diff --git a/turbopack/crates/turbopack-ecmascript/src/tree_shake/graph.rs b/turbopack/crates/turbopack-ecmascript/src/tree_shake/graph.rs index b68a48ddea217f..e3f384ebd8c02d 100644 --- a/turbopack/crates/turbopack-ecmascript/src/tree_shake/graph.rs +++ b/turbopack/crates/turbopack-ecmascript/src/tree_shake/graph.rs @@ -584,6 +584,22 @@ impl DepGraph { } } + // Do not store export * in internal part fragments. + if let ModuleItem::ModuleDecl(ModuleDecl::ExportAll(export)) = &data[g].content { + // Preserve side effects of import caused by export * + chunk + .body + .push(ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl { + span: export.span, + specifiers: Default::default(), + src: export.src.clone(), + type_only: false, + with: export.with.clone(), + phase: Default::default(), + }))); + continue; + } + chunk.body.push(data[g].content.clone()); }