We plan to implement WebAssembly/ES Module Integration in GraalJS. This allows WebAssembly modules to be imported similarly to ES modules to improve the ergonomics of WebAssembly module instantiation.
Details
Currently, there is an imperative JS API for instantiating WebAssembly modules. This requires users to manually fetch a module file, wire up imports, and run WebAssembly.instantiate or WebAssembly.instantiateStreaming.
A declarative API would improve the ergonomics by making this work happen implicitly.
import { foo } from "./myModule.wasm";
foo();
Then by integrating with Source Phase Imports, arbitrary instantiations with custom imports can still be supported.
import source myModule from "./myModule.wasm";
const { foo: foo1 } = new WebAssembly.Instance(myModule, { ...imports1 });
foo1();
const { foo: foo2 } = new WebAssembly.Instance(myModule, { ...imports2 });
foo2();
For dynamically loaded modules, dynamic import() integration is also supported for both phases.
TL;DR
We plan to implement WebAssembly/ES Module Integration in GraalJS. This allows WebAssembly modules to be imported similarly to ES modules to improve the ergonomics of WebAssembly module instantiation.
Details
Currently, there is an imperative JS API for instantiating WebAssembly modules. This requires users to manually fetch a module file, wire up imports, and run
WebAssembly.instantiate
orWebAssembly.instantiateStreaming
.A declarative API would improve the ergonomics by making this work happen implicitly.
Then by integrating with Source Phase Imports, arbitrary instantiations with custom imports can still be supported.
For dynamically loaded modules, dynamic import() integration is also supported for both phases.
import source fibMod from "./fib.wasm
)import { fib } from "./fib.wasm
)