Skip to content

Commit

Permalink
feat(minifier): remove parenthesized expression for dce (#5439)
Browse files Browse the repository at this point in the history
relates #5436
  • Loading branch information
Boshen committed Sep 4, 2024
1 parent d9d7e7c commit ba4b68c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/oxc_minifier/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ impl CompressOptions {
}

pub fn dead_code_elimination() -> Self {
Self { fold_constants: true, remove_dead_code: true, ..Self::all_false() }
Self {
remove_syntax: true,
fold_constants: true,
remove_dead_code: true,
..Self::all_false()
}
}
}
3 changes: 3 additions & 0 deletions crates/oxc_minifier/tests/ast_passes/remove_dead_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ fn dce_if_statement() {
"const a = { fn: function() { if (true) { foo; } } }",
"const a = { fn: function() { { foo; } } }",
);

// parenthesized
test("if (!!(false)) { REMOVE; } else { KEEP; }", "{ KEEP }");
}

#[test]
Expand Down

0 comments on commit ba4b68c

Please sign in to comment.