Skip to content

Commit

Permalink
fix(minifier): RemoveDeadCode should visit nested expression (#4268)
Browse files Browse the repository at this point in the history
  • Loading branch information
underfin committed Jul 15, 2024
1 parent 8fad7db commit f144082
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/oxc_minifier/src/ast_passes/remove_dead_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ impl<'a> VisitMut<'a> for RemoveDeadCode<'a> {
fn visit_expression(&mut self, expr: &mut Expression<'a>) {
self.fold_conditional_expression(expr);
self.fold_logical_expression(expr);
walk_mut::walk_expression(self, expr);
}
}

Expand Down
6 changes: 6 additions & 0 deletions crates/oxc_minifier/tests/oxc/remove_dead_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ fn dce_if_statement() {
",
"{foo; return }",
);

// nested expression
test(
"const a = { fn: function() { if (true) { foo; } } }",
"const a = { fn: function() { { foo; } } }",
);
}

#[test]
Expand Down

0 comments on commit f144082

Please sign in to comment.