-
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(transformer): clean up TransformerOptions (#7005)
This is a work towards #6982 Next PR will try and make sense of env options vs babel options vs targets and bugfixes, I'm super confused right now.
- Loading branch information
Showing
12 changed files
with
284 additions
and
390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,8 @@ | ||
use serde::Deserialize; | ||
|
||
use crate::env::{can_enable_plugin, Versions}; | ||
|
||
#[derive(Debug, Default, Clone, Deserialize)] | ||
#[serde(default, rename_all = "camelCase", deny_unknown_fields)] | ||
pub struct ES2016Options { | ||
#[serde(skip)] | ||
pub exponentiation_operator: bool, | ||
} | ||
|
||
impl ES2016Options { | ||
pub fn with_exponentiation_operator(&mut self, enable: bool) -> &mut Self { | ||
self.exponentiation_operator = enable; | ||
self | ||
} | ||
|
||
#[must_use] | ||
pub fn from_targets_and_bugfixes(targets: Option<&Versions>, bugfixes: bool) -> Self { | ||
Self { | ||
exponentiation_operator: can_enable_plugin( | ||
"transform-exponentiation-operator", | ||
targets, | ||
bugfixes, | ||
), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,8 @@ | ||
use serde::Deserialize; | ||
|
||
use crate::env::{can_enable_plugin, Versions}; | ||
|
||
#[derive(Debug, Default, Clone, Deserialize)] | ||
#[serde(default, rename_all = "camelCase", deny_unknown_fields)] | ||
pub struct ES2017Options { | ||
#[serde(skip)] | ||
pub async_to_generator: bool, | ||
} | ||
|
||
impl ES2017Options { | ||
pub fn with_async_to_generator(&mut self, enable: bool) -> &mut Self { | ||
self.async_to_generator = enable; | ||
self | ||
} | ||
|
||
#[must_use] | ||
pub fn from_targets_and_bugfixes(targets: Option<&Versions>, bugfixes: bool) -> Self { | ||
Self { | ||
async_to_generator: can_enable_plugin( | ||
"transform-async-to-generator", | ||
targets, | ||
bugfixes, | ||
), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,8 @@ | ||
use serde::Deserialize; | ||
|
||
use crate::env::{can_enable_plugin, Versions}; | ||
|
||
#[derive(Debug, Default, Clone, Deserialize)] | ||
#[serde(default, rename_all = "camelCase", deny_unknown_fields)] | ||
pub struct ES2019Options { | ||
#[serde(skip)] | ||
pub optional_catch_binding: bool, | ||
} | ||
|
||
impl ES2019Options { | ||
pub fn with_optional_catch_binding(&mut self, enable: bool) -> &mut Self { | ||
self.optional_catch_binding = enable; | ||
self | ||
} | ||
|
||
#[must_use] | ||
pub fn from_targets_and_bugfixes(targets: Option<&Versions>, bugfixes: bool) -> Self { | ||
Self { | ||
optional_catch_binding: can_enable_plugin( | ||
"transform-optional-catch-binding", | ||
targets, | ||
bugfixes, | ||
), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,8 @@ | ||
use serde::Deserialize; | ||
|
||
use crate::env::{can_enable_plugin, Versions}; | ||
|
||
#[derive(Debug, Default, Clone, Deserialize)] | ||
#[serde(default, rename_all = "camelCase", deny_unknown_fields)] | ||
pub struct ES2020Options { | ||
#[serde(skip)] | ||
pub nullish_coalescing_operator: bool, | ||
} | ||
|
||
impl ES2020Options { | ||
pub fn with_nullish_coalescing_operator(&mut self, enable: bool) -> &mut Self { | ||
self.nullish_coalescing_operator = enable; | ||
self | ||
} | ||
|
||
#[must_use] | ||
pub fn from_targets_and_bugfixes(targets: Option<&Versions>, bugfixes: bool) -> Self { | ||
Self { | ||
nullish_coalescing_operator: can_enable_plugin( | ||
"transform-nullish-coalescing-operator", | ||
targets, | ||
bugfixes, | ||
), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,8 @@ | ||
use serde::Deserialize; | ||
|
||
use crate::env::{can_enable_plugin, Versions}; | ||
|
||
#[derive(Debug, Default, Clone, Deserialize)] | ||
#[serde(default, rename_all = "camelCase", deny_unknown_fields)] | ||
pub struct ES2021Options { | ||
#[serde(skip)] | ||
pub logical_assignment_operators: bool, | ||
} | ||
|
||
impl ES2021Options { | ||
pub fn with_logical_assignment_operators(&mut self, enable: bool) -> &mut Self { | ||
self.logical_assignment_operators = enable; | ||
self | ||
} | ||
|
||
#[must_use] | ||
pub fn from_targets_and_bugfixes(targets: Option<&Versions>, bugfixes: bool) -> Self { | ||
Self { | ||
logical_assignment_operators: can_enable_plugin( | ||
"transform-logical-assignment-operators", | ||
targets, | ||
bugfixes, | ||
), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,8 @@ | ||
use serde::Deserialize; | ||
|
||
use crate::env::{can_enable_plugin, Versions}; | ||
|
||
#[derive(Debug, Default, Clone, Deserialize)] | ||
#[serde(default, rename_all = "camelCase", deny_unknown_fields)] | ||
pub struct ES2022Options { | ||
#[serde(skip)] | ||
pub class_static_block: bool, | ||
} | ||
|
||
impl ES2022Options { | ||
pub fn with_class_static_block(&mut self, enable: bool) -> &mut Self { | ||
self.class_static_block = enable; | ||
self | ||
} | ||
|
||
#[must_use] | ||
pub fn from_targets_and_bugfixes(targets: Option<&Versions>, bugfixes: bool) -> Self { | ||
Self { | ||
class_static_block: can_enable_plugin( | ||
"transform-class-static-block", | ||
targets, | ||
bugfixes, | ||
), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.