-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Support outputting wasm as inline base64 #1880
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
Conversation
I searched around, but I'm not sure I found where the |
To my knowledge, it should be possible to use the (Though this is probably an interesting idea regardless). |
@Pauan Though most tools do support it, there's a few that don't facebook/create-react-app#4912 / node requiring extra flag It's copied from rollup, which does it with @rollup/plugin-wasm for wasm smaller than 4kb Although not ideal, it's intended for library authors. |
@samdenty Ah, right, I forgot about things like Angular (and apparently React) disabling wasm support (even though they use Webpack internally, which does support wasm out of the box). |
Thanks for the PR! I do agree with @Pauan though that this seems best left to bundlers rather than a different emission mode of wasm-bindgen itself. (we could add tons of various emission options but in general we try to leave most of them to bundlers). Can you speak more as to why, if webpack supports this, it's not supported through your use case? Is this perhaps best done as a feature request for those systems to pass through webpack configuration options? |
@alexcrichton The problem is that some of those projects (e.g. Angular) have refused to add support for |
That's a bummer :( If that's the case we could try to explore our own workaround, but I think there's a few things we'd want to consider:
|
This hasn't seen movement in quite some time now so I'm going to close this, feel free to resubmit it though! |
I'm using Parcel 2 because of it greatly improves compile times but it also unfortunately lacks wasm support atm. I'd like |
It's difficult to use
wasm-bindgen
in libraries meant to be consumed across a variety of bundler setups.Given an application using
pkg-a -> pkg-wasm
, you'd need to ship separate builds for bothpkg-wasm
andpkg-a
. This will be fixed when.wasm
imports become mainstream.In the meantime, this PR adds support for an
inline
option that outputs the wasm as Base64, in the JS file.This alleviates the need for separate builds, at the cost of a slightly larger bundle / no async streaming compiler.
Expected JS output