How to use with a bundler?
See original GitHub issueHey there,
thanks for providing this awesome module to the community! I am trying to get this package to work with Webpack & React, but it turns out to be quite the issue. I suspect it is because of the way that the argon2.js
:
- Uses a factory and does not have a default export (webpack will bundle it in a scope which afaik is unaccessible afterwards), and
- Loads the asm-file from a
node_modules
folder which is supposed to be exposed (if I get this correctly)
I was able to get this to work with a bundler by copying both of these files, exposing the asm variant file, and then both adding a default export & changing the import path. Is there a way to get first hand support for bundlers so that this does not result in any issues? I suspect most people will not be willing to expose their node_modules, and I feel it is a really bad practice. On the other hand, my workaround will need to be updated manually, which might pose security risks at some point in time.
Would love to get your feedback on this!
Cheers
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
Done. Usage examples:
I used base64-loader because WebPack 4 is too smart and does some magic with WASM, however this magic doesn’t work with emscripten and it’s not possible to disable it, so I screwed it with base64-loader. If you manage to find another solution, please let me know.
Hi! Indeed exposing node_modules is not cool and it’s supposed to be used mostly for debugging.
Now WebPack has better support for loading WebAssembly, we can improve bundling as well. I’d be happy to see a merge request on this, but I’ll also try to implement it.