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

Fixes #3929 Allow exporting functions named "default". #3930

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,10 @@

### Added

* Allow exporting functions named `default`. Throw error in wasm-bindgen-cli if --target web and
an exported symbol is named `default`.
[#3930](https://github.com/rustwasm/wasm-bindgen/pull/3930)

* Added support for arbitrary expressions when using `#[wasm_bindgen(typescript_custom_section)]`.
[#3901](https://github.com/rustwasm/wasm-bindgen/pull/3901)

Expand Down
7 changes: 7 additions & 0 deletions crates/cli-support/src/lib.rs
Expand Up @@ -327,6 +327,13 @@ impl Bindgen {
.context("failed getting Wasm module")?,
};

// Check that no exported symbol is called "default" if we target web.
if matches!(self.mode, OutputMode::Web)
daxpedda marked this conversation as resolved.
Show resolved Hide resolved
&& module.exports.iter().any(|export| export.name == "default")
{
bail!("exported symbol \"default\" not allowed for --target web")
}

let thread_count = self
.threads
.run(&mut module)
Expand Down
2 changes: 1 addition & 1 deletion crates/macro-support/src/parser.rs
Expand Up @@ -799,7 +799,7 @@ impl ConvertToAst<BindgenAttrs> for syn::ItemFn {
false,
None,
false,
None,
Some(&["default"]),
)?;
attrs.check_used();
Ok(ret.0)
Expand Down