1
2
3
4
5
6
7
8
9
10
11
12
13
14
// node --import ./rust/host/swap.mjs --test <suites>: every import of javascript/src/run-module
// resolves to rust/host/conformance.mjs, so runModule (and everything built on them:
// harness handle(), runCompose) run on the Rust engine while the suites' assertions stay as written.
import { registerHooks } from "node:module";
const TARGET = new URL("../../javascript/src/run-module/index.js", import.meta.url).href;
const SWAPPED = new URL("./conformance.mjs", import.meta.url).href;
registerHooks({
resolve(specifier, context, next) {
const resolved = next(specifier, context);
return resolved.url === TARGET ? { ...resolved, url: SWAPPED } : resolved;
},
});