From 9069ef4c85c38d8d9bbd328632ee5a2dce8d9e0d Mon Sep 17 00:00:00 2001 From: Matthias Geihs Date: Fri, 14 Apr 2023 16:03:01 +0200 Subject: [PATCH 1/2] Add option: omit_default_module_path --- CHANGELOG.md | 2 ++ docs/src/cargo-toml-configuration.md | 4 ++++ src/bindgen.rs | 3 +++ src/manifest/mod.rs | 12 ++++++++++++ 4 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 659e344..0aec688 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1031,6 +1031,8 @@ demangle-name-section = true # Should we emit the DWARF debug info custom sections? dwarf-debug-info = false + # Should we omit the default import path? + omit-default-module-path = false ``` As always- there are defaults for you to use, but if you love to configure (or have a project that requires it), diff --git a/docs/src/cargo-toml-configuration.md b/docs/src/cargo-toml-configuration.md index 1f13ad5..613cc65 100644 --- a/docs/src/cargo-toml-configuration.md +++ b/docs/src/cargo-toml-configuration.md @@ -27,6 +27,8 @@ debug-js-glue = true demangle-name-section = true # Should we emit the DWARF debug info custom sections? dwarf-debug-info = false +# Should we omit the default import path? +omit-default-module-path = false [package.metadata.wasm-pack.profile.profiling] wasm-opt = ['-O'] @@ -35,6 +37,7 @@ wasm-opt = ['-O'] debug-js-glue = false demangle-name-section = true dwarf-debug-info = false +omit-default-module-path = false # `wasm-opt` is on by default in for the release profile, but it can be # disabled by setting it to `false` @@ -45,4 +48,5 @@ wasm-opt = false debug-js-glue = false demangle-name-section = true dwarf-debug-info = false +omit-default-module-path = false ``` diff --git a/src/bindgen.rs b/src/bindgen.rs index 58fab36..d50d2f7 100644 --- a/src/bindgen.rs +++ b/src/bindgen.rs @@ -91,6 +91,9 @@ pub fn wasm_bindgen_build( if profile.wasm_bindgen_dwarf_debug_info() { cmd.arg("--keep-debug"); } + if profile.wasm_bindgen_omit_default_module_path() { + cmd.arg("--omit-default-module-path"); + } child::run(cmd, "wasm-bindgen").context("Running the wasm-bindgen CLI")?; Ok(()) diff --git a/src/manifest/mod.rs b/src/manifest/mod.rs index 54f7740..7d8ef06 100644 --- a/src/manifest/mod.rs +++ b/src/manifest/mod.rs @@ -118,6 +118,9 @@ struct CargoWasmPackProfileWasmBindgen { #[serde(default, rename = "dwarf-debug-info")] dwarf_debug_info: Option, + + #[serde(default, rename = "omit-default-module-path")] + omit_default_module_path: Option, } struct Collector(Vec); @@ -283,6 +286,7 @@ impl CargoWasmPackProfile { debug_js_glue: Some(true), demangle_name_section: Some(true), dwarf_debug_info: Some(false), + omit_default_module_path: Some(false), }, wasm_opt: None, } @@ -294,6 +298,7 @@ impl CargoWasmPackProfile { debug_js_glue: Some(false), demangle_name_section: Some(true), dwarf_debug_info: Some(false), + omit_default_module_path: Some(false), }, wasm_opt: Some(CargoWasmPackProfileWasmOpt::Enabled(true)), } @@ -305,6 +310,7 @@ impl CargoWasmPackProfile { debug_js_glue: Some(false), demangle_name_section: Some(true), dwarf_debug_info: Some(false), + omit_default_module_path: Some(false), }, wasm_opt: Some(CargoWasmPackProfileWasmOpt::Enabled(true)), } @@ -346,6 +352,7 @@ impl CargoWasmPackProfile { d!(wasm_bindgen.debug_js_glue); d!(wasm_bindgen.demangle_name_section); d!(wasm_bindgen.dwarf_debug_info); + d!(wasm_bindgen.omit_default_module_path); if self.wasm_opt.is_none() { self.wasm_opt = defaults.wasm_opt.clone(); @@ -367,6 +374,11 @@ impl CargoWasmPackProfile { self.wasm_bindgen.dwarf_debug_info.unwrap() } + /// Get this profile's configured `[wasm-bindgen.omit-default-module-path]` value. + pub fn wasm_bindgen_omit_default_module_path(&self) -> bool { + self.wasm_bindgen.omit_default_module_path.unwrap() + } + /// Get this profile's configured arguments for `wasm-opt`, if enabled. pub fn wasm_opt_args(&self) -> Option> { match self.wasm_opt.as_ref()? { From 33691457d37b3cd596f1c5dadb422e165dfa5900 Mon Sep 17 00:00:00 2001 From: Matthias Geihs Date: Wed, 31 May 2023 13:00:38 +0200 Subject: [PATCH 2/2] Revert CHANGELOG --- CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0aec688..659e344 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1031,8 +1031,6 @@ demangle-name-section = true # Should we emit the DWARF debug info custom sections? dwarf-debug-info = false - # Should we omit the default import path? - omit-default-module-path = false ``` As always- there are defaults for you to use, but if you love to configure (or have a project that requires it),