only-cliches / cpp-wasm-loader

C/C++ to WASM Webpack Loader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

File name index.wasm is expected

dr3 opened this issue · comments

When running initialize, even though the following object is defined for existingModule or userDefinedModule it always errors 404 because index.wasm isnt there and doesnt use wasm-a4af9bc10428694c23bf2f1bc5a442c8.wasm which is present.

{wasmBinaryFile: "wasm-a4af9bc10428694c23bf2f1bc5a442c8.wasm", ENVIRONMENT: "WEB"}

image

Hi, check this commit: dugagjin@dc09b8b, maybe it can solve your problem.

Ah thanks @Kobzol that fixes that issue, It still doesnt allow me to pick a different .wasm filename on initialize() though, Do you know if thats possible?

For example if you build it as wasm-a4af9bc10428694c23bf2f1bc5a442c8.wasm, could you rename it, or put it in a different directory and then when initialize() is called pass in ./dir/newfile.wasm

Im not sure if thats possible, any ideas? Thanks

I'm not sure how you mean that. During the build, Webpack creates the .wasm file, puts it in the build/dist folder and then hardcodes the path to it in all Javascript usages (similar to how e. g. CSS extraction works in Webpack). So if you renamed or moved the generated .wasm file, you would also have to edit the resulting JS file and update the paths to the WASM binary.

Ah ok, I was hoping you could update the .wasm filename on the fly, but I guess you cant without editing it in the js bundle, thanks anyway :)

Closing as dugagjinll/cpp-wasm-loader@dc09b8b fixed my problem

Ok :) Feel free to create a PR with the update that you made if you want.