Skip to content
Closed
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
7 changes: 5 additions & 2 deletions napi/minify/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use napi_derive::napi;
use oxc_allocator::Allocator;
use oxc_codegen::{Codegen, CodegenOptions};
use oxc_minifier::Minifier;
use oxc_parser::Parser;
use oxc_parser::{ParseOptions, Parser};
use oxc_span::SourceType;

use crate::options::{MinifyOptions, MinifyResult};
Expand All @@ -40,7 +40,10 @@ pub fn minify(

let source_type = SourceType::from_path(&filename).unwrap_or_default();

let mut program = Parser::new(&allocator, &source_text, source_type).parse().program;
let mut program = Parser::new(&allocator, &source_text, source_type)
.with_options(ParseOptions { preserve_parens: false, ..ParseOptions::default() })
.parse()
.program;

let scoping = Minifier::new(minifier_options).build(&allocator, &mut program).scoping;

Expand Down
10 changes: 8 additions & 2 deletions tasks/benchmark/benches/minifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use oxc_allocator::Allocator;
use oxc_benchmark::{BenchmarkId, Criterion, criterion_group, criterion_main};
use oxc_mangler::Mangler;
use oxc_minifier::{CompressOptions, Compressor};
use oxc_parser::Parser;
use oxc_parser::{ParseOptions, Parser};
use oxc_semantic::SemanticBuilder;
use oxc_span::SourceType;
use oxc_tasks_common::TestFiles;
Expand All @@ -28,7 +28,13 @@ fn bench_minifier(criterion: &mut Criterion) {
allocator.reset();

// Create fresh AST + semantic data for each iteration
let mut program = Parser::new(&allocator, source_text, source_type).parse().program;
let mut program = Parser::new(&allocator, source_text, source_type)
.with_options(ParseOptions {
preserve_parens: false,
..ParseOptions::default()
})
.parse()
.program;
let scoping = SemanticBuilder::new().build(&program).semantic.into_scoping();

// Minifier only works on esnext.
Expand Down
Loading