From 994c9655c899d71e5482a7bfe06cad015a25f512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Fri, 5 Nov 2021 16:09:08 +0900 Subject: [PATCH] feat(es/ast): Add utils (#2657) swc_ecma_ast: - Add `as_ident` to `PatOrExpr`. - Add `as_ident_mut` to `PatOrExpr`. - Replace `Is` macro for `ParOrExpr` with custom impl. --- Cargo.lock | 56 ++++---- Cargo.toml | 30 ++--- bundler/Cargo.toml | 26 ++-- ecmascript/Cargo.toml | 20 +-- ecmascript/ast/Cargo.toml | 2 +- ecmascript/ast/src/expr.rs | 121 +++++++++++++++++- ecmascript/codegen/Cargo.toml | 6 +- ecmascript/dep-graph/Cargo.toml | 8 +- ecmascript/ext-transforms/Cargo.toml | 10 +- ecmascript/jsdoc/Cargo.toml | 6 +- ecmascript/loader/Cargo.toml | 6 +- ecmascript/minifier/Cargo.toml | 16 +-- .../src/compress/optimize/sequences.rs | 22 ++-- .../minifier/src/compress/pure/sequences.rs | 4 +- ecmascript/minifier/src/compress/util/mod.rs | 34 ----- ecmascript/parser/Cargo.toml | 6 +- ecmascript/preset-env/Cargo.toml | 14 +- ecmascript/transforms/Cargo.toml | 28 ++-- ecmascript/transforms/base/Cargo.toml | 12 +- ecmascript/transforms/classes/Cargo.toml | 10 +- ecmascript/transforms/compat/Cargo.toml | 16 +-- .../compat/src/es2015/function_name.rs | 2 +- .../compat/src/es2016/exponentation.rs | 5 +- .../es2022/class_properties/private_field.rs | 5 +- ecmascript/transforms/module/Cargo.toml | 18 +-- ecmascript/transforms/optimization/Cargo.toml | 24 ++-- .../optimization/src/simplify/dce/mod.rs | 1 - .../optimization/src/simplify/inlining/mod.rs | 2 +- ecmascript/transforms/proposal/Cargo.toml | 22 ++-- ecmascript/transforms/react/Cargo.toml | 20 +-- .../transforms/react/src/display_name/mod.rs | 1 - ecmascript/transforms/testing/Cargo.toml | 14 +- ecmascript/transforms/typescript/Cargo.toml | 24 ++-- ecmascript/utils/Cargo.toml | 6 +- ecmascript/visit/Cargo.toml | 4 +- plugin/Cargo.toml | 8 +- plugin/api/Cargo.toml | 6 +- plugin/runner/Cargo.toml | 10 +- plugin/testing/Cargo.toml | 12 +- 39 files changed, 357 insertions(+), 280 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 218638887d9b..c5be7e8b5af1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -950,7 +950,7 @@ dependencies = [ [[package]] name = "jsdoc" -version = "0.45.1" +version = "0.46.0" dependencies = [ "anyhow", "dashmap", @@ -2350,7 +2350,7 @@ checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" [[package]] name = "swc" -version = "0.81.1" +version = "0.82.0" dependencies = [ "ahash", "anyhow", @@ -2456,7 +2456,7 @@ dependencies = [ [[package]] name = "swc_bundler" -version = "0.78.1" +version = "0.80.0" dependencies = [ "ahash", "anyhow", @@ -2616,7 +2616,7 @@ dependencies = [ [[package]] name = "swc_ecma_ast" -version = "0.56.1" +version = "0.57.0" dependencies = [ "arbitrary", "is-macro", @@ -2630,7 +2630,7 @@ dependencies = [ [[package]] name = "swc_ecma_codegen" -version = "0.78.1" +version = "0.79.0" dependencies = [ "bitflags", "memchr", @@ -2660,7 +2660,7 @@ dependencies = [ [[package]] name = "swc_ecma_dep_graph" -version = "0.45.1" +version = "0.46.0" dependencies = [ "swc_atoms 0.2.9", "swc_common", @@ -2672,7 +2672,7 @@ dependencies = [ [[package]] name = "swc_ecma_ext_transforms" -version = "0.36.1" +version = "0.37.0" dependencies = [ "phf", "swc_atoms 0.2.9", @@ -2685,7 +2685,7 @@ dependencies = [ [[package]] name = "swc_ecma_loader" -version = "0.23.0" +version = "0.24.0" dependencies = [ "ahash", "anyhow", @@ -2707,7 +2707,7 @@ dependencies = [ [[package]] name = "swc_ecma_minifier" -version = "0.48.4" +version = "0.49.0" dependencies = [ "ahash", "ansi_term 0.12.1", @@ -2740,7 +2740,7 @@ dependencies = [ [[package]] name = "swc_ecma_parser" -version = "0.76.3" +version = "0.77.0" dependencies = [ "either", "enum_kind", @@ -2765,7 +2765,7 @@ dependencies = [ [[package]] name = "swc_ecma_preset_env" -version = "0.63.1" +version = "0.64.0" dependencies = [ "ahash", "dashmap", @@ -2791,7 +2791,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms" -version = "0.92.1" +version = "0.93.0" dependencies = [ "pretty_assertions 0.6.1", "sourcemap", @@ -2818,7 +2818,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_base" -version = "0.42.1" +version = "0.43.0" dependencies = [ "once_cell", "phf", @@ -2839,7 +2839,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_classes" -version = "0.28.1" +version = "0.29.0" dependencies = [ "swc_atoms 0.2.9", "swc_common", @@ -2851,7 +2851,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_compat" -version = "0.49.4" +version = "0.50.0" dependencies = [ "ahash", "arrayvec", @@ -2889,7 +2889,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_module" -version = "0.55.2" +version = "0.56.0" dependencies = [ "Inflector", "ahash", @@ -2912,7 +2912,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_optimization" -version = "0.62.1" +version = "0.63.0" dependencies = [ "ahash", "dashmap", @@ -2941,7 +2941,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_proposal" -version = "0.55.1" +version = "0.56.0" dependencies = [ "either", "serde", @@ -2965,7 +2965,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_react" -version = "0.57.1" +version = "0.58.0" dependencies = [ "ahash", "base64 0.13.0", @@ -2993,7 +2993,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_testing" -version = "0.43.1" +version = "0.44.0" dependencies = [ "ansi_term 0.12.1", "anyhow", @@ -3014,7 +3014,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_typescript" -version = "0.58.3" +version = "0.59.0" dependencies = [ "serde", "swc_atoms 0.2.9", @@ -3036,7 +3036,7 @@ dependencies = [ [[package]] name = "swc_ecma_utils" -version = "0.50.1" +version = "0.51.0" dependencies = [ "once_cell", "rayon", @@ -3050,7 +3050,7 @@ dependencies = [ [[package]] name = "swc_ecma_visit" -version = "0.42.0" +version = "0.43.0" dependencies = [ "num-bigint", "swc_atoms 0.2.9", @@ -3061,7 +3061,7 @@ dependencies = [ [[package]] name = "swc_ecmascript" -version = "0.84.1" +version = "0.85.0" dependencies = [ "swc_ecma_ast", "swc_ecma_codegen", @@ -3135,7 +3135,7 @@ dependencies = [ [[package]] name = "swc_plugin" -version = "0.11.0" +version = "0.12.0" dependencies = [ "abi_stable", "anyhow", @@ -3150,7 +3150,7 @@ dependencies = [ [[package]] name = "swc_plugin_api" -version = "0.2.0" +version = "0.3.0" dependencies = [ "abi_stable", "anyhow", @@ -3164,7 +3164,7 @@ dependencies = [ [[package]] name = "swc_plugin_runner" -version = "0.15.0" +version = "0.16.0" dependencies = [ "abi_stable", "anyhow", @@ -3182,7 +3182,7 @@ dependencies = [ [[package]] name = "swc_plugin_testing" -version = "0.17.0" +version = "0.18.0" dependencies = [ "anyhow", "swc_atoms 0.2.9", diff --git a/Cargo.toml b/Cargo.toml index 9b3c17d33744..25d772c42c73 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ include = ["Cargo.toml", "src/**/*.rs"] license = "Apache-2.0/MIT" name = "swc" repository = "https://github.com/swc-project/swc.git" -version = "0.81.1" +version = "0.82.0" [lib] name = "swc" @@ -61,14 +61,14 @@ serde_json = "1" sourcemap = "6" swc_atoms = {version = "0.2", path = "./atoms"} swc_common = {version = "0.14.0", path = "./common", features = ["sourcemap", "concurrent"]} -swc_ecma_ast = {version = "0.56.0", path = "./ecmascript/ast"} -swc_ecma_codegen = {version = "0.78.1", path = "./ecmascript/codegen"} -swc_ecma_ext_transforms = {version = "0.36.1", path = "./ecmascript/ext-transforms"} -swc_ecma_loader = {version = "0.23.0", path = "./ecmascript/loader", features = ["lru", "node", "tsc"]} -swc_ecma_minifier = {version = "0.48.1", path = "./ecmascript/minifier"} -swc_ecma_parser = {version = "0.76.3", path = "./ecmascript/parser"} -swc_ecma_preset_env = {version = "0.63.1", path = "./ecmascript/preset-env"} -swc_ecma_transforms = {version = "0.92.1", path = "./ecmascript/transforms", features = [ +swc_ecma_ast = {version = "0.57.0", path = "./ecmascript/ast"} +swc_ecma_codegen = {version = "0.79.0", path = "./ecmascript/codegen"} +swc_ecma_ext_transforms = {version = "0.37.0", path = "./ecmascript/ext-transforms"} +swc_ecma_loader = {version = "0.24.0", path = "./ecmascript/loader", features = ["lru", "node", "tsc"]} +swc_ecma_minifier = {version = "0.49.0", path = "./ecmascript/minifier"} +swc_ecma_parser = {version = "0.77.0", path = "./ecmascript/parser"} +swc_ecma_preset_env = {version = "0.64.0", path = "./ecmascript/preset-env"} +swc_ecma_transforms = {version = "0.93.0", path = "./ecmascript/transforms", features = [ "compat", "module", "optimization", @@ -76,12 +76,12 @@ swc_ecma_transforms = {version = "0.92.1", path = "./ecmascript/transforms", fea "react", "typescript", ]} -swc_ecma_transforms_base = {version = "0.42.1", path = "./ecmascript/transforms/base"} -swc_ecma_transforms_compat = {version = "0.49.1", path = "./ecmascript/transforms/compat"} -swc_ecma_transforms_optimization = {version = "0.62.1", path = "./ecmascript/transforms/optimization"} -swc_ecma_utils = {version = "0.50.0", path = "./ecmascript/utils"} -swc_ecma_visit = {version = "0.42.0", path = "./ecmascript/visit"} -swc_ecmascript = {version = "0.84.1", path = "./ecmascript"} +swc_ecma_transforms_base = {version = "0.43.0", path = "./ecmascript/transforms/base"} +swc_ecma_transforms_compat = {version = "0.50.0", path = "./ecmascript/transforms/compat"} +swc_ecma_transforms_optimization = {version = "0.63.0", path = "./ecmascript/transforms/optimization"} +swc_ecma_utils = {version = "0.51.0", path = "./ecmascript/utils"} +swc_ecma_visit = {version = "0.43.0", path = "./ecmascript/visit"} +swc_ecmascript = {version = "0.85.0", path = "./ecmascript"} swc_visit = {version = "0.2.3", path = "./visit"} tracing = "0.1.28" diff --git a/bundler/Cargo.toml b/bundler/Cargo.toml index 486c08d03e82..13cf1c5c08cd 100644 --- a/bundler/Cargo.toml +++ b/bundler/Cargo.toml @@ -9,7 +9,7 @@ include = ["Cargo.toml", "build.rs", "src/**/*.rs", "src/**/*.js"] license = "Apache-2.0/MIT" name = "swc_bundler" repository = "https://github.com/swc-project/swc.git" -version = "0.78.1" +version = "0.80.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] @@ -38,14 +38,14 @@ relative-path = "1.2" retain_mut = "0.1.2" swc_atoms = {version = "0.2.4", path = "../atoms"} swc_common = {version = "0.14.0", path = "../common"} -swc_ecma_ast = {version = "0.56.0", path = "../ecmascript/ast"} -swc_ecma_codegen = {version = "0.78.1", path = "../ecmascript/codegen"} -swc_ecma_loader = {version = "0.23.0", path = "../ecmascript/loader"} -swc_ecma_parser = {version = "0.76.3", path = "../ecmascript/parser"} -swc_ecma_transforms_base = {version = "0.42.1", path = "../ecmascript/transforms/base"} -swc_ecma_transforms_optimization = {version = "0.62.1", path = "../ecmascript/transforms/optimization"} -swc_ecma_utils = {version = "0.50.0", path = "../ecmascript/utils"} -swc_ecma_visit = {version = "0.42.0", path = "../ecmascript/visit"} +swc_ecma_ast = {version = "0.57.0", path = "../ecmascript/ast"} +swc_ecma_codegen = {version = "0.79.0", path = "../ecmascript/codegen"} +swc_ecma_loader = {version = "0.24.0", path = "../ecmascript/loader"} +swc_ecma_parser = {version = "0.77.0", path = "../ecmascript/parser"} +swc_ecma_transforms_base = {version = "0.43.0", path = "../ecmascript/transforms/base"} +swc_ecma_transforms_optimization = {version = "0.63.0", path = "../ecmascript/transforms/optimization"} +swc_ecma_utils = {version = "0.51.0", path = "../ecmascript/utils"} +swc_ecma_visit = {version = "0.43.0", path = "../ecmascript/visit"} tracing = "0.1.28" [dev-dependencies] @@ -54,10 +54,10 @@ ntest = "0.7.2" path-clean = "=0.1.0" reqwest = {version = "0.11.4", features = ["blocking"]} sha-1 = "0.9" -swc_ecma_loader = {version = "0.23.0", path = "../ecmascript/loader", features = ["node", "lru"]} -swc_ecma_minifier = {version = "0.48.1", path = "../ecmascript/minifier"} -swc_ecma_transforms_react = {version = "0.57.1", path = "../ecmascript/transforms/react"} -swc_ecma_transforms_typescript = {version = "0.58.1", path = "../ecmascript/transforms/typescript"} +swc_ecma_loader = {version = "0.24.0", path = "../ecmascript/loader", features = ["node", "lru"]} +swc_ecma_minifier = {version = "0.49.0", path = "../ecmascript/minifier"} +swc_ecma_transforms_react = {version = "0.58.0", path = "../ecmascript/transforms/react"} +swc_ecma_transforms_typescript = {version = "0.59.0", path = "../ecmascript/transforms/typescript"} swc_node_base = {version = "0.5.0", path = "../node/base"} tempfile = "3.1.0" testing = {version = "0.15.0", path = "../testing"} diff --git a/ecmascript/Cargo.toml b/ecmascript/Cargo.toml index bfc845f116ea..0fb0631c1721 100644 --- a/ecmascript/Cargo.toml +++ b/ecmascript/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecmascript" repository = "https://github.com/swc-project/swc.git" -version = "0.84.1" +version = "0.85.0" [package.metadata.docs.rs] all-features = true @@ -32,14 +32,14 @@ react = ["swc_ecma_transforms/react"] typescript = ["typescript-parser", "swc_ecma_transforms/typescript"] [dependencies] -swc_ecma_ast = {version = "0.56.0", path = "./ast"} -swc_ecma_codegen = {version = "0.78.1", path = "./codegen", optional = true} -swc_ecma_dep_graph = {version = "0.45.1", path = "./dep-graph", optional = true} -swc_ecma_minifier = {version = "0.48.1", path = "./minifier", optional = true} -swc_ecma_parser = {version = "0.76.3", path = "./parser", optional = true, default-features = false} -swc_ecma_preset_env = {version = "0.63.1", path = "./preset-env", optional = true} -swc_ecma_transforms = {version = "0.92.1", path = "./transforms", optional = true} -swc_ecma_utils = {version = "0.50.0", path = "./utils", optional = true} -swc_ecma_visit = {version = "0.42.0", path = "./visit", optional = true} +swc_ecma_ast = {version = "0.57.0", path = "./ast"} +swc_ecma_codegen = {version = "0.79.0", path = "./codegen", optional = true} +swc_ecma_dep_graph = {version = "0.46.0", path = "./dep-graph", optional = true} +swc_ecma_minifier = {version = "0.49.0", path = "./minifier", optional = true} +swc_ecma_parser = {version = "0.77.0", path = "./parser", optional = true, default-features = false} +swc_ecma_preset_env = {version = "0.64.0", path = "./preset-env", optional = true} +swc_ecma_transforms = {version = "0.93.0", path = "./transforms", optional = true} +swc_ecma_utils = {version = "0.51.0", path = "./utils", optional = true} +swc_ecma_visit = {version = "0.43.0", path = "./visit", optional = true} [dev-dependencies] diff --git a/ecmascript/ast/Cargo.toml b/ecmascript/ast/Cargo.toml index 17b473fc479c..f8343bc9cc89 100644 --- a/ecmascript/ast/Cargo.toml +++ b/ecmascript/ast/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_ast" repository = "https://github.com/swc-project/swc.git" -version = "0.56.1" +version = "0.57.0" [features] default = [] diff --git a/ecmascript/ast/src/expr.rs b/ecmascript/ast/src/expr.rs index ae8461d17afc..eb44ce3d86e6 100644 --- a/ecmascript/ast/src/expr.rs +++ b/ecmascript/ast/src/expr.rs @@ -745,7 +745,7 @@ impl Take for BlockStmtOrExpr { } #[ast_node] -#[derive(Eq, Hash, Is, EqIgnoreSpan)] +#[derive(Eq, Hash, EqIgnoreSpan)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub enum PatOrExpr { #[tag("ThisExpression")] @@ -790,6 +790,125 @@ pub enum PatOrExpr { Pat(Box), } +impl PatOrExpr { + /// Returns the [Pat] if this is a pattern, otherwise returns [None]. + pub fn pat(self) -> Option> { + match self { + PatOrExpr::Expr(_) => None, + PatOrExpr::Pat(p) => Some(p), + } + } + + /// Returns the [Expr] if this is an expression, otherwise returns + /// `None`. + pub fn expr(self) -> Option> { + match self { + PatOrExpr::Expr(e) => Some(e), + PatOrExpr::Pat(p) => match *p { + Pat::Expr(e) => Some(e), + _ => None, + }, + } + } + + #[track_caller] + pub fn expect_pat(self) -> Box { + self.pat() + .expect("expect_pat is called but it was not a pattern") + } + + #[track_caller] + pub fn expect_expr(self) -> Box { + self.expr() + .expect("expect_expr is called but it was not a pattern") + } + + pub fn as_pat(&self) -> Option<&Pat> { + match self { + PatOrExpr::Expr(_) => None, + PatOrExpr::Pat(p) => Some(p), + } + } + + pub fn as_expr(&self) -> Option<&Expr> { + match self { + PatOrExpr::Expr(e) => Some(e), + PatOrExpr::Pat(p) => match &**p { + Pat::Expr(e) => Some(e), + _ => None, + }, + } + } + + pub fn is_pat(&self) -> bool { + self.as_pat().is_some() + } + + pub fn is_expr(&self) -> bool { + self.as_expr().is_some() + } + + pub fn as_ident(&self) -> Option<&Ident> { + match self { + PatOrExpr::Expr(v) => match &**v { + Expr::Ident(i) => Some(i), + _ => None, + }, + PatOrExpr::Pat(v) => match &**v { + Pat::Ident(i) => Some(&i.id), + Pat::Expr(v) => match &**v { + Expr::Ident(i) => Some(i), + _ => None, + }, + _ => None, + }, + } + } + + pub fn as_ident_mut(&mut self) -> Option<&mut Ident> { + match self { + PatOrExpr::Expr(v) => match &mut **v { + Expr::Ident(i) => Some(i), + _ => None, + }, + PatOrExpr::Pat(v) => match &mut **v { + Pat::Ident(i) => Some(&mut i.id), + Pat::Expr(v) => match &mut **v { + Expr::Ident(i) => Some(i), + _ => None, + }, + _ => None, + }, + } + } + + pub fn normalize_expr(self) -> Self { + match self { + PatOrExpr::Pat(pat) => match *pat { + Pat::Expr(expr) => PatOrExpr::Expr(expr), + _ => return PatOrExpr::Pat(pat), + }, + _ => self, + } + } + + pub fn normalize_ident(self) -> Self { + match self { + PatOrExpr::Expr(expr) => match *expr { + Expr::Ident(i) => PatOrExpr::Pat(Box::new(Pat::Ident(i.into()))), + _ => PatOrExpr::Expr(expr), + }, + PatOrExpr::Pat(pat) => match *pat { + Pat::Expr(expr) => match *expr { + Expr::Ident(i) => PatOrExpr::Pat(Box::new(Pat::Ident(i.into()))), + _ => PatOrExpr::Expr(expr), + }, + _ => PatOrExpr::Pat(pat), + }, + } + } +} + impl Take for PatOrExpr { fn dummy() -> Self { PatOrExpr::Pat(Take::dummy()) diff --git a/ecmascript/codegen/Cargo.toml b/ecmascript/codegen/Cargo.toml index e9e4386f0f67..d5c028483934 100644 --- a/ecmascript/codegen/Cargo.toml +++ b/ecmascript/codegen/Cargo.toml @@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs"] license = "Apache-2.0/MIT" name = "swc_ecma_codegen" repository = "https://github.com/swc-project/swc.git" -version = "0.78.1" +version = "0.79.0" [dependencies] bitflags = "1" @@ -17,9 +17,9 @@ once_cell = "1.8.0" sourcemap = "6" swc_atoms = {version = "0.2", path = "../../atoms"} swc_common = {version = "0.14.0", path = "../../common"} -swc_ecma_ast = {version = "0.56.0", path = "../ast"} +swc_ecma_ast = {version = "0.57.0", path = "../ast"} swc_ecma_codegen_macros = {version = "0.6.0", path = "./macros"} -swc_ecma_parser = {version = "0.76.3", path = "../parser"} +swc_ecma_parser = {version = "0.77.0", path = "../parser"} tracing = "0.1" [dev-dependencies] diff --git a/ecmascript/dep-graph/Cargo.toml b/ecmascript/dep-graph/Cargo.toml index 42b0e5307f58..a7b382d2bb57 100644 --- a/ecmascript/dep-graph/Cargo.toml +++ b/ecmascript/dep-graph/Cargo.toml @@ -6,14 +6,14 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_dep_graph" repository = "https://github.com/swc-project/swc.git" -version = "0.45.1" +version = "0.46.0" [dependencies] swc_atoms = {version = "0.2", path = "../../atoms"} swc_common = {version = "0.14.0", path = "../../common"} -swc_ecma_ast = {version = "0.56.0", path = "../ast"} -swc_ecma_visit = {version = "0.42.0", path = "../visit"} +swc_ecma_ast = {version = "0.57.0", path = "../ast"} +swc_ecma_visit = {version = "0.43.0", path = "../visit"} [dev-dependencies] -swc_ecma_parser = {version = "0.76.3", path = "../parser"} +swc_ecma_parser = {version = "0.77.0", path = "../parser"} testing = {version = "0.15.0", path = "../../testing"} diff --git a/ecmascript/ext-transforms/Cargo.toml b/ecmascript/ext-transforms/Cargo.toml index c01e584d2e5b..60e38359a31d 100644 --- a/ecmascript/ext-transforms/Cargo.toml +++ b/ecmascript/ext-transforms/Cargo.toml @@ -5,7 +5,7 @@ documentation = "https://rustdoc.swc.rs/swc_ecma_ext_transforms/" edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_ext_transforms" -version = "0.36.1" +version = "0.37.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -13,7 +13,7 @@ version = "0.36.1" phf = {version = "0.8.0", features = ["macros"]} swc_atoms = {version = "0.2", path = "../../atoms"} swc_common = {version = "0.14.0", path = "../../common"} -swc_ecma_ast = {version = "0.56.0", path = "../ast"} -swc_ecma_parser = {version = "0.76.3", path = "../parser"} -swc_ecma_utils = {version = "0.50.0", path = "../utils"} -swc_ecma_visit = {version = "0.42.0", path = "../visit"} +swc_ecma_ast = {version = "0.57.0", path = "../ast"} +swc_ecma_parser = {version = "0.77.0", path = "../parser"} +swc_ecma_utils = {version = "0.51.0", path = "../utils"} +swc_ecma_visit = {version = "0.43.0", path = "../visit"} diff --git a/ecmascript/jsdoc/Cargo.toml b/ecmascript/jsdoc/Cargo.toml index 1b9530ea5214..edadd1d5c4ff 100644 --- a/ecmascript/jsdoc/Cargo.toml +++ b/ecmascript/jsdoc/Cargo.toml @@ -5,7 +5,7 @@ documentation = "https://rustdoc.swc.rs/jsdoc/" edition = "2018" license = "Apache-2.0/MIT" name = "jsdoc" -version = "0.45.1" +version = "0.46.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -18,7 +18,7 @@ swc_common = {version = "0.14.0", path = "../../common"} [dev-dependencies] anyhow = "1" dashmap = "4.0.2" -swc_ecma_ast = {version = "0.56.0", path = "../ast"} -swc_ecma_parser = {version = "0.76.3", path = "../parser"} +swc_ecma_ast = {version = "0.57.0", path = "../ast"} +swc_ecma_parser = {version = "0.77.0", path = "../parser"} testing = {version = "0.15.0", path = "../../testing"} walkdir = "2" diff --git a/ecmascript/loader/Cargo.toml b/ecmascript/loader/Cargo.toml index 6522dcdc6b44..185a7286f7a7 100644 --- a/ecmascript/loader/Cargo.toml +++ b/ecmascript/loader/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_loader" repository = "https://github.com/swc-project/swc.git" -version = "0.23.0" +version = "0.24.0" [package.metadata.docs.rs] all-features = true @@ -31,8 +31,8 @@ serde = {version = "1.0.126", optional = true} serde_json = {version = "1.0.64", optional = true} swc_atoms = {version = "0.2.3", path = "../../atoms"} swc_common = {version = "0.14.0", path = "../../common"} -swc_ecma_ast = {version = "0.56.0", path = "../ast"} -swc_ecma_visit = {version = "0.42.0", path = "../visit"} +swc_ecma_ast = {version = "0.57.0", path = "../ast"} +swc_ecma_visit = {version = "0.43.0", path = "../visit"} tracing = "0.1.28" [dev-dependencies] diff --git a/ecmascript/minifier/Cargo.toml b/ecmascript/minifier/Cargo.toml index 7a0ce112dedf..ed21cd67683c 100644 --- a/ecmascript/minifier/Cargo.toml +++ b/ecmascript/minifier/Cargo.toml @@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs", "src/lists/*.json"] license = "Apache-2.0/MIT" name = "swc_ecma_minifier" repository = "https://github.com/swc-project/swc.git" -version = "0.48.4" +version = "0.49.0" [features] debug = ["backtrace"] @@ -26,13 +26,13 @@ serde_json = "1.0.61" serde_regex = "1.1.0" swc_atoms = {version = "0.2", path = "../../atoms"} swc_common = {version = "0.14.0", path = "../../common"} -swc_ecma_ast = {version = "0.56.0", path = "../ast"} -swc_ecma_codegen = {version = "0.78.1", path = "../codegen"} -swc_ecma_parser = {version = "0.76.3", path = "../parser"} -swc_ecma_transforms = {version = "0.92.1", path = "../transforms/", features = ["optimization"]} -swc_ecma_transforms_base = {version = "0.42.1", path = "../transforms/base"} -swc_ecma_utils = {version = "0.50.0", path = "../utils"} -swc_ecma_visit = {version = "0.42.0", path = "../visit"} +swc_ecma_ast = {version = "0.57.0", path = "../ast"} +swc_ecma_codegen = {version = "0.79.0", path = "../codegen"} +swc_ecma_parser = {version = "0.77.0", path = "../parser"} +swc_ecma_transforms = {version = "0.93.0", path = "../transforms/", features = ["optimization"]} +swc_ecma_transforms_base = {version = "0.43.0", path = "../transforms/base"} +swc_ecma_utils = {version = "0.51.0", path = "../utils"} +swc_ecma_visit = {version = "0.43.0", path = "../visit"} tracing = "0.1.28" unicode-xid = "0.2.2" diff --git a/ecmascript/minifier/src/compress/optimize/sequences.rs b/ecmascript/minifier/src/compress/optimize/sequences.rs index 47c8f7609efb..f3b81e0d293c 100644 --- a/ecmascript/minifier/src/compress/optimize/sequences.rs +++ b/ecmascript/minifier/src/compress/optimize/sequences.rs @@ -2,7 +2,7 @@ use super::{is_pure_undefined, Optimizer}; use crate::{ compress::{ optimize::util::replace_id_with_expr, - util::{get_lhs_ident, get_lhs_ident_mut, is_directive, is_ident_used_by, replace_expr}, + util::{is_directive, is_ident_used_by, replace_expr}, }, debug::dump, mode::Mode, @@ -241,7 +241,7 @@ where .. }) => { if !has_conflict - && get_lhs_ident_mut(left).is_some() + && left.as_ident().is_some() && match &**right { Expr::Lit(Lit::Regex(..)) => false, Expr::Lit(..) => true, @@ -568,7 +568,7 @@ where match &*e.exprs[e.exprs.len() - 2] { Expr::Assign(assign @ AssignExpr { op: op!("="), .. }) => { - if let Some(lhs) = get_lhs_ident(&assign.left) { + if let Some(lhs) = assign.left.as_ident() { if lhs.sym == last_id.sym && lhs.span.ctxt == last_id.span.ctxt { e.exprs.pop(); self.changed = true; @@ -878,7 +878,7 @@ where } Expr::Assign(e) => { - let left_id = get_lhs_ident(&e.left); + let left_id = e.left.as_ident(); let left_id = match left_id { Some(v) => v, _ => return false, @@ -1070,7 +1070,7 @@ where } Expr::Assign(b) => { - let b_left = get_lhs_ident(&b.left); + let b_left = b.left.as_ident(); let b_left = match b_left { Some(v) => v.clone(), None => return Ok(false), @@ -1275,7 +1275,7 @@ where }) => { match &**arg { Expr::Ident(a_id) => { - let mut v = UsageCoutner { + let mut v = UsageCounter { expr_usage: Default::default(), pat_usage: Default::default(), target: &*a_id, @@ -1331,7 +1331,7 @@ where // // (console.log(a = 5)) - let left_id = match get_lhs_ident(left) { + let left_id = match left.as_ident() { Some(v) => v, None => { tracing::trace!("[X] sequences: Aborting because lhs is not an id"); @@ -1434,7 +1434,7 @@ where } { - let mut v = UsageCoutner { + let mut v = UsageCounter { expr_usage: Default::default(), pat_usage: Default::default(), target: &left_id, @@ -1475,7 +1475,7 @@ where } } -struct UsageCoutner<'a> { +struct UsageCounter<'a> { expr_usage: usize, pat_usage: usize, @@ -1483,7 +1483,7 @@ struct UsageCoutner<'a> { in_lhs: bool, } -impl Visit for UsageCoutner<'_> { +impl Visit for UsageCounter<'_> { noop_visit_type!(); fn visit_ident(&mut self, i: &Ident, _: &dyn Node) { @@ -1535,7 +1535,7 @@ impl Mergable<'_> { _ => None, }, Mergable::Expr(s) => match &**s { - Expr::Assign(s) => get_lhs_ident(&s.left).map(|v| v.to_id()), + Expr::Assign(s) => s.left.as_ident().map(|v| v.to_id()), _ => None, }, } diff --git a/ecmascript/minifier/src/compress/pure/sequences.rs b/ecmascript/minifier/src/compress/pure/sequences.rs index 6dbed94ae9bc..f7af5e5692f6 100644 --- a/ecmascript/minifier/src/compress/pure/sequences.rs +++ b/ecmascript/minifier/src/compress/pure/sequences.rs @@ -1,5 +1,5 @@ use super::Pure; -use crate::{compress::util::get_lhs_ident, mode::Mode}; +use crate::mode::Mode; use swc_common::{util::take::Take, SyntaxContext, DUMMY_SP}; use swc_ecma_ast::*; use swc_ecma_utils::{ExprExt, ExprFactory}; @@ -163,7 +163,7 @@ where .. }), ) => { - let var_name = get_lhs_ident(&a_assign.left); + let var_name = a_assign.left.as_ident(); let var_name = match var_name { Some(v) => v, None => continue, diff --git a/ecmascript/minifier/src/compress/util/mod.rs b/ecmascript/minifier/src/compress/util/mod.rs index 46117fd77b83..675dbe5f571d 100644 --- a/ecmascript/minifier/src/compress/util/mod.rs +++ b/ecmascript/minifier/src/compress/util/mod.rs @@ -374,40 +374,6 @@ pub(crate) fn is_valid_identifier(s: &str, ascii_only: bool) -> bool { && !s.is_reserved() } -pub(crate) fn get_lhs_ident(e: &PatOrExpr) -> Option<&Ident> { - match e { - PatOrExpr::Expr(v) => match &**v { - Expr::Ident(i) => Some(i), - _ => None, - }, - PatOrExpr::Pat(v) => match &**v { - Pat::Ident(i) => Some(&i.id), - Pat::Expr(v) => match &**v { - Expr::Ident(i) => Some(i), - _ => None, - }, - _ => None, - }, - } -} - -pub(crate) fn get_lhs_ident_mut(e: &mut PatOrExpr) -> Option<&mut Ident> { - match e { - PatOrExpr::Expr(v) => match &mut **v { - Expr::Ident(i) => Some(i), - _ => None, - }, - PatOrExpr::Pat(v) => match &mut **v { - Pat::Ident(i) => Some(&mut i.id), - Pat::Expr(v) => match &mut **v { - Expr::Ident(i) => Some(i), - _ => None, - }, - _ => None, - }, - } -} - pub(crate) fn is_directive(e: &Stmt) -> bool { match e { Stmt::Expr(s) => match &*s.expr { diff --git a/ecmascript/parser/Cargo.toml b/ecmascript/parser/Cargo.toml index cf318991b243..509a8621dee5 100644 --- a/ecmascript/parser/Cargo.toml +++ b/ecmascript/parser/Cargo.toml @@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs", "examples/**/*.rs"] license = "Apache-2.0/MIT" name = "swc_ecma_parser" repository = "https://github.com/swc-project/swc.git" -version = "0.76.3" +version = "0.77.0" [package.metadata.docs.rs] all-features = true @@ -27,8 +27,8 @@ serde = {version = "1", features = ["derive"]} smallvec = "1" swc_atoms = {version = "0.2.3", path = "../../atoms"} swc_common = {version = "0.14.0", path = "../../common"} -swc_ecma_ast = {version = "0.56.0", path = "../ast"} -swc_ecma_visit = {version = "0.42.0", path = "../visit"} +swc_ecma_ast = {version = "0.57.0", path = "../ast"} +swc_ecma_visit = {version = "0.43.0", path = "../visit"} tracing = "0.1.28" typed-arena = "2.0.1" unicode-xid = "0.2" diff --git a/ecmascript/preset-env/Cargo.toml b/ecmascript/preset-env/Cargo.toml index 21f5efaad060..f5b6a2c94af8 100644 --- a/ecmascript/preset-env/Cargo.toml +++ b/ecmascript/preset-env/Cargo.toml @@ -5,7 +5,7 @@ documentation = "https://rustdoc.swc.rs/swc_ecma_preset_env/" edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_preset_env" -version = "0.63.1" +version = "0.64.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -21,14 +21,14 @@ st-map = "0.1.2" string_enum = {version = "0.3.1", path = "../../macros/string_enum"} swc_atoms = {version = "0.2", path = "../../atoms"} swc_common = {version = "0.14.0", path = "../../common"} -swc_ecma_ast = {version = "0.56.0", path = "../ast"} -swc_ecma_transforms = {version = "0.92.1", path = "../transforms", features = ["compat", "proposal"]} -swc_ecma_utils = {version = "0.50.0", path = "../utils"} -swc_ecma_visit = {version = "0.42.0", path = "../visit"} +swc_ecma_ast = {version = "0.57.0", path = "../ast"} +swc_ecma_transforms = {version = "0.93.0", path = "../transforms", features = ["compat", "proposal"]} +swc_ecma_utils = {version = "0.51.0", path = "../utils"} +swc_ecma_visit = {version = "0.43.0", path = "../visit"} walkdir = "2" [dev-dependencies] pretty_assertions = "0.6" -swc_ecma_codegen = {version = "0.78.1", path = "../codegen"} -swc_ecma_parser = {version = "0.76.3", path = "../parser"} +swc_ecma_codegen = {version = "0.79.0", path = "../codegen"} +swc_ecma_parser = {version = "0.77.0", path = "../parser"} testing = {version = "0.15.0", path = "../../testing"} diff --git a/ecmascript/transforms/Cargo.toml b/ecmascript/transforms/Cargo.toml index 9f45908c0117..639bdf230265 100644 --- a/ecmascript/transforms/Cargo.toml +++ b/ecmascript/transforms/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms" repository = "https://github.com/swc-project/swc.git" -version = "0.92.1" +version = "0.93.0" [package.metadata.docs.rs] all-features = true @@ -24,24 +24,24 @@ typescript = ["swc_ecma_transforms_typescript"] [dependencies] swc_atoms = {version = "0.2.0", path = "../../atoms"} swc_common = {version = "0.14.0", path = "../../common"} -swc_ecma_ast = {version = "0.56.0", path = "../ast"} -swc_ecma_parser = {version = "0.76.3", path = "../parser"} -swc_ecma_transforms_base = {version = "0.42.1", path = "./base"} -swc_ecma_transforms_compat = {version = "0.49.1", path = "./compat", optional = true} -swc_ecma_transforms_module = {version = "0.55.1", path = "./module", optional = true} -swc_ecma_transforms_optimization = {version = "0.62.1", path = "./optimization", optional = true} -swc_ecma_transforms_proposal = {version = "0.55.1", path = "./proposal", optional = true} -swc_ecma_transforms_react = {version = "0.57.1", path = "./react", optional = true} -swc_ecma_transforms_typescript = {version = "0.58.1", path = "./typescript", optional = true} -swc_ecma_utils = {version = "0.50.0", path = "../utils"} -swc_ecma_visit = {version = "0.42.0", path = "../visit"} +swc_ecma_ast = {version = "0.57.0", path = "../ast"} +swc_ecma_parser = {version = "0.77.0", path = "../parser"} +swc_ecma_transforms_base = {version = "0.43.0", path = "./base"} +swc_ecma_transforms_compat = {version = "0.50.0", path = "./compat", optional = true} +swc_ecma_transforms_module = {version = "0.56.0", path = "./module", optional = true} +swc_ecma_transforms_optimization = {version = "0.63.0", path = "./optimization", optional = true} +swc_ecma_transforms_proposal = {version = "0.56.0", path = "./proposal", optional = true} +swc_ecma_transforms_react = {version = "0.58.0", path = "./react", optional = true} +swc_ecma_transforms_typescript = {version = "0.59.0", path = "./typescript", optional = true} +swc_ecma_utils = {version = "0.51.0", path = "../utils"} +swc_ecma_visit = {version = "0.43.0", path = "../visit"} unicode-xid = "0.2" [dev-dependencies] pretty_assertions = "0.6" sourcemap = "6" -swc_ecma_codegen = {version = "0.78.1", path = "../codegen"} -swc_ecma_transforms_testing = {version = "0.43.1", path = "./testing"} +swc_ecma_codegen = {version = "0.79.0", path = "../codegen"} +swc_ecma_transforms_testing = {version = "0.44.0", path = "./testing"} tempfile = "3" testing = {version = "0.15.0", path = "../../testing"} walkdir = "2" diff --git a/ecmascript/transforms/base/Cargo.toml b/ecmascript/transforms/base/Cargo.toml index 525c74b6f9ee..a48e2c6d88c8 100644 --- a/ecmascript/transforms/base/Cargo.toml +++ b/ecmascript/transforms/base/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_base" repository = "https://github.com/swc-project/swc.git" -version = "0.42.1" +version = "0.43.0" [features] concurrent = [ @@ -22,13 +22,13 @@ scoped-tls = "1.0.0" smallvec = "1.6.0" swc_atoms = {version = "0.2", path = "../../../atoms"} swc_common = {version = "0.14.0", path = "../../../common"} -swc_ecma_ast = {version = "0.56.0", path = "../../ast"} -swc_ecma_parser = {version = "0.76.3", path = "../../parser"} -swc_ecma_utils = {version = "0.50.0", path = "../../utils"} -swc_ecma_visit = {version = "0.42.0", path = "../../visit"} +swc_ecma_ast = {version = "0.57.0", path = "../../ast"} +swc_ecma_parser = {version = "0.77.0", path = "../../parser"} +swc_ecma_utils = {version = "0.51.0", path = "../../utils"} +swc_ecma_visit = {version = "0.43.0", path = "../../visit"} tracing = "0.1" [dev-dependencies] -swc_ecma_codegen = {version = "0.78.1", path = "../../codegen"} +swc_ecma_codegen = {version = "0.79.0", path = "../../codegen"} swc_ecma_transforms_macros = {version = "0.3.0", path = "../macros"} testing = {version = "0.15.0", path = "../../../testing"} diff --git a/ecmascript/transforms/classes/Cargo.toml b/ecmascript/transforms/classes/Cargo.toml index b41149693f6c..4ecb2aaa9e1b 100644 --- a/ecmascript/transforms/classes/Cargo.toml +++ b/ecmascript/transforms/classes/Cargo.toml @@ -6,12 +6,12 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_classes" repository = "https://github.com/swc-project/swc.git" -version = "0.28.1" +version = "0.29.0" [dependencies] swc_atoms = {version = "0.2.6", path = "../../../atoms"} swc_common = {version = "0.14.0", path = "../../../common"} -swc_ecma_ast = {version = "0.56.0", path = "../../ast"} -swc_ecma_transforms_base = {version = "0.42.1", path = "../base"} -swc_ecma_utils = {version = "0.50.0", path = "../../utils"} -swc_ecma_visit = {version = "0.42.0", path = "../../visit"} +swc_ecma_ast = {version = "0.57.0", path = "../../ast"} +swc_ecma_transforms_base = {version = "0.43.0", path = "../base"} +swc_ecma_utils = {version = "0.51.0", path = "../../utils"} +swc_ecma_visit = {version = "0.43.0", path = "../../visit"} diff --git a/ecmascript/transforms/compat/Cargo.toml b/ecmascript/transforms/compat/Cargo.toml index 0cd12bb6a009..0600d6d8a130 100644 --- a/ecmascript/transforms/compat/Cargo.toml +++ b/ecmascript/transforms/compat/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_compat" repository = "https://github.com/swc-project/swc.git" -version = "0.49.4" +version = "0.50.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] @@ -28,15 +28,15 @@ serde = {version = "1.0.118", features = ["derive"]} smallvec = "1.6.0" swc_atoms = {version = "0.2.5", path = "../../../atoms"} swc_common = {version = "0.14.0", path = "../../../common"} -swc_ecma_ast = {version = "0.56.0", path = "../../ast"} -swc_ecma_transforms_base = {version = "0.42.1", path = "../base"} -swc_ecma_transforms_classes = {version = "0.28.1", path = "../classes"} +swc_ecma_ast = {version = "0.57.0", path = "../../ast"} +swc_ecma_transforms_base = {version = "0.43.0", path = "../base"} +swc_ecma_transforms_classes = {version = "0.29.0", path = "../classes"} swc_ecma_transforms_macros = {version = "0.3.0", path = "../macros"} -swc_ecma_utils = {version = "0.50.0", path = "../../utils"} -swc_ecma_visit = {version = "0.42.0", path = "../../visit"} +swc_ecma_utils = {version = "0.51.0", path = "../../utils"} +swc_ecma_visit = {version = "0.43.0", path = "../../visit"} [dev-dependencies] serde_json = "1.0.66" -swc_ecma_parser = {version = "0.76.3", path = "../../parser"} -swc_ecma_transforms_testing = {version = "0.43.1", path = "../testing"} +swc_ecma_parser = {version = "0.77.0", path = "../../parser"} +swc_ecma_transforms_testing = {version = "0.44.0", path = "../testing"} testing = {version = "0.15.0", path = "../../../testing"} diff --git a/ecmascript/transforms/compat/src/es2015/function_name.rs b/ecmascript/transforms/compat/src/es2015/function_name.rs index e0b67543e94e..d1b33f737754 100644 --- a/ecmascript/transforms/compat/src/es2015/function_name.rs +++ b/ecmascript/transforms/compat/src/es2015/function_name.rs @@ -1,6 +1,6 @@ use swc_common::util::take::Take; use swc_ecma_ast::*; -use swc_ecma_transforms_base::{ext::PatOrExprExt, perf::Parallel}; +use swc_ecma_transforms_base::perf::Parallel; use swc_ecma_transforms_macros::parallel; use swc_ecma_utils::{private_ident, UsageFinder}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith}; diff --git a/ecmascript/transforms/compat/src/es2016/exponentation.rs b/ecmascript/transforms/compat/src/es2016/exponentation.rs index eb25901c604d..9f6618075872 100644 --- a/ecmascript/transforms/compat/src/es2016/exponentation.rs +++ b/ecmascript/transforms/compat/src/es2016/exponentation.rs @@ -1,9 +1,6 @@ use swc_common::{util::take::Take, Span, Spanned, DUMMY_SP}; use swc_ecma_ast::*; -use swc_ecma_transforms_base::{ - ext::PatOrExprExt, - perf::{ParExplode, Parallel}, -}; +use swc_ecma_transforms_base::perf::{ParExplode, Parallel}; use swc_ecma_transforms_macros::parallel; use swc_ecma_utils::{member_expr, private_ident, ExprFactory}; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith}; diff --git a/ecmascript/transforms/compat/src/es2022/class_properties/private_field.rs b/ecmascript/transforms/compat/src/es2022/class_properties/private_field.rs index 1a94df30c247..2a9b78e85e7c 100644 --- a/ecmascript/transforms/compat/src/es2022/class_properties/private_field.rs +++ b/ecmascript/transforms/compat/src/es2022/class_properties/private_field.rs @@ -2,10 +2,7 @@ use std::{iter, mem}; use swc_atoms::JsWord; use swc_common::{collections::AHashSet, util::take::Take, Mark, Spanned, SyntaxContext, DUMMY_SP}; use swc_ecma_ast::*; -use swc_ecma_transforms_base::{ - ext::{AsOptExpr, PatOrExprExt}, - helper, -}; +use swc_ecma_transforms_base::helper; use swc_ecma_utils::{alias_ident_for, alias_if_required, prepend, quote_ident, ExprFactory}; use swc_ecma_visit::{noop_fold_type, noop_visit_mut_type, Fold, FoldWith, VisitMut, VisitMutWith}; diff --git a/ecmascript/transforms/module/Cargo.toml b/ecmascript/transforms/module/Cargo.toml index 4f3244f0480e..e27e334a5c35 100644 --- a/ecmascript/transforms/module/Cargo.toml +++ b/ecmascript/transforms/module/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_module" repository = "https://github.com/swc-project/swc.git" -version = "0.55.2" +version = "0.56.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -18,14 +18,14 @@ pathdiff = "0.2.0" serde = {version = "1.0.118", features = ["derive"]} swc_atoms = {version = "0.2", path = "../../../atoms"} swc_common = {version = "0.14.0", path = "../../../common"} -swc_ecma_ast = {version = "0.56.0", path = "../../ast"} -swc_ecma_loader = {version = "0.23.0", path = "../../loader", features = ["node"]} -swc_ecma_parser = {version = "0.76.3", path = "../../parser"} -swc_ecma_transforms_base = {version = "0.42.1", path = "../base"} -swc_ecma_utils = {version = "0.50.0", path = "../../utils"} -swc_ecma_visit = {version = "0.42.0", path = "../../visit"} +swc_ecma_ast = {version = "0.57.0", path = "../../ast"} +swc_ecma_loader = {version = "0.24.0", path = "../../loader", features = ["node"]} +swc_ecma_parser = {version = "0.77.0", path = "../../parser"} +swc_ecma_transforms_base = {version = "0.43.0", path = "../base"} +swc_ecma_utils = {version = "0.51.0", path = "../../utils"} +swc_ecma_visit = {version = "0.43.0", path = "../../visit"} [dev-dependencies] -swc_ecma_transforms_compat = {version = "0.49.1", path = "../compat"} -swc_ecma_transforms_testing = {version = "0.43.1", path = "../testing/"} +swc_ecma_transforms_compat = {version = "0.50.0", path = "../compat"} +swc_ecma_transforms_testing = {version = "0.44.0", path = "../testing/"} testing = {version = "0.15.0", path = "../../../testing/"} diff --git a/ecmascript/transforms/optimization/Cargo.toml b/ecmascript/transforms/optimization/Cargo.toml index 2aea150e22ae..7a892efac2ec 100644 --- a/ecmascript/transforms/optimization/Cargo.toml +++ b/ecmascript/transforms/optimization/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_optimization" repository = "https://github.com/swc-project/swc.git" -version = "0.62.1" +version = "0.63.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] @@ -28,19 +28,19 @@ retain_mut = "0.1.2" serde_json = "1.0.61" swc_atoms = {version = "0.2", path = "../../../atoms"} swc_common = {version = "0.14.0", path = "../../../common"} -swc_ecma_ast = {version = "0.56.0", path = "../../ast"} -swc_ecma_parser = {version = "0.76.3", path = "../../parser"} -swc_ecma_transforms_base = {version = "0.42.1", path = "../base"} +swc_ecma_ast = {version = "0.57.0", path = "../../ast"} +swc_ecma_parser = {version = "0.77.0", path = "../../parser"} +swc_ecma_transforms_base = {version = "0.43.0", path = "../base"} swc_ecma_transforms_macros = {version = "0.3.0", path = "../macros"} -swc_ecma_utils = {version = "0.50.0", path = "../../utils"} -swc_ecma_visit = {version = "0.42.0", path = "../../visit"} +swc_ecma_utils = {version = "0.51.0", path = "../../utils"} +swc_ecma_visit = {version = "0.43.0", path = "../../visit"} tracing = "0.1.28" [dev-dependencies] -swc_ecma_transforms_compat = {version = "0.49.1", path = "../compat"} -swc_ecma_transforms_module = {version = "0.55.1", path = "../module"} -swc_ecma_transforms_proposal = {version = "0.55.1", path = "../proposal"} -swc_ecma_transforms_react = {version = "0.57.1", path = "../react"} -swc_ecma_transforms_testing = {version = "0.43.1", path = "../testing"} -swc_ecma_transforms_typescript = {version = "0.58.1", path = "../typescript"} +swc_ecma_transforms_compat = {version = "0.50.0", path = "../compat"} +swc_ecma_transforms_module = {version = "0.56.0", path = "../module"} +swc_ecma_transforms_proposal = {version = "0.56.0", path = "../proposal"} +swc_ecma_transforms_react = {version = "0.58.0", path = "../react"} +swc_ecma_transforms_testing = {version = "0.44.0", path = "../testing"} +swc_ecma_transforms_typescript = {version = "0.59.0", path = "../typescript"} testing = {version = "0.15.0", path = "../../../testing"} diff --git a/ecmascript/transforms/optimization/src/simplify/dce/mod.rs b/ecmascript/transforms/optimization/src/simplify/dce/mod.rs index 358dc69af3a1..c51acb688243 100644 --- a/ecmascript/transforms/optimization/src/simplify/dce/mod.rs +++ b/ecmascript/transforms/optimization/src/simplify/dce/mod.rs @@ -11,7 +11,6 @@ use swc_common::{ Mark, DUMMY_SP, }; use swc_ecma_ast::*; -use swc_ecma_transforms_base::ext::PatOrExprExt; use swc_ecma_utils::{ collect_decls, ident::IdentLike, ExprExt, Id, IsEmpty, ModuleItemLike, StmtLike, Value, }; diff --git a/ecmascript/transforms/optimization/src/simplify/inlining/mod.rs b/ecmascript/transforms/optimization/src/simplify/inlining/mod.rs index ff971ea235ad..d318f548fe29 100644 --- a/ecmascript/transforms/optimization/src/simplify/inlining/mod.rs +++ b/ecmascript/transforms/optimization/src/simplify/inlining/mod.rs @@ -6,7 +6,7 @@ use swc_common::{ DUMMY_SP, }; use swc_ecma_ast::*; -use swc_ecma_transforms_base::{ext::PatOrExprExt, pass::RepeatedJsPass, scope::IdentType}; +use swc_ecma_transforms_base::{pass::RepeatedJsPass, scope::IdentType}; use swc_ecma_utils::{contains_this_expr, find_ids, ident::IdentLike, undefined, Id}; use swc_ecma_visit::{ as_folder, noop_visit_mut_type, noop_visit_type, Node, Visit, VisitMut, VisitMutWith, VisitWith, diff --git a/ecmascript/transforms/proposal/Cargo.toml b/ecmascript/transforms/proposal/Cargo.toml index 02f165191126..a3b51ec3cb94 100644 --- a/ecmascript/transforms/proposal/Cargo.toml +++ b/ecmascript/transforms/proposal/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_proposal" repository = "https://github.com/swc-project/swc.git" -version = "0.55.1" +version = "0.56.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -20,18 +20,18 @@ serde = {version = "1.0.118", features = ["derive"]} smallvec = "1.6.0" swc_atoms = {version = "0.2", path = "../../../atoms"} swc_common = {version = "0.14.0", path = "../../../common"} -swc_ecma_ast = {version = "0.56.0", path = "../../ast"} -swc_ecma_loader = {version = "0.23.0", path = "../../loader", optional = true} -swc_ecma_parser = {version = "0.76.3", path = "../../parser"} -swc_ecma_transforms_base = {version = "0.42.1", path = "../base"} -swc_ecma_transforms_classes = {version = "0.28.1", path = "../classes"} +swc_ecma_ast = {version = "0.57.0", path = "../../ast"} +swc_ecma_loader = {version = "0.24.0", path = "../../loader", optional = true} +swc_ecma_parser = {version = "0.77.0", path = "../../parser"} +swc_ecma_transforms_base = {version = "0.43.0", path = "../base"} +swc_ecma_transforms_classes = {version = "0.29.0", path = "../classes"} swc_ecma_transforms_macros = {version = "0.3.0", path = "../macros"} -swc_ecma_utils = {version = "0.50.0", path = "../../utils"} -swc_ecma_visit = {version = "0.42.0", path = "../../visit"} +swc_ecma_utils = {version = "0.51.0", path = "../../utils"} +swc_ecma_visit = {version = "0.43.0", path = "../../visit"} [dev-dependencies] serde_json = "1.0.66" -swc_ecma_transforms_compat = {version = "0.49.1", path = "../compat"} -swc_ecma_transforms_module = {version = "0.55.1", path = "../module"} -swc_ecma_transforms_testing = {version = "0.43.1", path = "../testing"} +swc_ecma_transforms_compat = {version = "0.50.0", path = "../compat"} +swc_ecma_transforms_module = {version = "0.56.0", path = "../module"} +swc_ecma_transforms_testing = {version = "0.44.0", path = "../testing"} testing = {version = "0.15.0", path = "../../../testing"} diff --git a/ecmascript/transforms/react/Cargo.toml b/ecmascript/transforms/react/Cargo.toml index c6a810d7c62b..6f3d46e49b5c 100644 --- a/ecmascript/transforms/react/Cargo.toml +++ b/ecmascript/transforms/react/Cargo.toml @@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs"] license = "Apache-2.0/MIT" name = "swc_ecma_transforms_react" repository = "https://github.com/swc-project/swc.git" -version = "0.57.1" +version = "0.58.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -22,16 +22,16 @@ sha-1 = "0.9.4" string_enum = {version = "0.3.1", path = "../../../macros/string_enum"} swc_atoms = {version = "0.2", path = "../../../atoms"} swc_common = {version = "0.14.0", path = "../../../common"} -swc_ecma_ast = {version = "0.56.0", path = "../../ast"} -swc_ecma_parser = {version = "0.76.3", path = "../../parser"} -swc_ecma_transforms_base = {version = "0.42.1", path = "../base"} +swc_ecma_ast = {version = "0.57.0", path = "../../ast"} +swc_ecma_parser = {version = "0.77.0", path = "../../parser"} +swc_ecma_transforms_base = {version = "0.43.0", path = "../base"} swc_ecma_transforms_macros = {version = "0.3.0", path = "../macros"} -swc_ecma_utils = {version = "0.50.0", path = "../../utils"} -swc_ecma_visit = {version = "0.42.0", path = "../../visit"} +swc_ecma_utils = {version = "0.51.0", path = "../../utils"} +swc_ecma_visit = {version = "0.43.0", path = "../../visit"} [dev-dependencies] -swc_ecma_codegen = {version = "0.78.1", path = "../../codegen/"} -swc_ecma_transforms_compat = {version = "0.49.1", path = "../compat/"} -swc_ecma_transforms_module = {version = "0.55.1", path = "../module"} -swc_ecma_transforms_testing = {version = "0.43.1", path = "../testing/"} +swc_ecma_codegen = {version = "0.79.0", path = "../../codegen/"} +swc_ecma_transforms_compat = {version = "0.50.0", path = "../compat/"} +swc_ecma_transforms_module = {version = "0.56.0", path = "../module"} +swc_ecma_transforms_testing = {version = "0.44.0", path = "../testing/"} testing = {version = "0.15.0", path = "../../../testing"} diff --git a/ecmascript/transforms/react/src/display_name/mod.rs b/ecmascript/transforms/react/src/display_name/mod.rs index acfc031b9e87..9a1e70ae20d5 100644 --- a/ecmascript/transforms/react/src/display_name/mod.rs +++ b/ecmascript/transforms/react/src/display_name/mod.rs @@ -2,7 +2,6 @@ use std::ops::DerefMut; use swc_atoms::js_word; use swc_common::DUMMY_SP; use swc_ecma_ast::*; -use swc_ecma_transforms_base::ext::{AsOptExpr, PatOrExprExt}; use swc_ecma_utils::quote_ident; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith}; diff --git a/ecmascript/transforms/testing/Cargo.toml b/ecmascript/transforms/testing/Cargo.toml index 6a2709bf4863..0b4e082902e9 100644 --- a/ecmascript/transforms/testing/Cargo.toml +++ b/ecmascript/transforms/testing/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_testing" repository = "https://github.com/swc-project/swc.git" -version = "0.43.1" +version = "0.44.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -18,11 +18,11 @@ serde = "1" serde_json = "1" sha-1 = "0.9.8" swc_common = {version = "0.14.0", path = "../../../common"} -swc_ecma_ast = {version = "0.56.0", path = "../../ast"} -swc_ecma_codegen = {version = "0.78.1", path = "../../codegen"} -swc_ecma_parser = {version = "0.76.3", path = "../../parser"} -swc_ecma_transforms_base = {version = "0.42.1", path = "../base"} -swc_ecma_utils = {version = "0.50.0", path = "../../utils"} -swc_ecma_visit = {version = "0.42.0", path = "../../visit"} +swc_ecma_ast = {version = "0.57.0", path = "../../ast"} +swc_ecma_codegen = {version = "0.79.0", path = "../../codegen"} +swc_ecma_parser = {version = "0.77.0", path = "../../parser"} +swc_ecma_transforms_base = {version = "0.43.0", path = "../base"} +swc_ecma_utils = {version = "0.51.0", path = "../../utils"} +swc_ecma_visit = {version = "0.43.0", path = "../../visit"} tempfile = "3.1.0" testing = {version = "0.15.0", path = "../../../testing"} diff --git a/ecmascript/transforms/typescript/Cargo.toml b/ecmascript/transforms/typescript/Cargo.toml index 936928f7c252..f0fb3b27c4b6 100644 --- a/ecmascript/transforms/typescript/Cargo.toml +++ b/ecmascript/transforms/typescript/Cargo.toml @@ -6,25 +6,25 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_typescript" repository = "https://github.com/swc-project/swc.git" -version = "0.58.3" +version = "0.59.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] serde = {version = "1.0.118", features = ["derive"]} swc_atoms = {version = "0.2", path = "../../../atoms"} swc_common = {version = "0.14.0", path = "../../../common"} -swc_ecma_ast = {version = "0.56.0", path = "../../ast"} -swc_ecma_parser = {version = "0.76.3", path = "../../parser"} -swc_ecma_transforms_base = {version = "0.42.1", path = "../base"} -swc_ecma_transforms_react = {version = "0.57.1", path = "../react"} -swc_ecma_utils = {version = "0.50.0", path = "../../utils"} -swc_ecma_visit = {version = "0.42.0", path = "../../visit"} +swc_ecma_ast = {version = "0.57.0", path = "../../ast"} +swc_ecma_parser = {version = "0.77.0", path = "../../parser"} +swc_ecma_transforms_base = {version = "0.43.0", path = "../base"} +swc_ecma_transforms_react = {version = "0.58.0", path = "../react"} +swc_ecma_utils = {version = "0.51.0", path = "../../utils"} +swc_ecma_visit = {version = "0.43.0", path = "../../visit"} [dev-dependencies] -swc_ecma_codegen = {version = "0.78.1", path = "../../codegen"} -swc_ecma_transforms_compat = {version = "0.49.1", path = "../compat"} -swc_ecma_transforms_module = {version = "0.55.1", path = "../module"} -swc_ecma_transforms_proposal = {version = "0.55.1", path = "../proposal/"} -swc_ecma_transforms_testing = {version = "0.43.1", path = "../testing"} +swc_ecma_codegen = {version = "0.79.0", path = "../../codegen"} +swc_ecma_transforms_compat = {version = "0.50.0", path = "../compat"} +swc_ecma_transforms_module = {version = "0.56.0", path = "../module"} +swc_ecma_transforms_proposal = {version = "0.56.0", path = "../proposal/"} +swc_ecma_transforms_testing = {version = "0.44.0", path = "../testing"} testing = {version = "0.15.0", path = "../../../testing"} walkdir = "2.3.1" diff --git a/ecmascript/utils/Cargo.toml b/ecmascript/utils/Cargo.toml index addc36c1fda0..d31e9ea11b60 100644 --- a/ecmascript/utils/Cargo.toml +++ b/ecmascript/utils/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_utils" repository = "https://github.com/swc-project/swc.git" -version = "0.50.1" +version = "0.51.0" [features] # Process in parallel. @@ -20,8 +20,8 @@ once_cell = "1" rayon = {version = "1.5.1", optional = true} swc_atoms = {version = "0.2.0", path = "../../atoms"} swc_common = {version = "0.14.3", path = "../../common"} -swc_ecma_ast = {version = "0.56.0", path = "../ast"} -swc_ecma_visit = {version = "0.42.0", path = "../visit"} +swc_ecma_ast = {version = "0.57.0", path = "../ast"} +swc_ecma_visit = {version = "0.43.0", path = "../visit"} unicode-xid = "0.2" [dev-dependencies] diff --git a/ecmascript/visit/Cargo.toml b/ecmascript/visit/Cargo.toml index 77624e8f46f8..59364dd105f3 100644 --- a/ecmascript/visit/Cargo.toml +++ b/ecmascript/visit/Cargo.toml @@ -6,11 +6,11 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_visit" repository = "https://github.com/swc-project/swc.git" -version = "0.42.0" +version = "0.43.0" [dependencies] num-bigint = {version = "0.2", features = ["serde"]} swc_atoms = {version = "0.2", path = "../../atoms"} swc_common = {version = "0.14.0", path = "../../common"} -swc_ecma_ast = {version = "0.56.0", path = "../ast"} +swc_ecma_ast = {version = "0.57.0", path = "../ast"} swc_visit = {version = "0.2.3", path = "../../visit"} diff --git a/plugin/Cargo.toml b/plugin/Cargo.toml index f8ab3dd316de..e92c8410104b 100644 --- a/plugin/Cargo.toml +++ b/plugin/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_plugin" repository = "https://github.com/swc-project/swc.git" -version = "0.11.0" +version = "0.12.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -17,6 +17,6 @@ serde = "1.0.126" serde_json = "1.0.64" swc_atoms = {version = "0.2.7", path = "../atoms"} swc_common = {version = "0.14.0", path = "../common", features = ["plugin-mode"]} -swc_ecma_ast = {version = "0.56.0", path = "../ecmascript/ast"} -swc_ecma_visit = {version = "0.42.0", path = "../ecmascript/visit"} -swc_plugin_api = {version = "0.2.0", path = "./api"} +swc_ecma_ast = {version = "0.57.0", path = "../ecmascript/ast"} +swc_ecma_visit = {version = "0.43.0", path = "../ecmascript/visit"} +swc_plugin_api = {version = "0.3.0", path = "./api"} diff --git a/plugin/api/Cargo.toml b/plugin/api/Cargo.toml index 4793e45dc58b..4791d38e743b 100644 --- a/plugin/api/Cargo.toml +++ b/plugin/api/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_plugin_api" repository = "https://github.com/swc-project/swc.git" -version = "0.2.0" +version = "0.3.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -17,5 +17,5 @@ serde = "1.0.126" serde_json = "1" swc_atoms = {version = "0.2.7", path = "../../atoms"} swc_common = {version = "0.14.5", path = "../../common", features = ["plugin-base"]} -swc_ecma_ast = {version = "0.56.0", path = "../../ecmascript/ast"} -swc_ecma_visit = {version = "0.42.0", path = "../../ecmascript/visit"} +swc_ecma_ast = {version = "0.57.0", path = "../../ecmascript/ast"} +swc_ecma_visit = {version = "0.43.0", path = "../../ecmascript/visit"} diff --git a/plugin/runner/Cargo.toml b/plugin/runner/Cargo.toml index ffbe89570fb7..3b5063c12f35 100644 --- a/plugin/runner/Cargo.toml +++ b/plugin/runner/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_plugin_runner" repository = "https://github.com/swc-project/swc.git" -version = "0.15.0" +version = "0.16.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -17,10 +17,10 @@ serde = {version = "1.0.126", features = ["derive"]} serde_json = "1.0.64" swc_atoms = "0.2.7" swc_common = {version = "0.14.0", path = "../../common", features = ["plugin-rt"]} -swc_ecma_ast = {version = "0.56.0", path = "../../ecmascript/ast"} -swc_ecma_parser = {version = "0.76.3", path = "../../ecmascript/parser"} -swc_plugin_api = {version = "0.2.0", path = "../api"} +swc_ecma_ast = {version = "0.57.0", path = "../../ecmascript/ast"} +swc_ecma_parser = {version = "0.77.0", path = "../../ecmascript/parser"} +swc_plugin_api = {version = "0.3.0", path = "../api"} [dev-dependencies] -swc_ecma_codegen = {version = "0.78.1", path = "../../ecmascript/codegen"} +swc_ecma_codegen = {version = "0.79.0", path = "../../ecmascript/codegen"} testing = {version = "0.15.0", path = "../../testing"} diff --git a/plugin/testing/Cargo.toml b/plugin/testing/Cargo.toml index 75fa3dec866f..8dcca828b54b 100644 --- a/plugin/testing/Cargo.toml +++ b/plugin/testing/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_plugin_testing" repository = "https://github.com/swc-project/swc.git" -version = "0.17.0" +version = "0.18.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -14,8 +14,8 @@ version = "0.17.0" anyhow = "1.0.41" swc_atoms = {version = "0.2.7", path = "../../atoms"} swc_common = {version = "0.14.0", path = "../../common"} -swc_ecma_ast = {version = "0.56.0", path = "../../ecmascript/ast"} -swc_ecma_codegen = {version = "0.78.1", path = "../../ecmascript/codegen"} -swc_ecma_utils = {version = "0.50.0", path = "../../ecmascript/utils"} -swc_ecma_visit = {version = "0.42.0", path = "../../ecmascript/visit"} -swc_plugin_api = {version = "0.2.0", path = "../api"} +swc_ecma_ast = {version = "0.57.0", path = "../../ecmascript/ast"} +swc_ecma_codegen = {version = "0.79.0", path = "../../ecmascript/codegen"} +swc_ecma_utils = {version = "0.51.0", path = "../../ecmascript/utils"} +swc_ecma_visit = {version = "0.43.0", path = "../../ecmascript/visit"} +swc_plugin_api = {version = "0.3.0", path = "../api"}