Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embedding WebAssembly in Javascript code #1074

Open
yoshida-valuesccg opened this issue Oct 24, 2021 · 7 comments
Open

Embedding WebAssembly in Javascript code #1074

yoshida-valuesccg opened this issue Oct 24, 2021 · 7 comments

Comments

@yoshida-valuesccg
Copy link

yoshida-valuesccg commented Oct 24, 2021

💡 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.

@jmole
Copy link

jmole commented Oct 25, 2021

+1, I've been doing this by hand and would love a build system that does it automatically.

@SabrinaJewson
Copy link

See also #831. I posted a workaround there that works with Webpack.

@sassman
Copy link
Contributor

sassman commented Nov 17, 2021

so you proposing essentially --target inline and base64 encoded inline wasm loading?

@jmole
Copy link

jmole commented Nov 19, 2021

@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.

@expertfox
Copy link

I've been searching something like this for days. Has anyone done this with binding any canvas functions?

@xiaohk
Copy link

xiaohk commented Sep 21, 2022

Would love to have this!

@xiaohk
Copy link

xiaohk commented Sep 21, 2022

+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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants