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
6 changes: 3 additions & 3 deletions crates/oxc_transformer/examples/transformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use oxc_codegen::CodeGenerator;
use oxc_parser::Parser;
use oxc_semantic::SemanticBuilder;
use oxc_span::SourceType;
use oxc_transformer::{EnvOptions, Targets, TransformOptions, Transformer};
use oxc_transformer::{BabelEnvOptions, Targets, TransformOptions, Transformer};
use pico_args::Arguments;

// Instruction:
Expand Down Expand Up @@ -55,9 +55,9 @@ fn main() {
let (symbols, scopes) = ret.semantic.into_symbol_table_and_scope_tree();

let transform_options = if let Some(targets) = &targets {
TransformOptions::try_from(&EnvOptions {
TransformOptions::try_from(&BabelEnvOptions {
targets: Targets::try_from_query(targets).unwrap(),
..EnvOptions::default()
..BabelEnvOptions::default()
})
.unwrap()
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_transformer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub use crate::{
compiler_assumptions::CompilerAssumptions,
es2015::{ArrowFunctionsOptions, ES2015Options},
jsx::{JsxOptions, JsxRuntime, ReactRefreshOptions},
options::{BabelOptions, EnvOptions, Targets, TransformOptions},
options::{BabelEnvOptions, BabelOptions, Targets, TransformOptions},
plugins::*,
typescript::{RewriteExtensionsMode, TypeScriptOptions},
};
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_transformer/src/options/babel/env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn default_as_true() -> bool {

#[derive(Default, Debug, Clone, Deserialize)]
#[serde(default, rename_all = "camelCase", deny_unknown_fields)]
pub struct EnvOptions {
pub struct BabelEnvOptions {
#[serde(default)]
pub targets: Targets,

Expand Down Expand Up @@ -56,7 +56,7 @@ pub struct EnvOptions {
pub shipped_proposals: bool,
}

impl EnvOptions {
impl BabelEnvOptions {
pub fn can_enable_plugin(&self, plugin_name: &str) -> bool {
let versions = if self.bugfixes {
bugfix_features().get(plugin_name).unwrap_or_else(|| &features()[plugin_name])
Expand Down
8 changes: 4 additions & 4 deletions crates/oxc_transformer/src/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::{
};

pub use babel::{
env::{EnvOptions, Targets},
env::{BabelEnvOptions, Targets},
BabelOptions,
};

Expand Down Expand Up @@ -121,11 +121,11 @@ impl TransformOptions {
}
}

impl TryFrom<&EnvOptions> for TransformOptions {
impl TryFrom<&BabelEnvOptions> for TransformOptions {
type Error = Vec<Error>;

/// If there are any errors in the `options.targets``, they will be returned as a list of errors.
fn try_from(o: &EnvOptions) -> Result<Self, Self::Error> {
fn try_from(o: &BabelEnvOptions) -> Result<Self, Self::Error> {
Ok(Self {
regexp: RegExpOptions {
sticky_flag: o.can_enable_plugin("transform-sticky-regex"),
Expand Down Expand Up @@ -255,7 +255,7 @@ impl TryFrom<&BabelOptions> for TransformOptions {
.get_preset("env")
.flatten()
.and_then(|value| {
serde_json::from_value::<EnvOptions>(value)
serde_json::from_value::<BabelEnvOptions>(value)
.inspect_err(|err| report_error("env", err, true, &mut errors))
.ok()
})
Expand Down
6 changes: 3 additions & 3 deletions crates/oxc_wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use oxc::{
ScopeFlags, ScopeId, ScopeTree, SemanticBuilder, SymbolTable,
},
span::SourceType,
transformer::{EnvOptions, Targets, TransformOptions, Transformer},
transformer::{BabelEnvOptions, Targets, TransformOptions, Transformer},
};
use oxc_index::Idx;
use oxc_linter::Linter;
Expand Down Expand Up @@ -242,9 +242,9 @@ impl Oxc {
}

if run_options.transform.unwrap_or_default() {
if let Ok(options) = TransformOptions::try_from(&EnvOptions {
if let Ok(options) = TransformOptions::try_from(&BabelEnvOptions {
targets: Targets::try_from_query("chrome 51").unwrap_or_default(),
..EnvOptions::default()
..BabelEnvOptions::default()
}) {
let result = Transformer::new(&allocator, &path, options)
.build_with_symbols_and_scopes(symbols, scopes, &mut program);
Expand Down