next.js
5eb90193 - Turbopack: skip trimmed side-effect imports in SideEffectsModule (#95781)

Commit
26 days ago
Turbopack: skip trimmed side-effect imports in SideEffectsModule (#95781) A star re-export barrel with imports but no top-level side effects is classified ModuleEvaluationIsSideEffectFree. follow_reexports_with_side_effects treats that as effectful and builds a SideEffectsModule that emits TURBOPACK_IMPORT(<eval part id>), but compute_side_effect_free_module_info classifies the same module as side-effect-free, so binding-usage prunes the Evaluation edge and the eval part never gets a module id. The build then panicked with 'ModuleId not found for ident: .../barrel.ts <internal part 0>' during middleware chunking. SideEffectsModule is designed so graph tree-shaking may trim these imports, so the consumer must tolerate a trimmed side effect. Add ModuleIdStrategy::try_get_id_from_module (returns None instead of erroring when an explicit id map lacks the module) and have chunk_item_content skip side effects with no id -- a pruned side-effect-free module has nothing to evaluate. Adds an e2e regression test (treeshake-mw).
Author
Parents
Loading