Skip to content

Commit

Permalink
ImportedSymbol::Exports
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed May 17, 2024
1 parent ef1d9a0 commit 1d2d58d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion crates/turbopack-ecmascript/src/analyzer/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ pub(crate) enum ImportedSymbol {
ModuleEvaluation,
Symbol(JsWord),
Namespace,
Exports,
Part(u32),
}

Expand Down Expand Up @@ -230,6 +231,10 @@ impl<'a> Analyzer<'a> {
imported_symbol: ImportedSymbol,
annotations: ImportAnnotations,
) -> Option<usize> {
if self.skip_namespace && matches!(imported_symbol, ImportedSymbol::Namespace) {
return None;
}

let issue_source = self
.source
.map(|s| IssueSource::from_swc_offsets(s, span.lo.to_usize(), span.hi.to_usize()));
Expand Down Expand Up @@ -404,7 +409,7 @@ fn parse_with(with: Option<&ObjectLit>) -> Option<ImportedSymbol> {
PartId::Internal(index) => ImportedSymbol::Part(index),
PartId::ModuleEvaluation => ImportedSymbol::ModuleEvaluation,
PartId::Export(e) => ImportedSymbol::Symbol(e.into()),
PartId::Exports => ImportedSymbol::Namespace,
PartId::Exports => ImportedSymbol::Exports,
})
}

Expand Down
4 changes: 3 additions & 1 deletion crates/turbopack-ecmascript/src/references/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ pub(crate) async fn analyse_ecmascript_module_internal(
}
ImportedSymbol::Symbol(name) => Some(ModulePart::export(name.to_string())),
ImportedSymbol::Part(part_id) => Some(ModulePart::internal(*part_id)),
ImportedSymbol::Exports => Some(ModulePart::exports()),
ImportedSymbol::Namespace => None,
},
Some(TreeShakingMode::ReexportsOnly) => match &r.imported_symbol {
Expand All @@ -573,8 +574,9 @@ pub(crate) async fn analyse_ecmascript_module_internal(
Some(ModulePart::evaluation())
}
ImportedSymbol::Symbol(name) => Some(ModulePart::export(name.to_string())),
ImportedSymbol::Namespace => None,
ImportedSymbol::Part(part_id) => Some(ModulePart::internal(*part_id)),
ImportedSymbol::Exports => Some(ModulePart::exports()),
ImportedSymbol::Namespace => None,
},
None => None,
},
Expand Down

0 comments on commit 1d2d58d

Please sign in to comment.