Skip to content

Commit

Permalink
refactor(transformer): remove unimplemented EnvOptions::bugfixes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Nov 6, 2024
1 parent a981caf commit 0e1f12c
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 226 deletions.

This file was deleted.

12 changes: 0 additions & 12 deletions crates/oxc_transformer/src/options/babel/env/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,3 @@ pub fn features() -> &'static FxHashMap<String, EngineTargets> {
.collect()
})
}

/// Reference: <https://github.com/swc-project/swc/blob/ea14fc8e5996dcd736b8deb4cc99262d07dfff44/crates/swc_ecma_preset_env/src/transform_data.rs#L220-L237>
pub fn bugfix_features() -> &'static FxHashMap<String, EngineTargets> {
static BUGFIX_FEATURES: OnceLock<FxHashMap<String, EngineTargets>> = OnceLock::new();
BUGFIX_FEATURES.get_or_init(|| {
let map = serde_json::from_str::<FxHashMap<String, EngineTargets>>(include_str!(
"./@babel/compat_data/data/plugin_bugfixes.json"
))
.unwrap();
features().clone().into_iter().chain(map).collect()
})
}
13 changes: 3 additions & 10 deletions crates/oxc_transformer/src/options/babel/env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ mod targets;

use serde::Deserialize;

pub use self::{
data::{bugfix_features, features},
targets::BabelTargets,
};
pub use self::{data::features, targets::BabelTargets};

use crate::options::EngineTargets;

Expand All @@ -20,6 +17,7 @@ pub struct BabelEnvOptions {
#[serde(default)]
pub targets: EngineTargets,

#[deprecated = "Not Implemented"]
#[serde(default = "default_as_true")]
pub bugfixes: bool,

Expand Down Expand Up @@ -62,11 +60,6 @@ pub struct BabelEnvOptions {

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])
} else {
&features()[plugin_name]
};
self.targets.should_enable(versions)
self.targets.should_enable(&features()[plugin_name])
}
}
3 changes: 0 additions & 3 deletions crates/oxc_transformer/src/options/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ impl EnvOptions {
pub fn from_browserslist_query(query: &str) -> Result<Self, Error> {
Self::try_from(BabelEnvOptions {
targets: EngineTargets::try_from_query(query)?,
// This option will be enabled by default in Babel 8.
// <https://babel.dev/docs/babel-preset-env#bugfixes>
bugfixes: true,
..BabelEnvOptions::default()
})
.map_err(|err| Error::msg(err))
Expand Down

0 comments on commit 0e1f12c

Please sign in to comment.