I'm trying out a simple hello world WebAssembly example and I'm having trouble understanding an error I'm seeing in Chrome 59:
RangeError: WebAssembly.Compile is disallowed on the main thread, if the buffer size is larger than 4KB. Use WebAssembly.compile, or compile on a worker thread.
src/wasm/counter.wasm:13
10 | let wa;
11 | const make = source => {
12 | // buffer should already be set
> 13 | return wa = new Module(buffer);
14 | };
15 |
16 | const WebAssemblyModule = function(deps = {
I've followed the steps in this tutorial, and I can build everything without error. I'm using create-react-app rewired with wasm-loader.
If I'm using my local build of the counter module I get the error I mentioned in the beginning. If I try and use a pre-built version (for example the one in this project) it works fine.
When I build my module, I'm using the same command as specified in the tutorial. The project with the working module has the same command listed in its README:
emcc counter.c -O1 -o counter.wasm -s WASM=1 -s SIDE_MODULE=1
Any idea what might be causing the error?