diff --git a/packages/compiler/src/frontend/lowering/lowerer.ts b/packages/compiler/src/frontend/lowering/lowerer.ts index 9acba4606..d1eb4bd7a 100644 --- a/packages/compiler/src/frontend/lowering/lowerer.ts +++ b/packages/compiler/src/frontend/lowering/lowerer.ts @@ -1168,6 +1168,10 @@ export function lowerToIr( function markModuleInitFences(program: ts.Program, fences: readonly ScrDiagnostic[]): void { for (const d of fences) { if (!d.loc.file.includes("/node_modules/")) continue; + // A fence without a source position belongs to synthesized code, such + // as the global object's lookup (global-values.ts), which runs when the + // program calls it, not when the module evaluates. + if (d.loc.start < 0) continue; const sf = program.getSourceFile(d.loc.file); if (sf === undefined) continue; let inFunction = false; diff --git a/tests/fixtures/node-island/order/node_modules/orderkit/index.js b/tests/fixtures/node-island/order/node_modules/orderkit/index.js index 072e3c4ff..9d4bfa8f4 100644 --- a/tests/fixtures/node-island/order/node_modules/orderkit/index.js +++ b/tests/fixtures/node-island/order/node_modules/orderkit/index.js @@ -1,5 +1,6 @@ "use strict"; -// Loads its part through a computed specifier, so it runs in a Node island. +// Loads its part through a computed specifier when it loads, so it runs in +// a Node island. const { createRequire } = require("node:module"); -const parts = ["./thing"].map((p) => createRequire(__filename)(p)); +const parts = [createRequire(__filename)(["./thing"][0])]; exports.make = () => new parts[0].Thing();