Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Oct 17, 2024
1 parent 3e73f36 commit ae1c61a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions turbopack/crates/turbopack-ecmascript/src/references/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,12 +591,6 @@ pub(crate) async fn analyse_ecmascript_module_internal(
.await?;

for (i, r) in eval_context.imports.references().enumerate() {
// If side effect free, ImportedSymbol::PartEvaluation doesn't need to be evaluated
let is_fragment_import = matches!(
r.imported_symbol,
ImportedSymbol::PartEvaluation(_) | ImportedSymbol::Part(_)
);

let r = EsmAssetReference::new(
origin,
Request::parse(Value::new(RcStr::from(&*r.module_path).into())),
Expand All @@ -611,7 +605,10 @@ pub(crate) async fn analyse_ecmascript_module_internal(
}
ImportedSymbol::Symbol(name) => Some(ModulePart::export((&**name).into())),
ImportedSymbol::PartEvaluation(part_id) => {
if !is_side_effect_free || !is_fragment_import {
// If side effect free, ImportedSymbol::PartEvaluation is also side effect
// free because ImportedSymbol::PartEvaluation is used only for
// __TURBOPACK_PART__ imports so it doesn't need to be evaluated
if !is_side_effect_free {
evaluation_references.push(i);
}
Some(ModulePart::internal(*part_id))
Expand Down

0 comments on commit ae1c61a

Please # to comment.