From 5b8bc358dba2eff36c009efbb55acad338913711 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Wed, 3 Dec 2025 11:51:34 -0600 Subject: [PATCH] Override strip even if you explicitly enable it in the passed profile (#5052) --- packages/cli/src/build/request.rs | 47 +++++++++++++++---------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/packages/cli/src/build/request.rs b/packages/cli/src/build/request.rs index 0b8a9685f..bbdccd944 100644 --- a/packages/cli/src/build/request.rs +++ b/packages/cli/src/build/request.rs @@ -5211,44 +5211,41 @@ __wbg_init({{module_or_path: "/{}/{wasm_path}"}}).then((wasm) => {{ /// /// Note how every platform gets its own profile, and each platform has a dev and release profile. fn profile_args(&self) -> Vec { + // Always disable stripping so symbols still exist for the asset system. We will apply strip manually + // after assets are built + let profile = self.profile.as_str(); + let mut args = Vec::new(); + args.push(format!(r#"profile.{profile}.strip=false"#)); + // If the user defined the profile in the Cargo.toml, we don't need to add it to our adhoc list - if self + if !self .workspace .cargo_toml .profile .custom .contains_key(&self.profile) { - return vec![]; - } + // Otherwise, we need to add the profile arguments to make it adhoc + let inherits = if self.release { "release" } else { "dev" }; - // Otherwise, we need to add the profile arguments to make it adhoc - let mut args = Vec::new(); + // Add the profile definition first. + args.push(format!(r#"profile.{profile}.inherits="{inherits}""#)); - let profile = self.profile.as_str(); - let inherits = if self.release { "release" } else { "dev" }; + // The default dioxus experience is to lightly optimize the web build, both in debug and release + // Note that typically in release builds, you would strip debuginfo, but we actually choose to do + // that with wasm-opt tooling instead. + if matches!(self.bundle, BundleFormat::Web) { + if self.release { + args.push(format!(r#"profile.{profile}.opt-level="s""#)); + } - // Add the profile definition first. - args.push(format!(r#"profile.{profile}.inherits="{inherits}""#)); - - // The default dioxus experience is to lightly optimize the web build, both in debug and release - // Note that typically in release builds, you would strip debuginfo, but we actually choose to do - // that with wasm-opt tooling instead. - if matches!(self.bundle, BundleFormat::Web) { - if self.release { - args.push(format!(r#"profile.{profile}.opt-level="s""#)); - } - - if self.wasm_split { - args.push(format!(r#"profile.{profile}.lto=true"#)); - args.push(format!(r#"profile.{profile}.debug=true"#)); + if self.wasm_split { + args.push(format!(r#"profile.{profile}.lto=true"#)); + args.push(format!(r#"profile.{profile}.debug=true"#)); + } } } - // Always disable stripping so symbols still exist for the asset system. We will apply strip manually - // after assets are built - args.push(format!(r#"profile.{profile}.strip=false"#)); - // Prepend --config to each argument args.into_iter() .flat_map(|arg| ["--config".to_string(), arg])