From 425c8b8b9fabc5888733148a9356f667a19de68a Mon Sep 17 00:00:00 2001 From: MevLyshkin Date: Fri, 17 Nov 2023 23:04:42 +0100 Subject: [PATCH] Fix wasm builds with file_watcher enabled (#10589) # 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 https://github.com/bevyengine/bevy/issues/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. --- crates/bevy_asset/Cargo.toml | 4 +++- crates/bevy_asset/src/io/mod.rs | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/bevy_asset/Cargo.toml b/crates/bevy_asset/Cargo.toml index 9f659b79c9..eb5e2ce6a2 100644 --- a/crates/bevy_asset/Cargo.toml +++ b/crates/bevy_asset/Cargo.toml @@ -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" } @@ -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" } diff --git a/crates/bevy_asset/src/io/mod.rs b/crates/bevy_asset/src/io/mod.rs index 14e52cddcb..a8e185d91c 100644 --- a/crates/bevy_asset/src/io/mod.rs +++ b/crates/bevy_asset/src/io/mod.rs @@ -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;