From 68d6de9a8392cc01c1a14a8541ba3f200e0ff59c Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Wed, 3 Sep 2025 14:41:53 -0500 Subject: [PATCH] Add a WASM build configuration The config.toml lets me run `cargo run --target wasm32-unknown-unknown` and host a dev server. I've adjusted the Cargo.toml to use the kdtree_rayon feature by default, but disable the Rayon feature for WASM builds (because it doesn't work). --- .cargo/config.toml | 2 ++ Cargo.toml | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..758ed610 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[target.wasm32-unknown-unknown] +runner = "wasm-server-runner" diff --git a/Cargo.toml b/Cargo.toml index 627d8ad0..99174d33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,6 @@ edition = "2024" [dependencies] bevy = "0.16.0" -bevy_spatial = "0.11.0" # Grand-dependency pins ab_glyph = "0.2.16" @@ -17,6 +16,16 @@ miniz-sys = "0.1.10" nonmax = "0.5.1" rand = "0.8.0" +# Use regular bevy_spatial on non-WASM builds +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +bevy_spatial = "0.11.0" + +# Use bevy_spatial *without* the kdtree_rayon feature when building for WASM. +[target.'cfg(target_arch = "wasm32")'.dependencies.bevy_spatial] +version = "0.11.0" +default-features = false +features = ["kdtree"] + [profile.dev] opt-level = 1