Skip to content

Commit

Permalink
Create more variables for wrapped esms.
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Feb 22, 2021
1 parent 627cb75 commit 1b9dafb
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions bundler/src/bundler/chunk/computed_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,16 +353,20 @@ impl Fold for ExportToReturn<'_> {
ModuleDecl::ExportAll(export) => {
return ModuleItem::ModuleDecl(ModuleDecl::ExportAll(export))
}
ModuleDecl::ExportNamed(named) => {
for specifier in &named.specifiers {
ModuleDecl::ExportNamed(export) => {
for specifier in &export.specifiers {
match specifier {
ExportSpecifier::Namespace(_) => {}
ExportSpecifier::Default(_) => {}
ExportSpecifier::Named(named) => match &named.exported {
Some(exported) => {
// As named exports are converted to variables by other passes, we
// should not create a variable for it.
self.export_key_value(exported.clone(), named.orig.clone(), true);
// As injected named exports are converted to variables by other
// passes, we should not create a variable for it.
self.export_key_value(
exported.clone(),
named.orig.clone(),
export.span.ctxt == self.injected_ctxt,
);
}
None => {
self.export_id(named.orig.clone());
Expand All @@ -372,10 +376,10 @@ impl Fold for ExportToReturn<'_> {
}

// Ignore export {} specified by user.
if named.src.is_none() && named.span.ctxt != self.synthesized_ctxt {
if export.src.is_none() && export.span.ctxt != self.synthesized_ctxt {
None
} else {
return ModuleItem::ModuleDecl(ModuleDecl::ExportNamed(named));
return ModuleItem::ModuleDecl(ModuleDecl::ExportNamed(export));
}
}
ModuleDecl::TsImportEquals(_) => None,
Expand Down

0 comments on commit 1b9dafb

Please sign in to comment.