You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it works but I found it a bit difficult due to rand dep
We have to make sure that Os::Rand is not called in the browser cause it panics. This can be configured in rand 0.7.3 by using rand = { version = "0.7.3", features = ["wasm-bindgen"] } however this is now deprecated in rust-random/rand#948 and I would need to do something along the same lines with getrandom now but the problem is basically the same.
This is basically a question of me not understanding how to best handle this in Cargo.toml and not sure if I need to do/ know something or if the proper way would be for this crate to make the solution easier.
As far as I understand, if I add rand as a dependency in my project explicitly (instead of it just being transitively required by age) I can specify feature flags and because both age and my crate use the same rand version, both use the one configured with my feature flag (my crate does not actually "use" rand itself, it just adds it as a dep such that it can set its features).
If however, for some reason, I would want to use a rand version incompatible with age, I could not use this solution and my create would use two rand versions at the same time (afaik this is supported by rust) (using one directly and another one as a dep of one age) and by doing this I would loose the ability to effectively set/ overwrite the feature flags of my transitive dependencies.
My suggestion is that I either don't understand how to handle this or that age might need to expose a feature flag which gets forwarded to rand.
(Performance is fine now that I compile in release mode btw. so your fix regarding os::Time was perfectly fine)
The text was updated successfully, but these errors were encountered:
Yes I think the way cargo handles setting features of dependencies of dependencies is less than ideal but it seems to be the current way how to do it so this can be closed.
What were you trying to do
compile to wasm
What happened
it works but I found it a bit difficult due to rand dep
We have to make sure that Os::Rand is not called in the browser cause it panics. This can be configured in rand 0.7.3 by using
rand = { version = "0.7.3", features = ["wasm-bindgen"] }
however this is now deprecated in rust-random/rand#948 and I would need to do something along the same lines with getrandom now but the problem is basically the same.This is basically a question of me not understanding how to best handle this in Cargo.toml and not sure if I need to do/ know something or if the proper way would be for this crate to make the solution easier.
As far as I understand, if I add rand as a dependency in my project explicitly (instead of it just being transitively required by age) I can specify feature flags and because both age and my crate use the same rand version, both use the one configured with my feature flag (my crate does not actually "use" rand itself, it just adds it as a dep such that it can set its features).
If however, for some reason, I would want to use a rand version incompatible with age, I could not use this solution and my create would use two rand versions at the same time (afaik this is supported by rust) (using one directly and another one as a dep of one age) and by doing this I would loose the ability to effectively set/ overwrite the feature flags of my transitive dependencies.
My suggestion is that I either don't understand how to handle this or that age might need to expose a feature flag which gets forwarded to rand.
(Performance is fine now that I compile in release mode btw. so your fix regarding os::Time was perfectly fine)
The text was updated successfully, but these errors were encountered: