Skip to content

Commit

Permalink
feat(wasm): turn on all transform options
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Aug 31, 2024
1 parent b867e5f commit add1465
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions crates/oxc_wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use oxc::{
parser::{ParseOptions, Parser, ParserReturn},
semantic::{ScopeFlags, ScopeId, ScopeTree, SemanticBuilder, SymbolTable},
span::SourceType,
transformer::{TransformOptions, Transformer},
transformer::{EnvOptions, Targets, TransformOptions, Transformer},
};
use oxc_index::Idx;
use oxc_linter::Linter;
Expand Down Expand Up @@ -217,20 +217,24 @@ impl Oxc {
}

if run_options.transform.unwrap_or_default() {
let options = TransformOptions::default();
let result = Transformer::new(
&allocator,
&path,
source_type,
source_text,
trivias.clone(),
options,
)
.build_with_symbols_and_scopes(symbols, scopes, &mut program);
if !result.errors.is_empty() {
self.save_diagnostics(
result.errors.into_iter().map(Error::from).collect::<Vec<_>>(),
);
if let Ok(options) = TransformOptions::from_preset_env(&EnvOptions {
targets: Targets::from_query("chrome 51"),
..EnvOptions::default()
}) {
let result = Transformer::new(
&allocator,
&path,
source_type,
source_text,
trivias.clone(),
options,
)
.build_with_symbols_and_scopes(symbols, scopes, &mut program);
if !result.errors.is_empty() {
self.save_diagnostics(
result.errors.into_iter().map(Error::from).collect::<Vec<_>>(),
);
}
}
}

Expand Down

0 comments on commit add1465

Please sign in to comment.