From 18477a0373e7369dbf0329990d7f4536d09bd22b Mon Sep 17 00:00:00 2001 From: Leon Wimbes <12753781+LeWimbes@users.noreply.github.com> Date: Thu, 15 May 2025 19:18:36 +0200 Subject: [PATCH] Fix `is_release_profile` Logic (#4091) * fix `is_release_profile` logic * fix: don't merge wasm-split modules with asset system, don't compress randomly --------- Co-authored-by: Jonathan Kelley --- packages/cli/src/build/request.rs | 6 +++--- packages/cli/src/workspace.rs | 12 ++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/cli/src/build/request.rs b/packages/cli/src/build/request.rs index 9cd00dd08..8ab7bfd62 100644 --- a/packages/cli/src/build/request.rs +++ b/packages/cli/src/build/request.rs @@ -2953,7 +2953,7 @@ impl BuildRequest { /// Check if assets should be pre_compressed. This will only be true in release mode if the user /// has enabled pre_compress in the web config. fn should_pre_compress_web_assets(&self, release: bool) -> bool { - self.config.web.pre_compress && release + self.config.web.pre_compress & release } /// Bundle the web app @@ -3147,7 +3147,7 @@ impl BuildRequest { // In release mode, we make the wasm and bindgen files into assets so they get bundled with max // optimizations. - let wasm_path = if self.release { + let wasm_path = if self.release && !should_bundle_split { // Register the main.js with the asset system so it bundles in the snippets and optimizes let name = assets.register_asset( &self.wasm_bindgen_js_output_file(), @@ -3159,7 +3159,7 @@ impl BuildRequest { format!("wasm/{}", asset.file_name().unwrap().to_str().unwrap()) }; - let js_path = if self.release { + let js_path = if self.release && !should_bundle_split { // Make sure to register the main wasm file with the asset system let name = assets.register_asset(&post_bindgen_wasm, AssetOptions::Unknown)?; format!("assets/{}", name.bundled_path()) diff --git a/packages/cli/src/workspace.rs b/packages/cli/src/workspace.rs index 6f2cb908b..7cc8f6cf0 100644 --- a/packages/cli/src/workspace.rs +++ b/packages/cli/src/workspace.rs @@ -107,16 +107,16 @@ impl Workspace { } pub fn is_release_profile(&self, profile: &str) -> bool { + if profile == "release" { + return true; + } + // Check if the profile inherits from release by traversing the `inherits` chain let mut current_profile_name = profile; // Try to find the current profile in the custom profiles section while let Some(profile_settings) = self.cargo_toml.profile.custom.get(current_profile_name) { - if profile == "release" { - return true; - } - // Check what this profile inherits from match &profile_settings.inherits { // Otherwise, continue checking the profile it inherits from @@ -126,6 +126,10 @@ impl Workspace { // Since it didn't lead to "release", return false. None => break, } + + if current_profile_name == "release" { + return true; + } } false