Skip to content

Commit 24f20ae

Browse files
authored
Prevent generating duplicate exports (#4380)
1 parent 88452fa commit 24f20ae

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@
7070
* Fixed `no_std` support for all APIs in `web-sys`.
7171
[#4378](https://github.com/rustwasm/wasm-bindgen/pull/4378)
7272

73+
* Prevent generating duplicate exports for closure conversions.
74+
[#4380](https://github.com/rustwasm/wasm-bindgen/pull/4380)
75+
7376
--------------------------------------------------------------------------------
7477

7578
## [0.2.99](https://github.com/rustwasm/wasm-bindgen/compare/0.2.98...0.2.99)

crates/cli-support/src/js/mod.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4270,8 +4270,18 @@ __wbg_set_wasm(wasm);"
42704270
"memory".to_owned()
42714271
}
42724272
walrus::ExportItem::Function(f) => match &self.module.funcs.get(f).name {
4273-
Some(s) => to_js_identifier(s),
4274-
None => default_name,
4273+
Some(s) => {
4274+
let mut name = to_js_identifier(s);
4275+
4276+
// Account for duplicate export names.
4277+
// See https://github.com/rustwasm/wasm-bindgen/issues/4371.
4278+
if self.module.exports.get_func(&name).is_ok() {
4279+
name.push_str(&self.next_export_idx.to_string());
4280+
}
4281+
4282+
name
4283+
}
4284+
_ => default_name,
42754285
},
42764286
_ => default_name,
42774287
};

0 commit comments

Comments
 (0)