Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions napi/minify/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
22 changes: 18 additions & 4 deletions napi/minify/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ pub struct CompressOptions {

/// Keep function / class names.
pub keep_names: Option<CompressOptionsKeepNames>,

/// Join consecutive var, let and const statements.
///
/// @default true
pub join_vars: Option<bool>,

/// Join consecutive simple statements using the comma operator.
///
/// `a; b` -> `a, b`
///
/// @default true
pub sequences: Option<bool>,

/// Limit the maximum number of iterations for debugging purpose.
pub passes: Option<u8>,
}

impl TryFrom<&CompressOptions> for oxc_minifier::CompressOptions {
Expand All @@ -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,
})
}
}
Expand Down
Loading