I'm reading the book
Learn WebAssembly by Mike Rourke, and in chapter 5 in the book I have to write this code:
https://gist.github.com/DragonOsman/54c0266c3cf30bd5bcde3dc27a53764d . What the chapter is showing in the section the code is from is how to write the Wasm loading code yourself. (In the book, the loadWasm stuff is in a separate file which is linked into the HTML page in the head element, but with that the browser can't see the function. So I put it with the rest of the JavaScript code. And the whole code was in the HTML file itself which I don't like, so I put it in a separate file.)
As the title says, I have an uncaught promise error in WebAssembly.instantiate. It's thrown because of the _jsClearRect function on line 46. I don't understand why the error is being thrown or how to fix it, though. The file without-glue.c shows the C code that was compiled.
Any help is appreciated.
PS. Is there a way to persistently save the temporary JS file created when Emscripten runs? The file that's run through Node when compiling C/C++ code. When I try to compile anything using the Wasm backend on Windows, and I use the -s SIDE_MODULE setting, it generates a .wasm file that doesn't work (without that setting, there's JS glue code but no .wasm file). And along with that, I get Node returning a nonzero value and an empty output when called with the temporary JS file as input.
I posted about it here:
https://github.com/emscripten-core/emscripten/issues/8557 . Sam Clegg said it's possible to do this, but that it requires hacking the JS code? I don't know what changes to make to the code so I can't do anything here. Would someone please help? Right now I'm sticking to using WSL when I want to use the Wasm backend on Windows.