workers-rs
workers-rs copied to clipboard
Enable WebAssembly reference types
The Workers runtime recently updated to V8 9.6, which has support for WebAssembly reference types. wasm-bindgen also has support with an optional flag: https://rustwasm.github.io/wasm-bindgen/reference/reference-types.html
We use wasm-bindgen
through wasm-pack
which has had this related PR open for a while: https://github.com/rustwasm/wasm-pack/pull/888
I may take a look at it in the next week or so. Definitely would be nice to take advantage of this now that we have it supported!
EDIT: it's also maybe time to consider dropping wasm-pack
as the intermediary, and just call wasm-bindgen
directly. Will investigate.
it's also maybe time to consider dropping
wasm-pack
as the intermediary, and just callwasm-bindgen
directly. Will investigate.
Any news on this front? My two cents would be that wasm-pack
and also this repository's worker-build
include too much and try to hide too much from the developer. I would much rather have clear documentation about how to transform the output of wasm-bindgen
to something that can be consumed by wrangler
.
For example, in my case, I already use WebAssembly on my front-end and would like to build all my crates with a single innovation of cargo build
and to use webpack
for bundling instead of swc
(since webpack
is already used for the front-end), but wasm-pack
/worker-build
makes this very awkward.
Just in case, this issue can be closed, you can use --reference-types
now via modifying wrangler.toml
's build command (I believe it should be the default behavior, it's a big advantage and performance boost in many cases):
[build]
command = "cargo install -q worker-build --version 0.0.7 && worker-build --release --reference-types"
P.S. It's possible due to wasm-pack ability to pass those arguments to wasm-bindgen, and worker-build passes os-level arguments to wasm-pack (looks like it was the original design, which is great).