Skip to content

Commit

Permalink
feat(es/visit): Groundwork to use VisitMut instead of Fold (#1842)
Browse files Browse the repository at this point in the history
swc_ecma_transforms:
 - Expose `VisitMut` if possible.

swc_ecma_visit:
 - Implement `VisitMut` for` Folder<V>`.
 - Implement `VisitMut` for `AndThen<A, B>`.
  • Loading branch information
kdy1 authored Jun 23, 2021
1 parent 6c49279 commit 6ad3f7b
Show file tree
Hide file tree
Showing 38 changed files with 196 additions and 151 deletions.
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc"
repository = "https://github.com/swc-project/swc.git"
version = "0.24.0"
version = "0.24.1"

[lib]
name = "swc"
Expand All @@ -31,20 +31,20 @@ sourcemap = "6"
swc_atoms = {version = "0.2", path = "./atoms"}
swc_common = {version = "0.10.16", path = "./common", features = ["sourcemap", "concurrent"]}
swc_ecma_ast = {version = "0.46.0", path = "./ecmascript/ast"}
swc_ecma_codegen = {version = "0.59.0", path = "./ecmascript/codegen"}
swc_ecma_ext_transforms = {version = "0.18.0", path = "./ecmascript/ext-transforms"}
swc_ecma_parser = {version = "0.60.0", path = "./ecmascript/parser"}
swc_ecma_preset_env = {version = "0.24.0", path = "./ecmascript/preset-env"}
swc_ecma_transforms = {version = "0.54.0", path = "./ecmascript/transforms", features = [
swc_ecma_codegen = {version = "0.59.1", path = "./ecmascript/codegen"}
swc_ecma_ext_transforms = {version = "0.18.1", path = "./ecmascript/ext-transforms"}
swc_ecma_parser = {version = "0.60.2", path = "./ecmascript/parser"}
swc_ecma_preset_env = {version = "0.24.1", path = "./ecmascript/preset-env"}
swc_ecma_transforms = {version = "0.54.1", path = "./ecmascript/transforms", features = [
"compat",
"module",
"optimization",
"proposal",
"react",
"typescript",
]}
swc_ecma_utils = {version = "0.37.0", path = "./ecmascript/utils"}
swc_ecma_visit = {version = "0.32.0", path = "./ecmascript/visit"}
swc_ecma_utils = {version = "0.37.2", path = "./ecmascript/utils"}
swc_ecma_visit = {version = "0.32.1", path = "./ecmascript/visit"}
swc_node_base = {version = "0.1.0", path = "./node/base"}
swc_visit = {version = "0.2.3", path = "./visit"}

Expand Down
14 changes: 7 additions & 7 deletions bundler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.41.0"
version = "0.41.1"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
Expand All @@ -34,18 +34,18 @@ retain_mut = "0.1.2"
swc_atoms = {version = "0.2.4", path = "../atoms"}
swc_common = {version = "0.10.16", path = "../common"}
swc_ecma_ast = {version = "0.46.0", path = "../ecmascript/ast"}
swc_ecma_codegen = {version = "0.59.0", path = "../ecmascript/codegen"}
swc_ecma_parser = {version = "0.60.0", path = "../ecmascript/parser"}
swc_ecma_transforms = {version = "0.54.0", path = "../ecmascript/transforms", features = ["optimization"]}
swc_ecma_utils = {version = "0.37.0", path = "../ecmascript/utils"}
swc_ecma_visit = {version = "0.32.0", path = "../ecmascript/visit"}
swc_ecma_codegen = {version = "0.59.1", path = "../ecmascript/codegen"}
swc_ecma_parser = {version = "0.60.2", path = "../ecmascript/parser"}
swc_ecma_transforms = {version = "0.54.1", path = "../ecmascript/transforms", features = ["optimization"]}
swc_ecma_utils = {version = "0.37.2", path = "../ecmascript/utils"}
swc_ecma_visit = {version = "0.32.1", path = "../ecmascript/visit"}

[dev-dependencies]
hex = "0.4"
ntest = "0.7.2"
reqwest = {version = "0.10.8", features = ["blocking"]}
sha-1 = "0.9"
swc_ecma_transforms = {version = "0.54.0", path = "../ecmascript/transforms", features = ["react", "typescript"]}
swc_ecma_transforms = {version = "0.54.1", path = "../ecmascript/transforms", features = ["react", "typescript"]}
tempfile = "3.1.0"
testing = {version = "0.10.5", path = "../testing"}
url = "2.1.1"
Expand Down
16 changes: 8 additions & 8 deletions ecmascript/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecmascript"
repository = "https://github.com/swc-project/swc.git"
version = "0.40.1"
version = "0.40.2"

[package.metadata.docs.rs]
all-features = true
Expand All @@ -29,12 +29,12 @@ typescript = ["swc_ecma_transforms/typescript"]

[dependencies]
swc_ecma_ast = {version = "0.46.0", path = "./ast"}
swc_ecma_codegen = {version = "0.59.0", path = "./codegen", optional = true}
swc_ecma_dep_graph = {version = "0.28.0", path = "./dep-graph", optional = true}
swc_ecma_minifier = {version = "0.6.0", path = "./minifier", optional = true}
swc_ecma_parser = {version = "0.60.0", path = "./parser", optional = true}
swc_ecma_transforms = {version = "0.54.0", path = "./transforms", optional = true}
swc_ecma_utils = {version = "0.37.1", path = "./utils", optional = true}
swc_ecma_visit = {version = "0.32.0", path = "./visit", optional = true}
swc_ecma_codegen = {version = "0.59.1", path = "./codegen", optional = true}
swc_ecma_dep_graph = {version = "0.28.1", path = "./dep-graph", optional = true}
swc_ecma_minifier = {version = "0.6.1", path = "./minifier", optional = true}
swc_ecma_parser = {version = "0.60.2", path = "./parser", optional = true}
swc_ecma_transforms = {version = "0.54.1", path = "./transforms", optional = true}
swc_ecma_utils = {version = "0.37.2", path = "./utils", optional = true}
swc_ecma_visit = {version = "0.32.1", path = "./visit", optional = true}

[dev-dependencies]
4 changes: 2 additions & 2 deletions ecmascript/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.59.0"
version = "0.59.1"

[dependencies]
bitflags = "1"
Expand All @@ -17,7 +17,7 @@ swc_atoms = {version = "0.2", path = "../../atoms"}
swc_common = {version = "0.10.21", path = "../../common"}
swc_ecma_ast = {version = "0.46.0", path = "../ast"}
swc_ecma_codegen_macros = {version = "0.5.2", path = "./macros"}
swc_ecma_parser = {version = "0.60.0", path = "../parser"}
swc_ecma_parser = {version = "0.60.2", path = "../parser"}

[dev-dependencies]
swc_common = {version = "0.10.16", path = "../../common", features = ["sourcemap"]}
Expand Down
6 changes: 3 additions & 3 deletions ecmascript/dep-graph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.28.0"
version = "0.28.1"

[dependencies]
swc_atoms = {version = "0.2", path = "../../atoms"}
swc_common = {version = "0.10.16", path = "../../common"}
swc_ecma_ast = {version = "0.46.0", path = "../ast"}
swc_ecma_visit = {version = "0.32.0", path = "../visit"}
swc_ecma_visit = {version = "0.32.1", path = "../visit"}

[dev-dependencies]
swc_ecma_parser = {version = "0.60.0", path = "../parser"}
swc_ecma_parser = {version = "0.60.2", path = "../parser"}
testing = {version = "0.10.5", path = "../../testing"}
8 changes: 4 additions & 4 deletions ecmascript/ext-transforms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.18.0"
version = "0.18.1"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -14,6 +14,6 @@ phf = {version = "0.8.0", features = ["macros"]}
swc_atoms = {version = "0.2", path = "../../atoms"}
swc_common = {version = "0.10.16", path = "../../common"}
swc_ecma_ast = {version = "0.46.0", path = "../ast"}
swc_ecma_parser = {version = "0.60.0", path = "../parser"}
swc_ecma_utils = {version = "0.37.0", path = "../utils"}
swc_ecma_visit = {version = "0.32.0", path = "../visit"}
swc_ecma_parser = {version = "0.60.2", path = "../parser"}
swc_ecma_utils = {version = "0.37.2", path = "../utils"}
swc_ecma_visit = {version = "0.32.1", path = "../visit"}
2 changes: 1 addition & 1 deletion ecmascript/ext-transforms/src/jest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static HOIST_METHODS: phf::Set<&str> = phf_set![
"deepUnmock"
];

pub fn jest() -> impl Fold {
pub fn jest() -> impl Fold + VisitMut {
as_folder(Jest)
}

Expand Down
4 changes: 2 additions & 2 deletions ecmascript/jsdoc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ documentation = "https://rustdoc.swc.rs/jsdoc/"
edition = "2018"
license = "Apache-2.0/MIT"
name = "jsdoc"
version = "0.28.0"
version = "0.28.1"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -19,6 +19,6 @@ swc_common = {version = "0.10.16", path = "../../common"}
anyhow = "1"
dashmap = "4.0.2"
swc_ecma_ast = {version = "0.46.0", path = "../ast"}
swc_ecma_parser = {version = "0.60.0", path = "../parser"}
swc_ecma_parser = {version = "0.60.2", path = "../parser"}
testing = {version = "0.10.5", path = "../../testing"}
walkdir = "2"
4 changes: 2 additions & 2 deletions ecmascript/loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_loader"
repository = "https://github.com/swc-project/swc.git"
version = "0.7.0"
version = "0.7.1"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
swc_atoms = {version = "0.2.3", path = "../../atoms"}
swc_common = {version = "0.10.16", path = "../../common"}
swc_ecma_ast = {version = "0.46.0", path = "../ast"}
swc_ecma_visit = {version = "0.32.0", path = "../visit"}
swc_ecma_visit = {version = "0.32.1", path = "../visit"}

[dev-dependencies]
testing = {version = "0.10.5", path = "../../testing"}
14 changes: 7 additions & 7 deletions ecmascript/minifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.6.0"
version = "0.6.1"

[features]
debug = []
Expand All @@ -25,12 +25,12 @@ serde_regex = "1.1.0"
swc_atoms = {version = "0.2", path = "../../atoms"}
swc_common = {version = "0.10.8", path = "../../common"}
swc_ecma_ast = {version = "0.46.0", path = "../ast"}
swc_ecma_codegen = {version = "0.59.0", path = "../codegen"}
swc_ecma_parser = {version = "0.60.0", path = "../parser"}
swc_ecma_transforms = {version = "0.54.0", path = "../transforms/", features = ["optimization"]}
swc_ecma_transforms_base = {version = "0.19.0", path = "../transforms/base"}
swc_ecma_utils = {version = "0.37.0", path = "../utils"}
swc_ecma_visit = {version = "0.32.0", path = "../visit"}
swc_ecma_codegen = {version = "0.59.1", path = "../codegen"}
swc_ecma_parser = {version = "0.60.2", path = "../parser"}
swc_ecma_transforms = {version = "0.54.1", path = "../transforms/", features = ["optimization"]}
swc_ecma_transforms_base = {version = "0.19.1", path = "../transforms/base"}
swc_ecma_utils = {version = "0.37.2", path = "../utils"}
swc_ecma_visit = {version = "0.32.1", path = "../visit"}

[dev-dependencies]
ansi_term = "0.12.1"
Expand Down
2 changes: 1 addition & 1 deletion ecmascript/minifier/src/compress/drop_console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use swc_ecma_visit::noop_visit_mut_type;
use swc_ecma_visit::VisitMut;
use swc_ecma_visit::VisitMutWith;

pub fn drop_console() -> impl JsPass {
pub fn drop_console() -> impl JsPass + VisitMut {
as_folder(DropConsole { done: false })
}

Expand Down
4 changes: 2 additions & 2 deletions ecmascript/parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.60.1"
version = "0.60.2"

[features]
default = []
Expand All @@ -24,7 +24,7 @@ smallvec = "1"
swc_atoms = {version = "0.2.3", path = "../../atoms"}
swc_common = {version = "0.10.16", path = "../../common"}
swc_ecma_ast = {version = "0.46.0", path = "../ast"}
swc_ecma_visit = {version = "0.32.0", path = "../visit"}
swc_ecma_visit = {version = "0.32.1", path = "../visit"}
unicode-xid = "0.2"

[dev-dependencies]
Expand Down
12 changes: 6 additions & 6 deletions ecmascript/preset-env/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.24.0"
version = "0.24.1"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -22,13 +22,13 @@ string_enum = {version = "0.3.1", path = "../../macros/string_enum"}
swc_atoms = {version = "0.2", path = "../../atoms"}
swc_common = {version = "0.10.16", path = "../../common"}
swc_ecma_ast = {version = "0.46.0", path = "../ast"}
swc_ecma_transforms = {version = "0.54.0", path = "../transforms", features = ["compat", "proposal"]}
swc_ecma_utils = {version = "0.37.0", path = "../utils"}
swc_ecma_visit = {version = "0.32.0", path = "../visit"}
swc_ecma_transforms = {version = "0.54.1", path = "../transforms", features = ["compat", "proposal"]}
swc_ecma_utils = {version = "0.37.2", path = "../utils"}
swc_ecma_visit = {version = "0.32.1", path = "../visit"}
walkdir = "2"

[dev-dependencies]
pretty_assertions = "0.6"
swc_ecma_codegen = {version = "0.59.0", path = "../codegen"}
swc_ecma_parser = {version = "0.60.0", path = "../parser"}
swc_ecma_codegen = {version = "0.59.1", path = "../codegen"}
swc_ecma_parser = {version = "0.60.2", path = "../parser"}
testing = {version = "0.10.5", path = "../../testing"}
26 changes: 13 additions & 13 deletions ecmascript/transforms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.54.0"
version = "0.54.1"

[package.metadata.docs.rs]
all-features = true
Expand All @@ -24,23 +24,23 @@ typescript = ["swc_ecma_transforms_typescript"]
swc_atoms = {version = "0.2.0", path = "../../atoms"}
swc_common = {version = "0.10.16", path = "../../common"}
swc_ecma_ast = {version = "0.46.0", path = "../ast"}
swc_ecma_parser = {version = "0.60.0", path = "../parser"}
swc_ecma_transforms_base = {version = "0.19.0", path = "./base"}
swc_ecma_transforms_compat = {version = "0.21.0", path = "./compat", optional = true}
swc_ecma_transforms_module = {version = "0.21.0", path = "./module", optional = true}
swc_ecma_transforms_optimization = {version = "0.24.0", path = "./optimization", optional = true}
swc_ecma_transforms_proposal = {version = "0.21.0", path = "./proposal", optional = true}
swc_ecma_transforms_react = {version = "0.22.0", path = "./react", optional = true}
swc_ecma_transforms_typescript = {version = "0.23.0", path = "./typescript", optional = true}
swc_ecma_utils = {version = "0.37.0", path = "../utils"}
swc_ecma_visit = {version = "0.32.0", path = "../visit"}
swc_ecma_parser = {version = "0.60.2", path = "../parser"}
swc_ecma_transforms_base = {version = "0.19.1", path = "./base"}
swc_ecma_transforms_compat = {version = "0.21.1", path = "./compat", optional = true}
swc_ecma_transforms_module = {version = "0.21.1", path = "./module", optional = true}
swc_ecma_transforms_optimization = {version = "0.24.1", path = "./optimization", optional = true}
swc_ecma_transforms_proposal = {version = "0.21.1", path = "./proposal", optional = true}
swc_ecma_transforms_react = {version = "0.22.1", path = "./react", optional = true}
swc_ecma_transforms_typescript = {version = "0.23.1", path = "./typescript", optional = true}
swc_ecma_utils = {version = "0.37.2", path = "../utils"}
swc_ecma_visit = {version = "0.32.1", path = "../visit"}
unicode-xid = "0.2"

[dev-dependencies]
pretty_assertions = "0.6"
sourcemap = "6"
swc_ecma_codegen = {version = "0.59.0", path = "../codegen"}
swc_ecma_transforms_testing = {version = "0.19.0", path = "./testing"}
swc_ecma_codegen = {version = "0.59.1", path = "../codegen"}
swc_ecma_transforms_testing = {version = "0.19.1", path = "./testing"}
tempfile = "3"
testing = {version = "0.10.5", path = "../../testing"}
walkdir = "2"
10 changes: 5 additions & 5 deletions ecmascript/transforms/base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.19.0"
version = "0.19.1"

[dependencies]
fxhash = "0.2.1"
Expand All @@ -17,10 +17,10 @@ smallvec = "1.6.0"
swc_atoms = {version = "0.2", path = "../../../atoms"}
swc_common = {version = "0.10.16", path = "../../../common"}
swc_ecma_ast = {version = "0.46.0", path = "../../ast"}
swc_ecma_parser = {version = "0.60.0", path = "../../parser"}
swc_ecma_utils = {version = "0.37.0", path = "../../utils"}
swc_ecma_visit = {version = "0.32.0", path = "../../visit"}
swc_ecma_parser = {version = "0.60.2", path = "../../parser"}
swc_ecma_utils = {version = "0.37.2", path = "../../utils"}
swc_ecma_visit = {version = "0.32.1", path = "../../visit"}

[dev-dependencies]
swc_ecma_codegen = {version = "0.59.0", path = "../../codegen"}
swc_ecma_codegen = {version = "0.59.1", path = "../../codegen"}
testing = {version = "0.10.5", path = "../../../testing"}
2 changes: 1 addition & 1 deletion ecmascript/transforms/base/src/fixer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use swc_common::{comments::Comments, Span, Spanned};
use swc_ecma_ast::*;
use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};

pub fn fixer<'a>(comments: Option<&'a dyn Comments>) -> impl 'a + Fold {
pub fn fixer<'a>(comments: Option<&'a dyn Comments>) -> impl 'a + Fold + VisitMut {
as_folder(Fixer {
comments,
ctx: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion ecmascript/transforms/base/src/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ define_helpers!(Helpers {
class_check_private_static_access: (),
});

pub fn inject_helpers() -> impl Fold {
pub fn inject_helpers() -> impl Fold + VisitMut {
as_folder(InjectHelpers)
}

Expand Down
2 changes: 1 addition & 1 deletion ecmascript/transforms/base/src/hygiene/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pub fn hygiene() -> impl Fold + 'static {
hygiene_with_config(Default::default())
}

pub fn hygiene_with_config(config: Config) -> impl Fold + 'static {
pub fn hygiene_with_config(config: Config) -> impl 'static + Fold + VisitMut {
chain!(
as_folder(Hygiene {
config,
Expand Down
4 changes: 2 additions & 2 deletions ecmascript/transforms/base/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn resolver() -> impl 'static + Fold {
/// 5. Found usage of `a` (last line), and determines that it's a
/// reference to top-level `a`, and change syntax context of `a` on last line to
/// top-level syntax context.
pub fn resolver_with_mark(top_level_mark: Mark) -> impl 'static + Fold {
pub fn resolver_with_mark(top_level_mark: Mark) -> impl 'static + Fold + VisitMut {
assert_ne!(
top_level_mark,
Mark::root(),
Expand All @@ -75,7 +75,7 @@ pub fn resolver_with_mark(top_level_mark: Mark) -> impl 'static + Fold {
}

/// [resolver_with_mark] with typescript support enabled.
pub fn ts_resolver(top_level_mark: Mark) -> impl 'static + Fold {
pub fn ts_resolver(top_level_mark: Mark) -> impl 'static + Fold + VisitMut {
assert_ne!(
top_level_mark,
Mark::root(),
Expand Down
Loading

0 comments on commit 6ad3f7b

Please sign in to comment.