Skip to content

Commit

Permalink
refactor(transformer): isolate babel options logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Oct 31, 2024
1 parent 12aa910 commit 2207299
Show file tree
Hide file tree
Showing 16 changed files with 408 additions and 411 deletions.
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

0 comments on commit 2207299

Please sign in to comment.