fastrand icon indicating copy to clipboard operation
fastrand copied to clipboard

instant needs wasm-bindgen outside of dev

Open zperk13 opened this issue 2 years ago • 1 comments

In Cargo.toml, you have these lines of "code"

`[target.'cfg(target_arch = "wasm32")'.dependencies] instant = "0.1"

[target.'cfg(target_arch = "wasm32")'.dev-dependencies] instant = { version = "0.1", features = ["wasm-bindgen"] } wasm-bindgen-test = "0.3" getrandom = { version = "0.2", features = ["js"] }`

If I'm using wasm-bingen and fastrand, and I'm not using a dev-dependcy profile, the compiled wasm simply won't work (more info here).

I fixed it by adding instant = {version="*", features=["wasm-bindgen"]} to my Cargo.toml file, but if it's possible, I think your Cargo.toml file should be modified in a way so I don't have to do this

zperk13 avatar Jun 21 '22 04:06 zperk13

This is semi-intentional because we cannot deduce which JavaScript interface is in use from the target name alone (see also getrandom's doc).

taiki-e avatar Jul 02 '22 14:07 taiki-e