Skip to content

Commit

Permalink
Fix wasm builds with file_watcher enabled (#10589)
Browse files Browse the repository at this point in the history
# Objective

- Currently, in 0.12 there is an issue that it is not possible to build
bevy for Wasm with feature "file_watcher" enabled. It still would not
compile, but now with proper explanation.
- Fixes #10507


## Solution

- Remove `notify-debouncer-full` dependency on WASM platform entirely.
- Compile with "file_watcher" feature now on platform `wasm32` gives
meaningful compile error.

---

## Changelog

### Fixed

- Compile with "file_watcher" feature now on platform `wasm32` gives
meaningful compile error.
  • Loading branch information
Leinnan authored and cart committed Nov 30, 2023
1 parent 55e74ea commit 425c8b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/bevy_asset/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ parking_lot = { version = "0.12", features = ["arc_lock", "send_guard"] }
ron = "0.8"
serde = { version = "1", features = ["derive"] }
thiserror = "1.0"
notify-debouncer-full = { version = "0.3.1", optional = true }

[target.'cfg(target_os = "android")'.dependencies]
bevy_winit = { path = "../bevy_winit", version = "0.12.0" }
Expand All @@ -49,5 +48,8 @@ web-sys = { version = "0.3", features = ["Request", "Window", "Response"] }
wasm-bindgen-futures = "0.4"
js-sys = "0.3"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
notify-debouncer-full = { version = "0.3.1", optional = true }

[dev-dependencies]
bevy_core = { path = "../bevy_core", version = "0.12.0" }
7 changes: 7 additions & 0 deletions crates/bevy_asset/src/io/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#[cfg(all(feature = "file_watcher", target_arch = "wasm32"))]
compile_error!(
"The \"file_watcher\" feature for hot reloading does not work \
on WASM.\nDisable \"file_watcher\" \
when compiling to WASM"
);

#[cfg(target_os = "android")]
pub mod android;
pub mod embedded;
Expand Down

0 comments on commit 425c8b8

Please sign in to comment.