mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-10 01:56:15 +08:00
tsc opens every CommonJS file with `exports.A = exports.B = void 0;` and later aliases `exports.A = A;`. Collection registered an export global for the chain's first name at the preamble, while the preamble lowered to nothing and the class alias registered and stored nothing. Importers then read `lib.A` from a global that was never assigned, and `new lib.A()` crashed with a segfault (chardet's encoding modules). The preamble detection moves to program.ts so collection and lowering share it. A dropped preamble whose real assignment is a class alias now registers no storage, so importers resolve to the class. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>