Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(transformer): isolate babel options logic #7034

Merged
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
1 change: 0 additions & 1 deletion crates/oxc_transformer/src/env/data/mod.rs

This file was deleted.

7 changes: 0 additions & 7 deletions crates/oxc_transformer/src/env/mod.rs

This file was deleted.

5 changes: 2 additions & 3 deletions crates/oxc_transformer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ mod common;
mod compiler_assumptions;
mod context;
mod options;

// Presets: <https://babel.dev/docs/presets>
mod env;
mod es2015;
mod es2016;
mod es2017;
Expand Down Expand Up @@ -52,10 +52,9 @@ use typescript::TypeScript;
pub use crate::{
common::helper_loader::HelperLoaderMode,
compiler_assumptions::CompilerAssumptions,
env::{EnvOptions, Targets},
es2015::{ArrowFunctionsOptions, ES2015Options},
jsx::{JsxOptions, JsxRuntime, ReactRefreshOptions},
options::{BabelOptions, TransformOptions},
options::{BabelOptions, EnvOptions, Targets, TransformOptions},
plugins::*,
typescript::{RewriteExtensionsMode, TypeScriptOptions},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::OnceLock;

use rustc_hash::FxHashMap;

use crate::env::{Targets, Version};
use super::{Targets, Version};

/// Reference: <https://github.com/swc-project/swc/blob/ea14fc8e5996dcd736b8deb4cc99262d07dfff44/crates/swc_ecma_preset_env/src/transform_data.rs#L194-L218>
pub fn features() -> &'static FxHashMap<String, Targets> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use serde::Deserialize;
mod data;
mod targets;

pub use data::{bugfix_features, features};
pub use targets::{Targets, Version};

use crate::env::{bugfix_features, features, Targets};
use serde::Deserialize;

fn default_as_true() -> bool {
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl TryFrom<BabelTargets> for Targets {

#[cfg(test)]
mod tests {
use crate::env::{targets::Version, Targets};
use super::{Targets, Version};

#[test]
fn should_enable_android_falls_back_to_chrome() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub mod env;

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

use serde::Deserialize;
Expand Down
Loading
Loading