Skip to content

Commit 5767be9

Browse files
authored
Fixes #3929 Allow exporting functions named "default". (#3930)
1 parent b4da51c commit 5767be9

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
### Added
77

8+
* Allow exporting functions named `default`. Throw error in wasm-bindgen-cli if --target web and
9+
an exported symbol is named `default`.
10+
[#3930](https://github.com/rustwasm/wasm-bindgen/pull/3930)
11+
812
* Added support for arbitrary expressions when using `#[wasm_bindgen(typescript_custom_section)]`.
913
[#3901](https://github.com/rustwasm/wasm-bindgen/pull/3901)
1014

crates/cli-support/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,13 @@ impl Bindgen {
327327
.context("failed getting Wasm module")?,
328328
};
329329

330+
// Check that no exported symbol is called "default" if we target web.
331+
if matches!(self.mode, OutputMode::Web)
332+
&& module.exports.iter().any(|export| export.name == "default")
333+
{
334+
bail!("exported symbol \"default\" not allowed for --target web")
335+
}
336+
330337
let thread_count = self
331338
.threads
332339
.run(&mut module)

crates/macro-support/src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ impl ConvertToAst<BindgenAttrs> for syn::ItemFn {
799799
false,
800800
None,
801801
false,
802-
None,
802+
Some(&["default"]),
803803
)?;
804804
attrs.check_used();
805805
Ok(ret.0)

0 commit comments

Comments
 (0)