Closed jkelleyrtp closed 3 years ago
Keep in mind that the approach in this PR requires "target specific features", which means that this change is somewhat incompatible with resolver = 1
. This may be fine, but it's something worth considering. It probably makes more sense to tie it to the wasm-client
feature.
Keep in mind that the approach in this PR requires "target specific features", which means that this change is somewhat incompatible with
resolver = 1
. This may be fine, but it's something worth considering. It probably makes more sense to tie it to thewasm-client
feature.
Thanks for the pointers. I switched the flag selection to use normal feature flags instead of the target-dependent flags.
I'll try to get 2.3.0 out "soon".
web-sys, getrandom and encoding now always get pulled in as dependencies. Well I guess at least it's semi optional via the feature, but the crates should still not be pulled in for targets that don't need them (or can't even compile them).
Those should only be pulled in when wasm-client
is selected though?
Yes, but due to resolver = 1, there are technically situations where that feature is active, but you aren't even compiling for WASM. (Resolver 1 is truly a mess)
Witch situations would those be? You have to manually activate the feature or have something else consciously activate it.
I believe it can be if you have multiple final binaries in the same workspace, where one ends up activating the feature for WASM and one compiles for x86. Another alternative is that there might be a crate that depends on surf, but always expects to be used only on WASM, so that crate might end up in your dependency graph (since all targets are always in the dependency graph. you can often find fuchsia and redox specific crates in Cargo.lock) and then even if you never intend to compile for WASM, this feature will be active. That's the issue with resolver 1. Technically you can ignore resolver 1 and say that surf is "only" compatible with resolver 2 (which basically has separate dependency graphs when it comes to the features for each target), but this is trivially fixable by undoing a few lines of this PR.
I can send a PR tomorrow that fixes it.
This PR pins getrandom to the "js" feature so that surf compiles on wasm32 again.
Solves #315
Before this change, when I tried to build the repo for wasm:
With these feature flags, I can build properly: