Skip to content

Commit

Permalink
next/dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Oct 10, 2024
1 parent 80cb74a commit 6bb438b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion turbopack/crates/turbopack-ecmascript/src/tree_shake/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,18 @@ pub fn should_skip_tree_shaking(m: &Program, special_exports: &[RcStr]) -> bool
match item {
// Skip turbopack helpers.
ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl {
with, specifiers, ..
src,
with,
specifiers,
..
})) => {
// We detect imports from next/dynamic in various places.
// See collect_next_dynamic_imports. We need to preserve the import of
// `next/dynamic`.
if src.value == "next/dynamic" {
return false;
}

if let Some(with) = with.as_deref().and_then(|v| v.as_import_with()) {
for item in with.values.iter() {
if item.key.sym == *TURBOPACK_HELPER {
Expand Down

0 comments on commit 6bb438b

Please sign in to comment.