Skip to content

Commit eef7eb6

Browse files
committed
refactor(minifier)!: rename CompressOptions::all_true/all_false to smallest/safest (#9866)
With the `keep_names` option, `all_true` will not behave as you would expect. I think what is expected is `smallest` / `safest` than `all_true` / `all_false`. Without this change, `all_true` will drop `console` calls but keep the function names as-is.
1 parent c8979d9 commit eef7eb6

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

crates/oxc_minifier/src/options.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ pub struct CompressOptions {
2626
#[expect(clippy::derivable_impls)]
2727
impl Default for CompressOptions {
2828
fn default() -> Self {
29-
Self { drop_console: false, ..Self::all_true() }
29+
Self { drop_console: false, ..Self::smallest() }
3030
}
3131
}
3232

3333
impl CompressOptions {
34-
pub fn all_true() -> Self {
34+
pub fn smallest() -> Self {
3535
Self { target: ESTarget::ESNext, drop_debugger: true, drop_console: true }
3636
}
3737

38-
pub fn all_false() -> Self {
38+
pub fn safest() -> Self {
3939
Self { target: ESTarget::ESNext, drop_debugger: false, drop_console: false }
4040
}
4141
}

crates/oxc_minifier/src/tester.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub fn test_same(source_text: &str) {
1010
}
1111

1212
pub fn test(source_text: &str, expected: &str) {
13-
let result = run(source_text, Some(CompressOptions::all_true()));
13+
let result = run(source_text, Some(CompressOptions::smallest()));
1414
let expected = run(expected, None);
1515
assert_eq!(result, expected, "\nfor source\n{source_text}\nexpect\n{expected}\ngot\n{result}");
1616
}

crates/oxc_minifier/tests/peephole/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mod esbuild;
44
use oxc_minifier::CompressOptions;
55

66
fn test(source_text: &str, expected: &str) {
7-
let options = CompressOptions::all_false();
7+
let options = CompressOptions::safest();
88
crate::test(source_text, expected, options);
99
}
1010

napi/playground/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,10 @@ impl Oxc {
266266
CompressOptions {
267267
drop_console: compress_options.drop_console,
268268
drop_debugger: compress_options.drop_debugger,
269-
..CompressOptions::all_false()
269+
..CompressOptions::safest()
270270
}
271271
} else {
272-
CompressOptions::all_false()
272+
CompressOptions::safest()
273273
}),
274274
};
275275
Minifier::new(options).build(&allocator, &mut program).scoping

tasks/benchmark/benches/minifier.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn bench_minifier(criterion: &mut Criterion) {
2828
let mut program = Parser::new(&allocator, source_text, source_type).parse().program;
2929
let scoping = SemanticBuilder::new().build(&program).semantic.into_scoping();
3030

31-
let options = CompressOptions::all_true();
31+
let options = CompressOptions::smallest();
3232

3333
runner.run(|| {
3434
Compressor::new(&allocator, options).build_with_scoping(scoping, &mut program);

tasks/coverage/src/driver.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl CompilerInterface for Driver {
5454
}
5555

5656
fn compress_options(&self) -> Option<CompressOptions> {
57-
self.compress.then(CompressOptions::all_true)
57+
self.compress.then(CompressOptions::smallest)
5858
}
5959

6060
fn codegen_options(&self) -> Option<CodegenOptions> {

0 commit comments

Comments
 (0)