Skip to content

Commit 6bb438b

Browse files
committed
next/dynamic
1 parent 80cb74a commit 6bb438b

File tree

1 file changed

+11
-1
lines changed
  • turbopack/crates/turbopack-ecmascript/src/tree_shake

1 file changed

+11
-1
lines changed

turbopack/crates/turbopack-ecmascript/src/tree_shake/util.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,18 @@ pub fn should_skip_tree_shaking(m: &Program, special_exports: &[RcStr]) -> bool
399399
match item {
400400
// Skip turbopack helpers.
401401
ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl {
402-
with, specifiers, ..
402+
src,
403+
with,
404+
specifiers,
405+
..
403406
})) => {
407+
// We detect imports from next/dynamic in various places.
408+
// See collect_next_dynamic_imports. We need to preserve the import of
409+
// `next/dynamic`.
410+
if src.value == "next/dynamic" {
411+
return false;
412+
}
413+
404414
if let Some(with) = with.as_deref().and_then(|v| v.as_import_with()) {
405415
for item in with.values.iter() {
406416
if item.key.sym == *TURBOPACK_HELPER {

0 commit comments

Comments
 (0)