Skip to content

Commit

Permalink
feat(turbopack): Enable tree shaking for modules with dynamic imports (
Browse files Browse the repository at this point in the history
…#71692)

### What?

We can now enable tree shaking for modules that imports `next/dynamic`.

### Why?

The bug is now fixed.

### How?

Closes PACK-3231
  • Loading branch information
kdy1 authored Nov 18, 2024
1 parent 7e9e18b commit 7fdbabc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
6 changes: 3 additions & 3 deletions test/integration/telemetry/pages/warning.skip
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function a(v) {
return v
}
;['index.js'].forEach(async f => {
function a(v) {
return v
}
await import(a('./dynamic-file-imports/' + f))
})

Expand Down
10 changes: 0 additions & 10 deletions turbopack/crates/turbopack-ecmascript/src/tree_shake/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,16 +490,6 @@ impl Visit for ShouldSkip {
n.visit_children_with(self);
}

fn visit_callee(&mut self, n: &Callee) {
// TOOD(PACK-3231): Tree shaking work with dynamic imports
if matches!(n, Callee::Import(..)) {
self.skip = true;
return;
}

n.visit_children_with(self);
}

fn visit_expr(&mut self, n: &Expr) {
if self.skip {
return;
Expand Down

0 comments on commit 7fdbabc

Please sign in to comment.