antelle / argon2-browser

Argon2 library compiled for browser runtime
https://antelle.net/argon2-browser
MIT License
367 stars 79 forks source link

CompileError: WebAssembly.instantiate(): expected magic word 00 61 73 6d #45

Closed fea17e86 closed 4 years ago

fea17e86 commented 4 years ago

Hi!

Using argon2-browser with webpack brings up the following error message.

Uncaught (in promise) RuntimeError: abort(CompileError: WebAssembly.instantiate(): expected magic word 00 61 73 6d, found 6d 6f 64 75 @+0). Build with -s ASSERTIONS=1 for more info.
    at abort (http://localhost:3000/static/js/0.chunk.js:788:9)
    at http://localhost:3000/static/js/0.chunk.js:870:7

I also get the following warning before:

failed to asynchronously prepare wasm: CompileError: WebAssembly.instantiate(): expected magic word 00 61 73 6d, found 6d 6f 64 75 @+0

image

I would appreciate any hints.

antelle commented 4 years ago

Looks like it's not packed properly, you can find an example in this repo

fea17e86 commented 4 years ago

I actually used an example provided by this repo.

I tried the webpack configuration path first with a react-aap-rewired webpack config of

module.exports = function override(config, env) {
  config.module.noParse = /\.wasm$/;
  config.module.rules.unshift({
    test: /\.wasm$/,
    loaders: ["base64-loader"],
    type: "javascript/auto",
  });
  return config;
};

I also copied the js code from argon2.online, which results in the same error.

fea17e86 commented 4 years ago

I am actually using webpack together with TypeScript and Babel. Might this issue be related to that?

antelle commented 4 years ago

Indeed, because my config works. You should probably investigate what's going wrong. If you create a minimal example without dependencies, maybe I or someone else will help with that.

tbelch-at-eHealth-Tec commented 4 years ago

Okay...so in my minimal TypeScript Webpack example it works. It must be related to the whole react build setup than.

tbelch-at-eHealth-Tec commented 4 years ago

Btw, sorry for the confusion. I switched from my personal to my work account. ;)