refactor(es/compat): Split swc_ecma_transforms_compat (#8110)

**Description:**

- New: `cargo build --release 478.59s user 19.16s system 814% cpu 1:01.09 total`
- Prev: `cargo build --release 495.60s user 18.89s system 742% cpu 1:09.26 total`
This commit is contained in:
Donny/강동윤 2023-10-12 19:08:00 +09:00 committed by GitHub
parent ee21b4e8e5
commit affb6fb5e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
77 changed files with 593 additions and 32 deletions

View File

@ -319,6 +319,39 @@ jobs:
- crate: swc_ecma_codegen_macros
os: ubuntu-latest
runner: ubuntu-latest
- crate: swc_ecma_compat_bugfixes
os: ubuntu-latest
runner: ubuntu-latest
- crate: swc_ecma_compat_common
os: ubuntu-latest
runner: ubuntu-latest
- crate: swc_ecma_compat_es2015
os: ubuntu-latest
runner: ubuntu-latest
- crate: swc_ecma_compat_es2016
os: ubuntu-latest
runner: ubuntu-latest
- crate: swc_ecma_compat_es2017
os: ubuntu-latest
runner: ubuntu-latest
- crate: swc_ecma_compat_es2018
os: ubuntu-latest
runner: ubuntu-latest
- crate: swc_ecma_compat_es2019
os: ubuntu-latest
runner: ubuntu-latest
- crate: swc_ecma_compat_es2020
os: ubuntu-latest
runner: ubuntu-latest
- crate: swc_ecma_compat_es2021
os: ubuntu-latest
runner: ubuntu-latest
- crate: swc_ecma_compat_es2022
os: ubuntu-latest
runner: ubuntu-latest
- crate: swc_ecma_compat_es3
os: ubuntu-latest
runner: ubuntu-latest
- crate: swc_ecma_dep_graph
os: ubuntu-latest
runner: ubuntu-latest
@ -538,6 +571,9 @@ jobs:
- crate: testing_macros
os: ubuntu-latest
runner: ubuntu-latest
- crate: xtask
os: ubuntu-latest
runner: ubuntu-latest
steps:
- name: Handle line endings
shell: bash

202
Cargo.lock generated
View File

@ -168,9 +168,9 @@ checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544"
[[package]]
name = "arrayvec"
version = "0.7.3"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8868f09ff8cea88b079da74ae569d9b8c62a23c68c746240b704ee6f7525c89c"
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
[[package]]
name = "ast_node"
@ -4183,6 +4183,193 @@ dependencies = [
"syn 2.0.37",
]
[[package]]
name = "swc_ecma_compat_bugfixes"
version = "0.1.0"
dependencies = [
"swc_atoms",
"swc_common",
"swc_ecma_ast",
"swc_ecma_compat_es2015",
"swc_ecma_parser",
"swc_ecma_transforms_base",
"swc_ecma_transforms_testing",
"swc_ecma_utils",
"swc_ecma_visit",
"swc_trace_macro",
"tracing",
]
[[package]]
name = "swc_ecma_compat_common"
version = "0.1.0"
dependencies = [
"swc_common",
"swc_ecma_ast",
"swc_ecma_utils",
"swc_ecma_visit",
"swc_trace_macro",
]
[[package]]
name = "swc_ecma_compat_es2015"
version = "0.1.0"
dependencies = [
"arrayvec",
"indexmap 1.9.3",
"is-macro",
"serde",
"serde_derive",
"smallvec",
"swc_atoms",
"swc_common",
"swc_config",
"swc_ecma_ast",
"swc_ecma_compat_common",
"swc_ecma_parser",
"swc_ecma_transforms_base",
"swc_ecma_transforms_classes",
"swc_ecma_transforms_macros",
"swc_ecma_transforms_testing",
"swc_ecma_utils",
"swc_ecma_visit",
"swc_trace_macro",
"tracing",
]
[[package]]
name = "swc_ecma_compat_es2016"
version = "0.1.0"
dependencies = [
"swc_atoms",
"swc_common",
"swc_ecma_ast",
"swc_ecma_parser",
"swc_ecma_transforms_base",
"swc_ecma_transforms_macros",
"swc_ecma_transforms_testing",
"swc_ecma_utils",
"swc_ecma_visit",
"swc_trace_macro",
"tracing",
]
[[package]]
name = "swc_ecma_compat_es2017"
version = "0.1.0"
dependencies = [
"serde",
"swc_atoms",
"swc_common",
"swc_ecma_ast",
"swc_ecma_parser",
"swc_ecma_transforms_base",
"swc_ecma_transforms_macros",
"swc_ecma_transforms_testing",
"swc_ecma_utils",
"swc_ecma_visit",
"swc_trace_macro",
"tracing",
]
[[package]]
name = "swc_ecma_compat_es2018"
version = "0.1.0"
dependencies = [
"serde",
"swc_atoms",
"swc_common",
"swc_ecma_ast",
"swc_ecma_compat_common",
"swc_ecma_parser",
"swc_ecma_transforms_base",
"swc_ecma_transforms_macros",
"swc_ecma_transforms_testing",
"swc_ecma_utils",
"swc_ecma_visit",
"swc_trace_macro",
"tracing",
]
[[package]]
name = "swc_ecma_compat_es2019"
version = "0.1.0"
dependencies = [
"swc_atoms",
"swc_common",
"swc_ecma_ast",
"swc_ecma_parser",
"swc_ecma_transforms_base",
"swc_ecma_transforms_testing",
"swc_ecma_utils",
"swc_ecma_visit",
"swc_trace_macro",
"tracing",
]
[[package]]
name = "swc_ecma_compat_es2020"
version = "0.1.0"
dependencies = [
"serde",
"swc_atoms",
"swc_common",
"swc_ecma_ast",
"swc_ecma_parser",
"swc_ecma_transforms_base",
"swc_ecma_transforms_testing",
"swc_ecma_utils",
"swc_ecma_visit",
"swc_trace_macro",
"tracing",
]
[[package]]
name = "swc_ecma_compat_es2021"
version = "0.1.0"
dependencies = [
"swc_atoms",
"swc_common",
"swc_ecma_ast",
"swc_ecma_transforms_base",
"swc_ecma_utils",
"swc_ecma_visit",
"swc_trace_macro",
"tracing",
]
[[package]]
name = "swc_ecma_compat_es2022"
version = "0.1.0"
dependencies = [
"swc_atoms",
"swc_common",
"swc_ecma_ast",
"swc_ecma_compat_common",
"swc_ecma_transforms_base",
"swc_ecma_transforms_classes",
"swc_ecma_transforms_macros",
"swc_ecma_utils",
"swc_ecma_visit",
"swc_trace_macro",
"tracing",
]
[[package]]
name = "swc_ecma_compat_es3"
version = "0.1.0"
dependencies = [
"swc_common",
"swc_ecma_ast",
"swc_ecma_parser",
"swc_ecma_transforms_base",
"swc_ecma_transforms_testing",
"swc_ecma_utils",
"swc_ecma_visit",
"swc_trace_macro",
"tracing",
]
[[package]]
name = "swc_ecma_dep_graph"
version = "0.113.1"
@ -4463,6 +4650,17 @@ dependencies = [
"swc_common",
"swc_config",
"swc_ecma_ast",
"swc_ecma_compat_bugfixes",
"swc_ecma_compat_common",
"swc_ecma_compat_es2015",
"swc_ecma_compat_es2016",
"swc_ecma_compat_es2017",
"swc_ecma_compat_es2018",
"swc_ecma_compat_es2019",
"swc_ecma_compat_es2020",
"swc_ecma_compat_es2021",
"swc_ecma_compat_es2022",
"swc_ecma_compat_es3",
"swc_ecma_parser",
"swc_ecma_transforms_base",
"swc_ecma_transforms_classes",

View File

@ -0,0 +1,26 @@
[package]
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
description = "Compatibility fixes for browser bugs"
documentation = "https://rustdoc.swc.rs/swc_ecma_compat_bugfixes/"
edition = "2021"
include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0"
name = "swc_ecma_compat_bugfixes"
repository = "https://github.com/swc-project/swc.git"
version = "0.1.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
swc_atoms = { version = "0.6.0", path = "../swc_atoms" }
swc_common = { version = "0.33.0", path = "../swc_common" }
swc_ecma_ast = { version = "0.110.0", path = "../swc_ecma_ast" }
swc_ecma_compat_es2015 = { version = "0.1.0", path = "../swc_ecma_compat_es2015" }
swc_ecma_transforms_base = { version = "0.134.2", path = "../swc_ecma_transforms_base" }
swc_ecma_utils = { version = "0.124.2", path = "../swc_ecma_utils" }
swc_ecma_visit = { version = "0.96.0", path = "../swc_ecma_visit" }
swc_trace_macro = { version = "0.1.3", path = "../swc_trace_macro" }
tracing = "0.1.37"
[dev-dependencies]
swc_ecma_parser = { version = "0.141.1", path = "../swc_ecma_parser" }
swc_ecma_transforms_testing = { version = "0.137.2", path = "../swc_ecma_transforms_testing" }

View File

@ -1,11 +1,10 @@
use swc_common::{util::take::Take, Mark, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_compat_es2015::arrow;
use swc_ecma_utils::prepend_stmt;
use swc_ecma_visit::{noop_fold_type, Fold, FoldWith, InjectVars};
use swc_trace_macro::swc_trace;
use crate::es2015::arrow;
/// Safari 10.3 had an issue where async arrow function expressions within any
/// class method would throw. After an initial fix, any references to the
/// instance via `this` within those methods would also throw. This is fixed by

View File

@ -0,0 +1,19 @@
[package]
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
description = "Commons for compat transforms"
documentation = "https://rustdoc.swc.rs/swc_ecma_compat_common/"
edition = "2021"
include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0"
name = "swc_ecma_compat_common"
repository = "https://github.com/swc-project/swc.git"
version = "0.1.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
swc_common = { version = "0.33.0", path = "../swc_common" }
swc_ecma_ast = { version = "0.110.0", path = "../swc_ecma_ast" }
swc_ecma_utils = { version = "0.124.2", path = "../swc_ecma_utils" }
swc_ecma_visit = { version = "0.96.0", path = "../swc_ecma_visit" }
swc_trace_macro = { version = "0.1.3", path = "../swc_trace_macro" }

View File

@ -0,0 +1,2 @@
pub mod macros;
pub mod regexp;

View File

@ -1,3 +1,5 @@
/// Not a public API
#[macro_export]
macro_rules! impl_visit_mut_fn {
() => {
fn visit_mut_function(&mut self, f: &mut Function) {

View File

@ -0,0 +1,39 @@
[package]
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
description = "ES2015 compatibility transforms"
documentation = "https://rustdoc.swc.rs/swc_ecma_compat_es2015/"
edition = "2021"
include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0"
name = "swc_ecma_compat_es2015"
repository = "https://github.com/swc-project/swc.git"
version = "0.1.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
arrayvec = "0.7.4"
indexmap = "1.9.3"
is-macro = "0.3.0"
serde = "1.0.188"
serde_derive = "1.0.188"
smallvec = "1.8.0"
swc_atoms = { version = "0.6.0", path = "../swc_atoms" }
swc_common = { version = "0.33.0", path = "../swc_common" }
swc_config = { version = "0.1.7", path = "../swc_config" }
swc_ecma_ast = { version = "0.110.0", path = "../swc_ecma_ast" }
swc_ecma_compat_common = { version = "0.1.0", path = "../swc_ecma_compat_common" }
swc_ecma_transforms_base = { version = "0.134.2", path = "../swc_ecma_transforms_base" }
swc_ecma_transforms_classes = { version = "0.123.2", path = "../swc_ecma_transforms_classes" }
swc_ecma_transforms_macros = { version = "0.5.3", path = "../swc_ecma_transforms_macros" }
swc_ecma_utils = { version = "0.124.2", path = "../swc_ecma_utils" }
swc_ecma_visit = { version = "0.96.0", path = "../swc_ecma_visit" }
swc_trace_macro = { version = "0.1.3", path = "../swc_trace_macro" }
tracing = "0.1.37"
[dev-dependencies]
swc_ecma_parser = { version = "0.141.1", path = "../swc_ecma_parser" }
swc_ecma_transforms_testing = { version = "0.137.2", path = "../swc_ecma_transforms_testing" }

View File

@ -3,6 +3,7 @@ use std::iter;
use serde::Deserialize;
use swc_common::{util::take::Take, Spanned, SyntaxContext, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_compat_common::impl_visit_mut_fn;
use swc_ecma_transforms_base::{helper, helper_expr, perf::Check};
use swc_ecma_transforms_macros::fast_path;
use swc_ecma_utils::{

View File

@ -1,5 +1,9 @@
#![allow(clippy::vec_box)]
#![allow(clippy::boxed_local)]
use serde::Deserialize;
use swc_common::{chain, comments::Comments, pass::Optional, Mark};
use swc_ecma_compat_common::regexp::{self, regexp};
use swc_ecma_visit::Fold;
pub use self::{
@ -10,7 +14,6 @@ pub use self::{
parameters::parameters, shorthand_property::shorthand, spread::spread,
sticky_regex::sticky_regex, template_literal::template_literal, typeof_symbol::typeof_symbol,
};
use crate::regexp::{self, regexp};
mod arrow;
mod block_scoped_fn;

View File

@ -491,7 +491,7 @@ mod tests {
use swc_ecma_transforms_testing::test;
use super::*;
use crate::es2015::{function_name, shorthand_property::shorthand};
use crate::{function_name, shorthand};
test!(
::swc_ecma_parser::Syntax::default(),
|_| {

View File

@ -1,6 +1,6 @@
use std::{iter, mem};
use serde::Deserialize;
use serde_derive::Deserialize;
use swc_atoms::JsWord;
use swc_common::{util::take::Take, BytePos, Spanned, DUMMY_SP};
use swc_ecma_ast::*;

View File

@ -0,0 +1,28 @@
[package]
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
description = "ES3 compatibility transforms"
documentation = "https://rustdoc.swc.rs/swc_ecma_compat_es2016/"
edition = "2021"
include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0"
name = "swc_ecma_compat_es2016"
repository = "https://github.com/swc-project/swc.git"
version = "0.1.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
swc_atoms = { version = "0.6.0", path = "../swc_atoms" }
swc_common = { version = "0.33.0", path = "../swc_common" }
swc_ecma_ast = { version = "0.110.0", path = "../swc_ecma_ast" }
swc_ecma_transforms_base = { version = "0.134.2", path = "../swc_ecma_transforms_base" }
swc_ecma_transforms_macros = { version = "0.5.3", path = "../swc_ecma_transforms_macros" }
swc_ecma_utils = { version = "0.124.2", path = "../swc_ecma_utils" }
swc_ecma_visit = { version = "0.96.0", path = "../swc_ecma_visit" }
swc_trace_macro = { version = "0.1.3", path = "../swc_trace_macro" }
tracing = "0.1.37"
[dev-dependencies]
swc_ecma_parser = { version = "0.141.1", path = "../swc_ecma_parser" }
swc_ecma_transforms_testing = { version = "0.137.2", path = "../swc_ecma_transforms_testing" }

View File

@ -1,3 +1,6 @@
#![allow(clippy::boxed_local)]
#![allow(clippy::vec_box)]
use swc_ecma_visit::Fold;
pub use self::exponentiation::exponentiation;

View File

@ -0,0 +1,30 @@
[package]
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
description = "ES3 compatibility transforms"
documentation = "https://rustdoc.swc.rs/swc_ecma_compat_es2017/"
edition = "2021"
include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0"
name = "swc_ecma_compat_es2017"
repository = "https://github.com/swc-project/swc.git"
version = "0.1.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = { version = "1.0.188", features = ["derive"] }
tracing = "0.1.37"
swc_atoms = { version = "0.6.0", path = "../swc_atoms" }
swc_common = { version = "0.33.0", path = "../swc_common" }
swc_ecma_ast = { version = "0.110.0", path = "../swc_ecma_ast" }
swc_ecma_transforms_base = { version = "0.134.2", path = "../swc_ecma_transforms_base" }
swc_ecma_transforms_macros = { version = "0.5.3", path = "../swc_ecma_transforms_macros" }
swc_ecma_utils = { version = "0.124.2", path = "../swc_ecma_utils" }
swc_ecma_visit = { version = "0.96.0", path = "../swc_ecma_visit" }
swc_trace_macro = { version = "0.1.3", path = "../swc_trace_macro" }
[dev-dependencies]
swc_ecma_parser = { version = "0.141.1", path = "../swc_ecma_parser" }
swc_ecma_transforms_testing = { version = "0.137.2", path = "../swc_ecma_transforms_testing" }

View File

@ -0,0 +1,31 @@
[package]
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
description = "ES2018 compatibility transforms"
documentation = "https://rustdoc.swc.rs/swc_ecma_compat_es2018/"
edition = "2021"
include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0"
name = "swc_ecma_compat_es2018"
repository = "https://github.com/swc-project/swc.git"
version = "0.1.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = { version = "1.0.188", features = ["derive"] }
tracing = "0.1.37"
swc_atoms = { version = "0.6.0", path = "../swc_atoms" }
swc_common = { version = "0.33.0", path = "../swc_common" }
swc_ecma_ast = { version = "0.110.0", path = "../swc_ecma_ast" }
swc_ecma_compat_common = { version = "0.1.0", path = "../swc_ecma_compat_common" }
swc_ecma_transforms_base = { version = "0.134.2", path = "../swc_ecma_transforms_base" }
swc_ecma_transforms_macros = { version = "0.5.3", path = "../swc_ecma_transforms_macros" }
swc_ecma_utils = { version = "0.124.2", path = "../swc_ecma_utils" }
swc_ecma_visit = { version = "0.96.0", path = "../swc_ecma_visit" }
swc_trace_macro = { version = "0.1.3", path = "../swc_trace_macro" }
[dev-dependencies]
swc_ecma_parser = { version = "0.141.1", path = "../swc_ecma_parser" }
swc_ecma_transforms_testing = { version = "0.137.2", path = "../swc_ecma_transforms_testing" }

View File

@ -1,9 +1,12 @@
#![allow(clippy::vec_box)]
#![allow(clippy::boxed_local)]
use serde::Deserialize;
use swc_common::chain;
use swc_ecma_compat_common::regexp::{self, regexp};
use swc_ecma_visit::Fold;
pub use self::object_rest_spread::object_rest_spread;
use crate::regexp::{self, regexp};
mod object_rest;
pub mod object_rest_spread;

View File

@ -5,6 +5,7 @@ use std::{
use swc_common::{util::take::Take, Mark, Spanned, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_compat_common::impl_visit_mut_fn;
use swc_ecma_transforms_base::{helper, helper_expr, perf::Check};
use swc_ecma_transforms_macros::fast_path;
use swc_ecma_utils::{

View File

@ -0,0 +1,29 @@
[package]
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
description = "ES2019 compatibility transforms"
documentation = "https://rustdoc.swc.rs/swc_ecma_compat_es2019/"
edition = "2021"
include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0"
name = "swc_ecma_compat_es2019"
repository = "https://github.com/swc-project/swc.git"
version = "0.1.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tracing = "0.1.37"
swc_atoms = { version = "0.6.0", path = "../swc_atoms" }
swc_common = { version = "0.33.0", path = "../swc_common" }
swc_ecma_ast = { version = "0.110.0", path = "../swc_ecma_ast" }
swc_ecma_transforms_base = { version = "0.134.2", path = "../swc_ecma_transforms_base" }
swc_ecma_utils = { version = "0.124.2", path = "../swc_ecma_utils" }
swc_ecma_visit = { version = "0.96.0", path = "../swc_ecma_visit" }
swc_trace_macro = { version = "0.1.3", path = "../swc_trace_macro" }
[dev-dependencies]
swc_ecma_parser = { version = "0.141.1", path = "../swc_ecma_parser" }
swc_ecma_transforms_testing = { version = "0.137.2", path = "../swc_ecma_transforms_testing" }

View File

@ -30,7 +30,7 @@ mod tests {
use swc_ecma_transforms_testing::test;
use swc_ecma_visit::{as_folder, Fold};
use crate::es2019::optional_catch_binding::OptionalCatchBinding;
use crate::optional_catch_binding::OptionalCatchBinding;
pub fn tr() -> impl Fold {
chain!(

View File

@ -0,0 +1,28 @@
[package]
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
description = "ES2020 compatibility transforms"
documentation = "https://rustdoc.swc.rs/swc_ecma_compat_es2020/"
edition = "2021"
include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0"
name = "swc_ecma_compat_es2020"
repository = "https://github.com/swc-project/swc.git"
version = "0.1.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = { version = "1.0.188", features = ["derive"] }
swc_atoms = { version = "0.6.0", path = "../swc_atoms" }
swc_common = { version = "0.33.0", path = "../swc_common" }
swc_ecma_ast = { version = "0.110.0", path = "../swc_ecma_ast" }
swc_ecma_transforms_base = { version = "0.134.2", path = "../swc_ecma_transforms_base" }
swc_ecma_utils = { version = "0.124.2", path = "../swc_ecma_utils" }
swc_ecma_visit = { version = "0.96.0", path = "../swc_ecma_visit" }
swc_trace_macro = { version = "0.1.3", path = "../swc_trace_macro" }
tracing = "0.1.37"
[dev-dependencies]
swc_ecma_parser = { version = "0.141.1", path = "../swc_ecma_parser" }
swc_ecma_transforms_testing = { version = "0.137.2", path = "../swc_ecma_transforms_testing" }

View File

@ -0,0 +1,24 @@
[package]
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
description = "ES2021 compatibility transforms"
documentation = "https://rustdoc.swc.rs/swc_ecma_compat_es2021/"
edition = "2021"
include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0"
name = "swc_ecma_compat_es2021"
repository = "https://github.com/swc-project/swc.git"
version = "0.1.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tracing = "0.1.37"
swc_atoms = { version = "0.6.0", path = "../swc_atoms" }
swc_common = { version = "0.33.0", path = "../swc_common" }
swc_ecma_ast = { version = "0.110.0", path = "../swc_ecma_ast" }
swc_ecma_transforms_base = { version = "0.134.2", path = "../swc_ecma_transforms_base" }
swc_ecma_utils = { version = "0.124.2", path = "../swc_ecma_utils" }
swc_ecma_visit = { version = "0.96.0", path = "../swc_ecma_visit" }
swc_trace_macro = { version = "0.1.3", path = "../swc_trace_macro" }

View File

@ -0,0 +1,28 @@
[package]
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
description = "ES2022 compatibility transforms"
documentation = "https://rustdoc.swc.rs/swc_ecma_compat_es2022/"
edition = "2021"
include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0"
name = "swc_ecma_compat_es2022"
repository = "https://github.com/swc-project/swc.git"
version = "0.1.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tracing = "0.1.37"
swc_atoms = { version = "0.6.0", path = "../swc_atoms" }
swc_common = { version = "0.33.0", path = "../swc_common" }
swc_ecma_ast = { version = "0.110.0", path = "../swc_ecma_ast" }
swc_ecma_compat_common = { version = "0.1.0", path = "../swc_ecma_compat_common" }
swc_ecma_transforms_base = { version = "0.134.2", path = "../swc_ecma_transforms_base" }
swc_ecma_transforms_classes = { version = "0.123.2", path = "../swc_ecma_transforms_classes" }
swc_ecma_transforms_macros = { version = "0.5.3", path = "../swc_ecma_transforms_macros" }
swc_ecma_utils = { version = "0.124.2", path = "../swc_ecma_utils" }
swc_ecma_visit = { version = "0.96.0", path = "../swc_ecma_visit" }
swc_trace_macro = { version = "0.1.3", path = "../swc_trace_macro" }

View File

@ -60,14 +60,7 @@ impl MemberInitRecord {
// there shouldn't be many class field, so n^2 should be fine
if let MemberInit::PrivAccessor(accessor) = member {
if let Some(MemberInit::PrivAccessor(previous)) =
self.record.iter_mut().find(|item| match item {
MemberInit::PrivAccessor(PrivAccessor { name, .. })
if name.sym == accessor.name.sym =>
{
true
}
_ => false,
})
self.record.iter_mut().find(|item| matches!(item, MemberInit::PrivAccessor(PrivAccessor { name, .. }) if name.sym == accessor.name.sym))
{
previous.getter = previous.getter.take().or(accessor.getter);
previous.setter = previous.setter.take().or(accessor.setter);

View File

@ -1,11 +1,13 @@
#![allow(clippy::vec_box)]
use swc_common::{chain, comments::Comments};
use swc_ecma_compat_common::regexp::{self, regexp};
use swc_ecma_visit::Fold;
pub use self::{
class_properties::class_properties, private_in_object::private_in_object,
static_blocks::static_blocks,
};
use crate::regexp::{self, regexp};
pub mod class_properties;
pub mod private_in_object;

View File

@ -0,0 +1,27 @@
[package]
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
description = "ES3 compatibility transforms"
documentation = "https://rustdoc.swc.rs/swc_ecma_compat_es3/"
edition = "2021"
include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0"
name = "swc_ecma_compat_es3"
repository = "https://github.com/swc-project/swc.git"
version = "0.1.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tracing = "0.1.37"
swc_common = { version = "0.33.0", path = "../swc_common" }
swc_ecma_ast = { version = "0.110.0", path = "../swc_ecma_ast" }
swc_ecma_transforms_base = { version = "0.134.2", path = "../swc_ecma_transforms_base" }
swc_ecma_utils = { version = "0.124.2", path = "../swc_ecma_utils" }
swc_ecma_visit = { version = "0.96.0", path = "../swc_ecma_visit" }
swc_trace_macro = { version = "0.1.3", path = "../swc_trace_macro" }
[dev-dependencies]
swc_ecma_parser = { version = "0.141.1", path = "../swc_ecma_parser" }
swc_ecma_transforms_testing = { version = "0.137.2", path = "../swc_ecma_transforms_testing" }

View File

@ -33,6 +33,17 @@ swc_atoms = { version = "0.6.0", path = "../swc_atoms" }
swc_common = { version = "0.33.0", path = "../swc_common" }
swc_config = { version = "0.1.7", path = "../swc_config" }
swc_ecma_ast = { version = "0.110.0", path = "../swc_ecma_ast" }
swc_ecma_compat_bugfixes = { version = "0.1.0", path = "../swc_ecma_compat_bugfixes" }
swc_ecma_compat_common = { version = "0.1.0", path = "../swc_ecma_compat_common" }
swc_ecma_compat_es2015 = { version = "0.1.0", path = "../swc_ecma_compat_es2015" }
swc_ecma_compat_es2016 = { version = "0.1.0", path = "../swc_ecma_compat_es2016" }
swc_ecma_compat_es2017 = { version = "0.1.0", path = "../swc_ecma_compat_es2017" }
swc_ecma_compat_es2018 = { version = "0.1.0", path = "../swc_ecma_compat_es2018" }
swc_ecma_compat_es2019 = { version = "0.1.0", path = "../swc_ecma_compat_es2019" }
swc_ecma_compat_es2020 = { version = "0.1.0", path = "../swc_ecma_compat_es2020" }
swc_ecma_compat_es2021 = { version = "0.1.0", path = "../swc_ecma_compat_es2021" }
swc_ecma_compat_es2022 = { version = "0.1.0", path = "../swc_ecma_compat_es2022" }
swc_ecma_compat_es3 = { version = "0.1.0", path = "../swc_ecma_compat_es3" }
swc_ecma_transforms_base = { version = "0.134.2", path = "../swc_ecma_transforms_base" }
swc_ecma_transforms_classes = { version = "0.123.2", path = "../swc_ecma_transforms_classes" }
swc_ecma_transforms_macros = { version = "0.5.3", path = "../swc_ecma_transforms_macros" }

View File

@ -5,23 +5,21 @@
#![allow(clippy::mutable_key_type)]
#![allow(clippy::match_like_matches_macro)]
pub use swc_ecma_compat_bugfixes as bugfixes;
pub use swc_ecma_compat_common::regexp;
pub use swc_ecma_compat_es2015 as es2015;
pub use swc_ecma_compat_es2016 as es2016;
pub use swc_ecma_compat_es2017 as es2017;
pub use swc_ecma_compat_es2018 as es2018;
pub use swc_ecma_compat_es2019 as es2019;
pub use swc_ecma_compat_es2020 as es2020;
pub use swc_ecma_compat_es2021 as es2021;
pub use swc_ecma_compat_es2022 as es2022;
pub use swc_ecma_compat_es3 as es3;
pub use self::{
bugfixes::bugfixes, es2015::es2015, es2016::es2016, es2017::es2017, es2018::es2018,
es2019::es2019, es2020::es2020, es2021::es2021, es2022::es2022, es3::es3,
};
#[macro_use]
mod macros;
pub mod bugfixes;
pub mod class_fields_use_set;
pub mod es2015;
pub mod es2016;
pub mod es2017;
pub mod es2018;
pub mod es2019;
pub mod es2020;
pub mod es2021;
pub mod es2022;
pub mod es3;
pub mod regexp;
pub mod reserved_words;