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
4 changes: 0 additions & 4 deletions crates/oxc/src/napi/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ pub struct TransformOptions {
/// Configure how TSX and JSX are transformed.
pub jsx: Option<JsxOptions>,

/// Enable ES2015 transformations.
pub es2015: Option<Es2015Options>,

/// Define Plugin
#[napi(ts_type = "Record<string, string>")]
pub define: Option<FxHashMap<String, String>>,
Expand All @@ -101,7 +98,6 @@ impl From<TransformOptions> for oxc_transformer::TransformOptions {
.map(oxc_transformer::TypeScriptOptions::from)
.unwrap_or_default(),
jsx: options.jsx.map(Into::into).unwrap_or_default(),
es2015: options.es2015.map(Into::into).unwrap_or_default(),
..Self::default()
}
}
Expand Down
16 changes: 9 additions & 7 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::{BabelEnvOptions, Targets, TransformOptions, Transformer};
use oxc_transformer::{TransformOptions, Transformer};
use pico_args::Arguments;

// Instruction:
Expand Down Expand Up @@ -54,12 +54,14 @@ fn main() {

let (symbols, scopes) = ret.semantic.into_symbol_table_and_scope_tree();

let transform_options = if let Some(targets) = &targets {
TransformOptions::try_from(&BabelEnvOptions {
targets: Targets::try_from_query(targets).unwrap(),
..BabelEnvOptions::default()
})
.unwrap()
let transform_options = if let Some(_targets) = &targets {
// FIXME
TransformOptions::enable_all()
// TransformOptions::try_from(&BabelEnvOptions {
// targets: Targets::try_from_query(targets).unwrap(),
// ..BabelEnvOptions::default()
// })
// .unwrap()
} else {
TransformOptions::enable_all()
};
Expand Down
5 changes: 3 additions & 2 deletions crates/oxc_transformer/src/es2017/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
mod async_to_generator;
pub mod options;
mod options;

use options::ES2017Options;
use oxc_ast::ast::{Expression, Statement};
use oxc_traverse::{Traverse, TraverseCtx};

use crate::{es2017::async_to_generator::AsyncToGenerator, TransformCtx};
pub use async_to_generator::AsyncGeneratorExecutor;

pub use options::ES2017Options;

#[allow(dead_code)]
pub struct ES2017<'a, 'ctx> {
options: ES2017Options,
Expand Down
1 change: 1 addition & 0 deletions crates/oxc_transformer/src/es2018/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use super::ObjectRestSpreadOptions;
pub struct ES2018Options {
#[serde(skip)]
pub object_rest_spread: Option<ObjectRestSpreadOptions>,

#[serde(skip)]
pub async_generator_functions: bool,
}
2 changes: 2 additions & 0 deletions crates/oxc_transformer/src/es2022/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ use super::ClassPropertiesOptions;
pub struct ES2022Options {
#[serde(skip)]
pub class_static_block: bool,

#[serde(skip)]
pub class_properties: Option<ClassPropertiesOptions>,
}
23 changes: 13 additions & 10 deletions crates/oxc_transformer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ pub use crate::{
compiler_assumptions::CompilerAssumptions,
es2015::{ArrowFunctionsOptions, ES2015Options},
jsx::{JsxOptions, JsxRuntime, ReactRefreshOptions},
options::{BabelEnvOptions, BabelOptions, Targets, TransformOptions},
options::{
babel::{BabelEnvOptions, BabelOptions, Targets},
TransformOptions,
},
plugins::*,
typescript::{RewriteExtensionsMode, TypeScriptOptions},
};
Expand Down Expand Up @@ -96,15 +99,15 @@ impl<'a> Transformer<'a> {
.is_typescript()
.then(|| TypeScript::new(&self.options.typescript, &self.ctx)),
x1_jsx: Jsx::new(self.options.jsx, ast_builder, &self.ctx),
x2_es2022: ES2022::new(self.options.es2022, &self.ctx),
x2_es2021: ES2021::new(self.options.es2021, &self.ctx),
x2_es2020: ES2020::new(self.options.es2020, &self.ctx),
x2_es2019: ES2019::new(self.options.es2019),
x2_es2018: ES2018::new(self.options.es2018, &self.ctx),
x2_es2016: ES2016::new(self.options.es2016, &self.ctx),
x2_es2017: ES2017::new(self.options.es2017, &self.ctx),
x3_es2015: ES2015::new(self.options.es2015),
x4_regexp: RegExp::new(self.options.regexp, &self.ctx),
x2_es2022: ES2022::new(self.options.env.es2022, &self.ctx),
x2_es2021: ES2021::new(self.options.env.es2021, &self.ctx),
x2_es2020: ES2020::new(self.options.env.es2020, &self.ctx),
x2_es2019: ES2019::new(self.options.env.es2019),
x2_es2018: ES2018::new(self.options.env.es2018, &self.ctx),
x2_es2016: ES2016::new(self.options.env.es2016, &self.ctx),
x2_es2017: ES2017::new(self.options.env.es2017, &self.ctx),
x3_es2015: ES2015::new(self.options.env.es2015),
x4_regexp: RegExp::new(self.options.env.regexp, &self.ctx),
common: Common::new(&self.ctx),
};

Expand Down
4 changes: 3 additions & 1 deletion crates/oxc_transformer/src/options/babel/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
pub mod env;
mod env;

use std::path::{Path, PathBuf};

use serde::Deserialize;
use serde_json::Value;

pub use env::{BabelEnvOptions, Targets};

/// Babel options
///
/// <https://babel.dev/docs/options#plugin-and-preset-options>
Expand Down
Loading