Skip to content

--npm-static rejects CJS bundles with require() below code reaching the binding (SC1013) #37

Description

@vinikjkkj

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions