Skip to content

Commit 964a560

Browse files
authored
fix(es/minifier): Fix top level detection of DCE (#10603)
1 parent 70bda6a commit 964a560

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

.changeset/soft-pots-roll.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
swc_core: patch
3+
swc_ecma_transforms_optimization: patch
4+
---
5+
6+
fix(es/minifier): Fix top level detection of DCE

crates/swc_ecma_transforms_optimization/src/simplify/dce/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,13 @@ impl VisitMut for TreeShaker {
794794
self.in_block_stmt = old_in_block_stmt;
795795
}
796796

797+
fn visit_mut_block_stmt_or_expr(&mut self, n: &mut BlockStmtOrExpr) {
798+
let old_in_fn = self.in_fn;
799+
self.in_fn = true;
800+
n.visit_mut_children_with(self);
801+
self.in_fn = old_in_fn;
802+
}
803+
797804
fn visit_mut_class_members(&mut self, members: &mut Vec<ClassMember>) {
798805
self.visit_mut_par(cpu_count() * 8, members);
799806
}

0 commit comments

Comments
 (0)