Found while landing #6559 (PR #6584): ajv@8 compiles natively (compilePackages) but ajv.compile() throws ReferenceError: addNames is not defined at library init — before any runtime-generated code runs.
Root shape: in ajv's dist/compile/codegen/index.js, class methods call the module-level function addNames that is declared later in the same CJS file. Node hoists the function declaration module-wide; perry's CJS compilation apparently binds the class-method reference before/without the hoisted binding, so the call site sees an undefined free variable.
Repro: run the #[ignore]d e2e in crates/perry/tests/issue_6559_real_libs_e2e.rs (PERRY_REQUIRE_NPM_E2E=1 … -- --ignored), or reduce to: a CJS module where a class method references a function declared after the class, instantiated + called from another module.
Blocks: #6559 real-library acceptance (ajv leg), kimi-code target #6565 (fastify stack inits ajv). The interpreter side is already proven against ajv's captured generated code (PR #6584 fixture suite), so this hoisting gap is the only thing between ajv and green.
Found while landing #6559 (PR #6584): ajv@8 compiles natively (compilePackages) but
ajv.compile()throwsReferenceError: addNames is not definedat library init — before any runtime-generated code runs.Root shape: in ajv's
dist/compile/codegen/index.js, class methods call the module-level functionaddNamesthat is declared later in the same CJS file. Node hoists the function declaration module-wide; perry's CJS compilation apparently binds the class-method reference before/without the hoisted binding, so the call site sees an undefined free variable.Repro: run the
#[ignore]d e2e incrates/perry/tests/issue_6559_real_libs_e2e.rs(PERRY_REQUIRE_NPM_E2E=1 … -- --ignored), or reduce to: a CJS module where a class method references afunctiondeclared after the class, instantiated + called from another module.Blocks: #6559 real-library acceptance (ajv leg), kimi-code target #6565 (fastify stack inits ajv). The interpreter side is already proven against ajv's captured generated code (PR #6584 fixture suite), so this hoisting gap is the only thing between ajv and green.