vercel-labs / vercel-labs/scriptc
--npm-static rejects CJS bundles with require() below code reaching the binding (SC1013)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.9k
- Forks
- 125
- Avg merge
- 2h 14m
- Merged PRs (30d)
- 95
Description
Summary
--npm-static auto falls back to the island for packages whose CJS output places a require() below code that can reach the resulting binding.
$ scriptc coverage app.ts --npm-static auto
npm packages compiled statically (--npm-static):
zapo-js island fallback (SC1013: require() below code that can reach its binding
'browser_1' (Node initializes the binding AT the require and throws ReferenceError
on any earlier access, which is not modeled — move the require above the code that
can run first) is not supported yet)
Environment: scriptc 0.0.17, zapo-js@1.6.2, Ubuntu 24.04 x86_64.
The diagnostic is clear and the workaround is understood — the package can hoist the require() in its build output. Filing mainly to register demand, since this pattern is common in bundler-emitted CJS and each occurrence silently costs a package its static lane.
No action expected if this is already on the roadmap.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported behavior with scriptc coverage app.ts --npm-static auto using zapo-js@1.6.2, then trace how the SC1013 diagnostic causes island fallback. The issue names no source files or tests; done would mean this CJS pattern can use the static lane instead of being rejected, with appropriate coverage for the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100