wasmer-js
wasmer-js copied to clipboard
How to use wasmer-js in the browser?
I'm trying to create a bundle for running wasmer-js in the browser. However, I keep on running into issues. Specifically, the browser bindings seem to import a buffer/crypto polyfill. However, this buffer polyfill is not installed as a dependency, so my script crashes in the browser.
How do we build a Javascript file that uses wasmer-js, with the necessary dependencies attached, that will run in the browser?
I am using rollup. I've tried several different methods, but I keep on running into undefined variables and other such things.
Specifically, I get the issue:
Missing global variable names
Use output.globals to specify browser global variable names corresponding to external modules
crypto (guessing 'crypto')
buffer (guessing 'buffer$1')
Reproduction repo: https://github.com/vedantroy/wasmer-js-reproduction
It seems there is an issue in the rollup bundler. Crypto and buffer should be automatically added by rollup to the bundle, but they aren't.
You might need https://github.com/calvinmetcalf/rollup-plugin-node-builtins
Did you solve this in the meantime @vedantroy ?
This is no longer an issue in Wasmer's new JavaScript SDK, @wasmer/sdk.