Target web with wasm-bindgen

I'm trying to deploy a wasm-bindgen library to be directly loaded by the browser without use of additional tools (Webpack).

https://rustwasm.github.io/wasm-bindgen/reference/deployment.html#without-a-bundler

I'm running cargo build --target web and it fails because indeed web doesn't make sense as a target triple. Have tried wasm32-unknown-unknown and I get no JavaScript artifact. What am I doing wrong?

Here, --target web is part of a wasm-bindgen or wasm-pack command, not cargo build.

(Also, you cannot build your application using only cargo build, because that will not create the JavaScript part.)

1 Like

I've considered running cargo install wasm-bindgen, but it does not seem to have a binary... am I missing something?

OK, found it:

cargo install -f wasm-bindgen-cli

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.