Skip to content

Commit 3ba2ae0

Browse files
feat: expose more options in oxc_minify_napi
1 parent 5db9774 commit 3ba2ae0

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

napi/minify/src/options.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ pub struct CompressOptions {
3838

3939
/// Keep function / class names.
4040
pub keep_names: Option<CompressOptionsKeepNames>,
41+
42+
/// Join consecutive var, let and const statements.
43+
///
44+
/// @default true
45+
pub join_vars: Option<bool>,
46+
47+
/// Join consecutive simple statements using the comma operator.
48+
///
49+
/// `a; b` -> `a, b`
50+
///
51+
/// @default true
52+
pub sequences: Option<bool>,
53+
54+
/// Limit the maximum number of iterations for debugging purpose.
55+
pub passes: Option<u8>,
4156
}
4257

4358
impl TryFrom<&CompressOptions> for oxc_minifier::CompressOptions {
@@ -52,14 +67,13 @@ impl TryFrom<&CompressOptions> for oxc_minifier::CompressOptions {
5267
},
5368
drop_console: o.drop_console.unwrap_or(default.drop_console),
5469
drop_debugger: o.drop_debugger.unwrap_or(default.drop_debugger),
55-
// TODO
56-
join_vars: true,
57-
sequences: true,
70+
join_vars: o.join_vars.unwrap_or(default.join_vars),
71+
sequences: o.sequences.unwrap_or(default.sequences),
5872
// TODO
5973
unused: oxc_minifier::CompressOptionsUnused::Keep,
6074
keep_names: o.keep_names.as_ref().map(Into::into).unwrap_or_default(),
6175
treeshake: TreeShakeOptions::default(),
62-
max_iterations: None,
76+
max_iterations: o.passes.or(default.max_iterations),
6377
})
6478
}
6579
}

0 commit comments

Comments
 (0)