Closed
Description
Describe the Bug
When using a Result
return type in a wasm-bindgen function without constructing a JsError
, the generated JavaScript includes an unexpected wasm-bindgen internal(?) import: import * as __wbg_star0 from '__wbindgen_externref_xform__';
.
Steps to Reproduce
Build the following
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn causes_error() -> Result<f64, JsError> {
return Ok(1.0);
}
// uncomment to prevent import issue
// #[wasm_bindgen]
// pub fn fix() -> JsError {
// return JsError::new("with this, no issue");
// }
with
cargo build --lib --target wasm32-unknown-unknown && wasm-bindgen.exe --target web --out-dir "pkg" ./target/wasm32-unknown-unknown/debug/test.wasm
or wasm-pack
Expected Behavior
JavaScript bindings for --target web
should not contain such imports.
Actual Behavior
JavaScript binding starts with
import * as __wbg_star0 from '__wbindgen_externref_xform__';
Additional Context
Using wasm-bindgen 0.2.99, rustc 1.83.0.
This seems to mostly be just an annoying behavior in an unlikely case, but took me a while of checking other things (e.g. for some version mismatch) to come up with the MRE.