diff --git a/napi/minify/index.d.ts b/napi/minify/index.d.ts index 80b0809a8ed3b..0a845a1669fcb 100644 --- a/napi/minify/index.d.ts +++ b/napi/minify/index.d.ts @@ -45,6 +45,22 @@ export interface CompressOptions { unused?: true | false | 'keep_assign' /** Keep function / class names. */ keepNames?: CompressOptionsKeepNames + /** + * Join consecutive var, let and const statements. + * + * @default true + */ + joinVars?: boolean + /** + * Join consecutive simple statements using the comma operator. + * + * `a; b` -> `a, b` + * + * @default true + */ + sequences?: boolean + /** Limit the maximum number of iterations for debugging purpose. */ + passes?: number } export interface CompressOptionsKeepNames { diff --git a/napi/minify/src/options.rs b/napi/minify/src/options.rs index 1f86ebb3d1694..cab6286efd96f 100644 --- a/napi/minify/src/options.rs +++ b/napi/minify/src/options.rs @@ -38,6 +38,21 @@ pub struct CompressOptions { /// Keep function / class names. pub keep_names: Option, + + /// Join consecutive var, let and const statements. + /// + /// @default true + pub join_vars: Option, + + /// Join consecutive simple statements using the comma operator. + /// + /// `a; b` -> `a, b` + /// + /// @default true + pub sequences: Option, + + /// Limit the maximum number of iterations for debugging purpose. + pub passes: Option, } impl TryFrom<&CompressOptions> for oxc_minifier::CompressOptions { @@ -52,14 +67,13 @@ impl TryFrom<&CompressOptions> for oxc_minifier::CompressOptions { }, drop_console: o.drop_console.unwrap_or(default.drop_console), drop_debugger: o.drop_debugger.unwrap_or(default.drop_debugger), - // TODO - join_vars: true, - sequences: true, + join_vars: o.join_vars.unwrap_or(true), + sequences: o.sequences.unwrap_or(true), // TODO unused: oxc_minifier::CompressOptionsUnused::Keep, keep_names: o.keep_names.as_ref().map(Into::into).unwrap_or_default(), treeshake: TreeShakeOptions::default(), - max_iterations: None, + max_iterations: o.passes, }) } }