-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Avoid using browser-specific features when building for WASM #8520
base: main
Are you sure you want to change the base?
Avoid using browser-specific features when building for WASM #8520
Conversation
Also, this fixes #4906. |
3d3c34c
to
35d5001
Compare
is it possible to use |
That's a really good idea, but I was thinking that perhaps some users might prefer to build for WASM targets without relying on the wasm32-wasi target or using browser-specific APIs, without more to add, I am open to use this method. |
Are there targets others than wasm32-unknown-unknown, wasm32-wasi, and wasm32-unknown-enscripten? |
I think those are the only ones, but some users prefer to use |
Looks good! being able to run a Bevy app in CLI with wasmtime is nice. I would love to extend support of more Bevy crates, but that can happen later |
Great to hear that. Adding support for more Bevy crates would definitely be a great addition. Let me know if you need any assistance in that matter with a follow-up PR, I'd be happy to help out, but I would need to know what any other crates could be useful in a WASM context. |
On the top of my head:
For now this PR needs another review before being merged |
Objective 🎯
This PR aims to improve the support for non-browser environments by introducing a new Cargo feature gate
browser
. This helps us prevent the usage of web-specific crates, such aswasm-bindgen
,web-sys
,wasm-bindgen-futures
,js-sys
and others when building for an environment like WebAssembly System Interface.This ensures that Bevy remains a versatile game engine that can be used across a wide range of platforms and environments, without relying on browser-specific features that may not be available in other contexts, for example, embedding Bevy inside a WASI runtime for game extensions.
Overall, this PR seeks to enhance the flexibility and portability of the Bevy Game Engine, making it more accessible and easier to use for a broader range of developers and use cases.
Solution 💥
browser
.Changelog 👩🏻💻
bevy_app
,bevy_asset
,bevy_tasks
,bevy_log
andbevy_utils
.cfg
s to only usewasm-bindgen
and other crates when available.Migration Guide 🐛
Open Questions⁉️
wasm_bindgen_futures
. For now, I used the multi-thread code withavailable_parallelism
set to 0.bevy_render
andbevy_audio
? I think it's unneeded because we can't use WGPU inside WASI.