mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-05 08:13:06 +08:00
A top-level var statement that mixes require() declarators with other
bindings, the shape bundlers emit (`var EventEmitter = require("events"),
Base = class extends EventEmitter {}`), registered a module global for each
require declarator, because the whole-statement skip only applied when every
declarator was a require. The statement lowering treats each require
declarator as alias plumbing and never assigns it, so a read that resolved
to that global saw null: `new EventEmitter` in a class constructor called
through a null class object and crashed with SIGSEGV. A builtin require in a
nested block (`if (c) { var fs = require("fs"); }`) had the same mismatch.
Collection now skips storage for each such declarator, with the same
registrations a whole require statement makes, so reads resolve to the
module as they do for a statement of requires only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>