Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wasmbindgen option: omit_default_module_path #1272

Merged
merged 2 commits into from
Jun 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the old changelog should be edited.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops 🙈 Thanks for catching this one 🙏 Added a revert commit for CHANGELOG.

```

As always- there are defaults for you to use, but if you love to configure (or have a project that requires it),
Expand Down
4 changes: 4 additions & 0 deletions docs/src/cargo-toml-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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`
Expand All @@ -45,4 +48,5 @@ wasm-opt = false
debug-js-glue = false
demangle-name-section = true
dwarf-debug-info = false
omit-default-module-path = false
```
3 changes: 3 additions & 0 deletions src/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
12 changes: 12 additions & 0 deletions src/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ struct CargoWasmPackProfileWasmBindgen {

#[serde(default, rename = "dwarf-debug-info")]
dwarf_debug_info: Option<bool>,

#[serde(default, rename = "omit-default-module-path")]
omit_default_module_path: Option<bool>,
}

struct Collector(Vec<u8>);
Expand Down Expand Up @@ -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,
}
Expand All @@ -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)),
}
Expand All @@ -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)),
}
Expand Down Expand Up @@ -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();
Expand All @@ -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<Vec<String>> {
match self.wasm_opt.as_ref()? {
Expand Down