Skip to content

Commit 7eead3b

Browse files
committed
fix(napi/playground): only mangle only if mangle option is enabled (#13956)
fixes oxc-project/playground#160
1 parent 28cacac commit 7eead3b

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

napi/playground/src/lib.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,17 +320,24 @@ impl Oxc {
320320
program: &mut Program<'a>,
321321
options: &OxcOptions,
322322
) -> Option<Scoping> {
323-
if options.run.compress || options.run.mangle {
324-
let compress = options.compress.map(|_| CompressOptions::smallest());
325-
let mangle = options.mangle.map(|o| MangleOptions {
323+
if !options.run.compress && !options.run.mangle {
324+
return None;
325+
}
326+
let compress = if options.run.compress {
327+
options.compress.map(|_| CompressOptions::smallest())
328+
} else {
329+
None
330+
};
331+
let mangle = if options.run.mangle {
332+
options.mangle.map(|o| MangleOptions {
326333
top_level: o.top_level,
327334
keep_names: MangleOptionsKeepNames { function: o.keep_names, class: o.keep_names },
328335
debug: false,
329-
});
330-
Minifier::new(MinifierOptions { mangle, compress }).minify(allocator, program).scoping
336+
})
331337
} else {
332338
None
333-
}
339+
};
340+
Minifier::new(MinifierOptions { mangle, compress }).minify(allocator, program).scoping
334341
}
335342

336343
fn finalize_output<'a>(

0 commit comments

Comments
 (0)