wasm-pack
wasm-pack copied to clipboard
Embedding WebAssembly in Javascript code
💡 Feature description
I wish wasm-pack could do something like this
.
The feature is almost the same as doing wasm-pack build --target nodejs
except, instead of doing
const path = require('path').join(__dirname, 'xxx_bg.wasm');
const bytes = require('fs').readFileSync(path);
do
// convert wasm file into base64 and embed it
const base64Wasm = "AGFzbQEAAAABBwFgAn9/AX8DAgEABwcBA2FkZAAACgkBBwAgACABags=";
const bytes = base64Decode(base64Wasm);
This is very helpful because I dont have to worry about .wasm file in both nodejs and web.
+1, I've been doing this by hand and would love a build system that does it automatically.
See also #831. I posted a workaround there that works with Webpack.
so you proposing essentially --target inline
and base64 encoded inline wasm loading?
@sassman that's the gist of it, at least from my perspective. It offers a nice "one-file" solution to incorporate wasm into a webpage.
I've been searching something like this for days. Has anyone done this with binding any canvas functions?
Would love to have this!
+1, I've been doing this by hand and would love a build system that does it automatically.
Hey @jmole, how did you do this by hand?