mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-28 06:53:42 +08:00
Two fixes for the CommonJS cycle check and the bundled-chunk splitter: - During a cycle's initialization, a read of a partner's exported function is safe only where the value neither runs nor stays: an expression statement, typeof, void, !, an equality operand, or the test of if, while, do and ?:. A const alias (`const f = binding.fn`), an object or array literal, a return, or an argument can be called before the cycle settles, so these keep SC1016 (Node throws when the function reads a binding in its temporal dead zone). A top-level const that only publishes the function in an export statement, as the static rewrite spells an export-table re-export, stays a read. - A copied helper whose initializer is a named function expression reaches itself through its own name. Each chunk gets its own copy, so that name must also be used only as a callee; otherwise the chunk keeps the package refused with the existing reason.