-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix(es/transforms/cjs): Allow mixing named exports and export stars. #2583
Conversation
…th, according to babel output for the same code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Nice work, but I found some small issues.
@@ -155,6 +155,19 @@ where | |||
ref specifiers, | |||
.. | |||
})) => { | |||
// handle: export {sym as alias1, alias2, ...} | |||
for ExportNamedSpecifier { orig, exported, .. } in | |||
specifiers.into_iter().map(|e| match e { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think filter_map
with None
for other cases is better.
(Although I don't have concrete input which breaks this)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed a change to try to address this. I hope it's in line with what you were thinking - I had previously used a pattern that I saw was elsewhere in the code.
_ => unreachable!(), | ||
}) | ||
{ | ||
if !exported.is_none() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use
if let Some(exported). = &exported {
exports.push(exported.sym.clone());
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
This is my attempt at fixing #2548.
swc_ecma_transforms_module:
common_js
: Fix _exportNames when exporting aliases and usingexport *
s . (export {default as name} can create duplicate symbols #2548)