From 9f19708590cbe14016873d7fadc3c5e87333144c Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Sat, 18 Jul 2026 02:24:11 -0700 Subject: [PATCH] fix(eshost): run module-flagged .js tests as their real file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The adapter copied module-flagged .js entries to a .mjs twin and ran that, so a fixture's self- or cyclic-import of the original .js resolved to a DIFFERENT file than the running entry — masking runtime module dedup and double-evaluating the module graph. The copy is redundant: the temp dir's package.json {"type":"module"} already parses .js entries as ESM. Removing it lets the entry run under its real name so self-imports dedupe. Validated with a 4-cell matrix (old/new runtime x old/new adapter) on language/module-code: +52 passes only with runtime fix d75351730 AND this change; adapter alone is a no-op. Full test262 corpus with both: 92,732/103,361, +143 new passes, 0 regressions. Co-Authored-By: Claude Fable 5 --- harness/src/eshost-elide/agent.elide.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/harness/src/eshost-elide/agent.elide.js b/harness/src/eshost-elide/agent.elide.js index bb679a6..20a65ed 100644 --- a/harness/src/eshost-elide/agent.elide.js +++ b/harness/src/eshost-elide/agent.elide.js @@ -144,15 +144,12 @@ class ElideAgent extends ConsoleAgent { // Fixture copying is best-effort; the test itself still runs. } } - if (this._elideModule && args[0].endsWith(".js")) { - const mjs = `${args[0].slice(0, -3)}.mjs`; - try { - fs.copyFileSync(args[0], mjs); - args = [mjs, ...args.slice(1)]; - } catch { - // Fall back to the original `.js` file if the copy fails. - } - } + // A module-flagged `.js` entry runs as ESM via the `{"type":"module"}` + // marker written above — no `.mjs` copy needed. Copying to `.mjs` would + // give the entry a distinct file identity from any self/cyclic import that + // names the original `.js` (e.g. instn-*_FIXTURE re-exports), splitting one + // module into two instances and breaking TDZ/binding-identity tests. Run + // the `.js` in place so those imports dedupe to the single entry record. } return super.createChildProcess(args, options); }