From cd4e381ef42e24e4f3cd5d9e75e32577d341898d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 21 Sep 2018 17:01:34 -0700 Subject: [PATCH] Pass `--debug` to `wasm-bindgen` in debug mode In debug mode `wasm-bindgen` emits more JS glue to check more invariants and otherwise provide more sanity checks. This is omitted by default with wasm-pack as it runs in release mode by default, but if `--debug` is passed let's be sure to include it! --- src/bindgen.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/bindgen.rs b/src/bindgen.rs index 60fd72c..d3d9e58 100644 --- a/src/bindgen.rs +++ b/src/bindgen.rs @@ -140,14 +140,19 @@ pub fn wasm_bindgen_build( _ => "--browser", }; let bindgen_path = Path::new(&wasm_bindgen_path); - let output = Command::new(bindgen_path) - .current_dir(path) + let mut cmd = Command::new(bindgen_path); + cmd.current_dir(path) .arg(&wasm_path) .arg("--out-dir") .arg(out_dir) .arg(dts_arg) - .arg(target_arg) - .output()?; + .arg(target_arg); + + if debug { + cmd.arg("--debug"); + } + + let output = cmd.output()?; if !output.status.success() { let s = String::from_utf8_lossy(&output.stderr); Error::cli("wasm-bindgen failed to execute properly", s)