Run a loaded shim's default() — handing it an already-compiled module when
one is available.
wasm-bindgen's generated __wbg_init accepts either a raw value or
{ module_or_path }, and its __wbg_load skips new WebAssembly.Module(...)
when the value already IS a WebAssembly.Module. So passing one means the
binary is neither re-fetched nor re-compiled — which is the whole point:
15 workers each compiling their own copy came ready ~160 ms apart, 2.2 s from
first to last.
Exported (and given an injectable shim) for the same reason
importFirstWasmShim is: initWasm reaches the real shim through a
new Function('url', 'return import(url)') indirection that vitest's module
runner does not service, so this path cannot be exercised through
initWasm itself.
Degrades: a relocated or older shim that rejects the object form is retried
once with no argument. __wbg_init only assigns its module-scoped wasm
inside __wbg_finalize_init, so a throw before that leaves the retry clean.
Run a loaded shim's
default()— handing it an already-compiled module when one is available.wasm-bindgen's generated
__wbg_initaccepts either a raw value or{ module_or_path }, and its__wbg_loadskipsnew WebAssembly.Module(...)when the value already IS aWebAssembly.Module. So passing one means the binary is neither re-fetched nor re-compiled — which is the whole point: 15 workers each compiling their own copy came ready ~160 ms apart, 2.2 s from first to last.Exported (and given an injectable shim) for the same reason
importFirstWasmShimis:initWasmreaches the real shim through anew Function('url', 'return import(url)')indirection that vitest's module runner does not service, so this path cannot be exercised throughinitWasmitself.Degrades: a relocated or older shim that rejects the object form is retried once with no argument.
__wbg_initonly assigns its module-scopedwasminside__wbg_finalize_init, so a throw before that leaves the retry clean.