-
Notifications
You must be signed in to change notification settings - Fork 38
Description
As brought up in #14 (comment), one problem with the ESM integration instance import model is that for multi-threading scenarios the memory import needs to be available at startup.
The ESM Phase Imports proposal also enables the ability for new Worker(wasmModule)
to create a worker from a WebAssembly module which is currently specified in #106.
Delaying instantiation via dynamic import provides one route, but it might be worth considering the ergonomics more carefully here.
One idea might be to allow passing module imports to the new Worker()
constructor when using the new source form:
import source mod from './mod.wasm';
const memory = new WebAssembly.Memory(...);
const worker = new Worker(source, {
imports: {
'memory': memory
}
});
Normally for dynamic import()
this sort of resolution override is dangerous due to mismatch with existing imports, but as the creator of the module environment it could be framed as a sort of top-level-only import map, so that setting imports for context creation can certainly work actually.
@sbc100 let me know if I'm summarizing the issue correctly or missing anything here too.