smol-rs / fastrand

A simple and fast random number generator
Apache License 2.0
409 stars 35 forks source link

instant needs wasm-bindgen outside of dev #27

Closed zperk13 closed 1 year ago

zperk13 commented 2 years ago

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

taiki-e commented 2 years ago

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