ustr icon indicating copy to clipboard operation
ustr copied to clipboard

WASM Compilation Error

Open romamik opened this issue 8 months ago • 1 comments

The last version that compiles successfully for WASM is 0.9.0. Versions 0.10.0 and 1.0.0 produce a compilation error when compiling the getrandom dependency:

error: the wasm*-unknown-unknown targets are not supported by default, you may need to enable the "js" feature. For more information see: https://docs.rs/getrandom/#webassembly-support
   --> /Users/romamik/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.2.15/src/lib.rs:342:9
    |
342 | /         compile_error!("the wasm*-unknown-unknown targets are not supported by \
343 | |                         default, you may need to enable the \"js\" feature. \
344 | |                         For more information see: \
345 | |                         https://docs.rs/getrandom/#webassembly-support");
    | |________________________________________________________________________^

Additionally, versions 0.8.0, 0.8.1, and 0.9.0 compile for WASM, but the generated JS contains an import of an unresolved module "env", similar to the issue described here: https://github.com/rustwasm/wasm-bindgen/issues/1907

Thus, the last version that actually works for WASM is 0.7.0.

Here is some small project: foo.zip

To build for WASM run wasm-pack build --target=web.

romamik avatar Jun 19 '24 10:06 romamik