-
Notifications
You must be signed in to change notification settings - Fork 433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default WASM bindings? #678
Comments
If one of the features will be enabled, then it will be easy to forget to disable default features. I think WASM feature should be enabled only by application level crates, and all library crates should stay unopinionated and enable one of those features only for dev profile. It's not convenient, but until ecosystem around WASM will settle down (e.g. until we'll get |
So, I have three points: 1- 2- Cargo features are not the right tool for this job. They are not compilation flags, and I have had to dig several times in the past through dependencies hell in order to fix this kind of bad usage of Cargo features. However, let's not care about this because almost nobody in the Rust ecosystem seems to care about this anyway, and because the only viable alternative is environment variables and build scripts, which people may not like. 3- If you take a look at this, the way it works is:
Seeing this, why not remove the
Which, for me, makes more sense. |
Yeah, but unfortunately we don't have better tools right now. Ideally "system RNG" should be selected with weak lang item (see e.g. discussion in #648), but for the time being we should work with that we have.
I probably should've maid it a compilation error as well. I think good compilation errors should reduce time to spent debugging such issues to a minimum. I hope @alexcrichton and/or @ashleygwilliams will help us here. |
That means that if you have a crate A that depends on rand+stdweb, and a crate B that depends on rand+wasm-bindgen, then there's no way can have a crate C that depends on both A and B. |
Yes, this is why earlier I've wrote that library crates shouldn't enable those features outside of dev profiles. If we do not mind getting opinionated, then we could choose one of them as a default and use another one if feature is enabled (i.e. do as you proposed). One drawback here will be that with the enabled feature both |
I do have plans to make That said, I do think that |
What about adding a runtime error if both features are disabled? My pragmatic concern is that right now if you write a library that has |
I think |
I believe runtime error in this case will go against Rust philosophy of handling as many errors at runtime as possible and practical. As a user I will be probably very surprised when I'll find out that I have to enable one of the features and there is no compilation-time error.
As I've wrote earlier in your [dev-dependencies]
rand_core = { version = "0.3", features = ["stdweb"] } This way
It already can be compiled right now, you just have to disable |
These APIs already return a Not everyone tests their crates on |
I think you misunderstood something. If we are talking about application crates, then you will have to just add |
Not sure why you're saying this because neither of these features were ever enabled by default. What 0.6.2 did break was moving them into I agree with @koute that we shouldn't make assumptions for @tomaka you can use a dev-dependency as suggested or add sub-crates into your project for testing which enable one of the features; I'm experimenting with the latter for Rand. |
0.6.1 didn't seem to have a |
I‘m using neither stdweb nor wasm-bindgen and rand 0.6.3 (and I guess 0.6.2) seem to have broken my crate, so I‘d like to see the compatibility for the case of neither brought back as well.
There is no target dependent features in cargo, so this doesn‘t work. |
True. I see; you want WASM with no extras to compile but with no
Why would you want |
It looks like criterion (dev-dependency) and parking_lot use it. So rand is not a direct dependency, but an indirect one. criterion isn't used for the wasm case, but for testing, and it very likely needs the std feature. parking_lot very likely needs the std feature for all the other targets too. So I don't think forcing them to not use std is an option. |
Presumably however you can run your tests without them using The alternative is compile-time disabling I guess then we need to replace those |
I had a quick look at |
@tomaka recently brought up the fact that this crate still fails to compile on WASM by default since explicit activation of either
stdweb
orwasm-bindgen
is required (see #676).Note that these are now "features" forwarded to the
rand_os
crate thanks to @newpavlov's #643.Should we enable one of these two features by default? Are
wasm-bindgen
andstdweb
compatible now? Is it likely that both projects will continue to exist in the future?I notice that we could now use
web-sys
bindings, though probably this achieves nothing over usingwasm-bindgen
directly and appears to lack the Node API bindings.CC @koute @fitzgen @alexcrichton
The text was updated successfully, but these errors were encountered: