bevy_asset: Add missing web-sys feature and cleanup unused ones #13281
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
bevy_asset
includes code here that referencesweb_sys::WorkerGlobalScope
. However,bevy_asset
does not enable this feature, see here. Running examples does not catch this problem because the feature is implicitly included bywgpu
whenbevy_render
is also a dependency, see bevy_render and wgpu. This results in compile errors for environments that are not usingbevy_render
.To reproduce the problem, try to build the crate individually for wasm targets by running
cargo build -p bevy_asset --target wasm32-unknown-unknown
.Running
cargo tree -e features --target wasm32-unknown-unknown
helped diagnose the issue.Solution
This PR adds the
WorkerGlobalScope
feature to theweb-sys
portion ofbevy_asset
'sCargo.toml
.It also seems to be the case that
bevy_asset
no longer needs theRequest
feature, since no code forRequest
is present anymore. I confirmed that building the crate individually for wasm succeeds without the feature, so that change is also included here.This is a little off-topic, but the repository would probably benefit from some automation around these types of changes, but I'm not sure what would work there. For example, building each crate individually for some key targets would work, but is...well, a lot. Happy to follow up if there is agreement on a good direction.
Testing
Building the crate individually for wasm by running
cargo build -p bevy_asset --target wasm32-unknown-unknown
.I don't believe so.