Shared loader for the BUILT WASM artifact in public/wasm/.
Tests, benchmarks and tools that want to exercise the compiled kernels can't
go through initWasm(): it resolves a browser URL and, when that fails,
silently hands back a TypeScriptFallback — which would make a WASM-vs-TS
comparison compare TS with TS. They instead read the .wasm bytes
and initSync the wasm-bindgen shim directly. This module is the ONE place
that does that; src/tests/unit/wasm/direct-import-guard.test.ts keeps it
that way, and every caller gets the staleness check for free instead of
hand-copying it.
Why the staleness assertion is never inside the load catch
public/wasm/ is gitignored build output, so a checkout can hold a build that
imports and initialises fine while predating a newer kernel. A vitest run
mostly does not get that far — global-setup.ts scans the built shim for the
same required exports and REBUILDS a stale artifact before any test loads it —
so this check is the diagnosis for what setup cannot see: a MIXED build whose
shim declares every name while the .wasm behind it does not, and any caller
that runs outside that setup (benchmarks, tools).
assertRequiredWasmExports names those cases; it must be able to THROW.
Inside the catch that downgrades a load failure to a soft skip, its "missing
required export" message would be flattened into the generic "failed to load"
console line, the module would stay null, and every case below would then
fail on a null module — strictly worse than the opaque x is not a function
the check exists to replace. So tryLoadWasmArtifact catches ONLY the
import/initSync step and asserts after it, and loadWasmArtifact
catches nothing at all.
Shared loader for the BUILT WASM artifact in
public/wasm/.Tests, benchmarks and tools that want to exercise the compiled kernels can't go through
initWasm(): it resolves a browser URL and, when that fails, silently hands back aTypeScriptFallback— which would make a WASM-vs-TS comparison compare TS with TS. They instead read the.wasmbytes andinitSyncthe wasm-bindgen shim directly. This module is the ONE place that does that;src/tests/unit/wasm/direct-import-guard.test.tskeeps it that way, and every caller gets the staleness check for free instead of hand-copying it.Why the staleness assertion is never inside the load
catchpublic/wasm/is gitignored build output, so a checkout can hold a build that imports and initialises fine while predating a newer kernel. A vitest run mostly does not get that far —global-setup.tsscans the built shim for the same required exports and REBUILDS a stale artifact before any test loads it — so this check is the diagnosis for what setup cannot see: a MIXED build whose shim declares every name while the.wasmbehind it does not, and any caller that runs outside that setup (benchmarks, tools). assertRequiredWasmExports names those cases; it must be able to THROW. Inside the catch that downgrades a load failure to a soft skip, its "missing required export" message would be flattened into the generic "failed to load" console line, the module would staynull, and every case below would then fail on a null module — strictly worse than the opaquex is not a functionthe check exists to replace. So tryLoadWasmArtifact catches ONLY the import/initSyncstep and asserts after it, and loadWasmArtifact catches nothing at all.Pure Node module — no DOM, no vitest globals.