I'm running the tutorial on webassembly.org and now I want to run the hello.wasm from my own page.
I'm compiling the code using Emscripten as per tutorial's instructions.
Following these instructions in my index.html I'm doing:
const instantiate = (bytes, imports = {}) =>
WebAssembly.compile(bytes).then(m =>
new WebAssembly.Instance(m, imports)
)
fetch('hello.wasm')
.then(response => response.arrayBuffer())
.then(bytes => instantiate(bytes, {}))
But I get this error:
So I tried to use WebAssembly.instantiate() from the MDN docs with this code:
const instantiate = (bytes, imports = {}) =>
WebAssembly.compile(bytes).then(m =>
WebAssembly.instantiate(m, imports)
)
And I get a different one:
Any idea how to fix it?


compilein your second example, onlyinstantiate: it takes the.wasmbytes and compile+instantiates them. What is theimportsobject? Or do you leave it as default{}? What are your module's declared imports (from Emscripten I assume)?instantiate, it fails with the same error. I'm passing it an empty object asimportsand I don't know of needed dependencies.hello.wasmfor you, including the WebAssembly import object. What Emscripten generates is pretty big because it emulates an OS. The import object basically supplies all the syscalls (to JavaScript). You'd have to pass these in for the example to work... or just use the ones Emscripten already generated.