The WebAssembly JS-API specification currently states that WebAssembly.Instance() must throw if importObject is undefined while the module declares imports. However, modules that only import JS builtins (for example from the wasm:js-string namespace) do not require an importObject.
The spec text does not clearly define this exception, which leads to inconsistent behavior across implementations. In particular, Firefox currently throws a TypeError in this situation, while Chrome (and I believe Safari) do not.
Currently the spec states
If module.imports is not empty, and importObject is undefined, throw a TypeError exception.
I think the spec should explicitly state that imports satisfied by builtins such as wasm:js-string do not require a user-supplied importObject, even if module.imports is non-empty.
The WebAssembly JS-API specification currently states that
WebAssembly.Instance()must throw ifimportObjectisundefinedwhile the module declares imports. However, modules that only import JS builtins (for example from thewasm:js-stringnamespace) do not require an importObject.The spec text does not clearly define this exception, which leads to inconsistent behavior across implementations. In particular, Firefox currently throws a TypeError in this situation, while Chrome (and I believe Safari) do not.
Currently the spec states
I think the spec should explicitly state that imports satisfied by builtins such as
wasm:js-stringdo not require a user-suppliedimportObject, even ifmodule.importsis non-empty.