Skip to content

Commit

Permalink
refactor: Move HANDLER to swc_common (#2599)
Browse files Browse the repository at this point in the history
swc_common:
 - Add `HANDLER`.

swc_ecma_utils:
 - Replace `HANDLER` with one from `swc_common`.
 - Make `StmtLike` `: Send + Sync`.
  • Loading branch information
kdy1 authored Oct 31, 2021
1 parent cd2a277 commit e589d00
Show file tree
Hide file tree
Showing 31 changed files with 182 additions and 161 deletions.
41 changes: 20 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.80.0"
version = "0.81.0"

[lib]
name = "swc"
Expand Down Expand Up @@ -63,25 +63,25 @@ 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.0", path = "./ecmascript/codegen"}
swc_ecma_ext_transforms = {version = "0.35.0", path = "./ecmascript/ext-transforms"}
swc_ecma_ext_transforms = {version = "0.36.0", path = "./ecmascript/ext-transforms"}
swc_ecma_loader = {version = "0.23.0", path = "./ecmascript/loader", features = ["lru", "node", "tsc"]}
swc_ecma_minifier = {version = "0.47.0", path = "./ecmascript/minifier"}
swc_ecma_minifier = {version = "0.48.0", path = "./ecmascript/minifier"}
swc_ecma_parser = {version = "0.76.0", path = "./ecmascript/parser"}
swc_ecma_preset_env = {version = "0.62.0", path = "./ecmascript/preset-env"}
swc_ecma_transforms = {version = "0.91.0", path = "./ecmascript/transforms", features = [
swc_ecma_preset_env = {version = "0.63.0", path = "./ecmascript/preset-env"}
swc_ecma_transforms = {version = "0.92.0", path = "./ecmascript/transforms", features = [
"compat",
"module",
"optimization",
"proposal",
"react",
"typescript",
]}
swc_ecma_transforms_base = {version = "0.41.0", path = "./ecmascript/transforms/base"}
swc_ecma_transforms_compat = {version = "0.48.0", path = "./ecmascript/transforms/compat"}
swc_ecma_transforms_optimization = {version = "0.61.0", path = "./ecmascript/transforms/optimization"}
swc_ecma_utils = {version = "0.49.0", path = "./ecmascript/utils"}
swc_ecma_transforms_base = {version = "0.42.0", path = "./ecmascript/transforms/base"}
swc_ecma_transforms_compat = {version = "0.49.0", path = "./ecmascript/transforms/compat"}
swc_ecma_transforms_optimization = {version = "0.62.0", 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.83.0", path = "./ecmascript"}
swc_ecmascript = {version = "0.84.0", path = "./ecmascript"}
swc_visit = {version = "0.2.3", path = "./visit"}
tracing = "0.1.28"

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.78.0"
version = "0.79.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
Expand Down Expand Up @@ -42,9 +42,9 @@ swc_ecma_ast = {version = "0.56.0", path = "../ecmascript/ast"}
swc_ecma_codegen = {version = "0.78.0", path = "../ecmascript/codegen"}
swc_ecma_loader = {version = "0.23.0", path = "../ecmascript/loader"}
swc_ecma_parser = {version = "0.76.0", path = "../ecmascript/parser"}
swc_ecma_transforms_base = {version = "0.41.0", path = "../ecmascript/transforms/base"}
swc_ecma_transforms_optimization = {version = "0.61.0", path = "../ecmascript/transforms/optimization"}
swc_ecma_utils = {version = "0.49.0", path = "../ecmascript/utils"}
swc_ecma_transforms_base = {version = "0.42.0", path = "../ecmascript/transforms/base"}
swc_ecma_transforms_optimization = {version = "0.62.0", path = "../ecmascript/transforms/optimization"}
swc_ecma_utils = {version = "0.50.0", path = "../ecmascript/utils"}
swc_ecma_visit = {version = "0.42.0", path = "../ecmascript/visit"}
tracing = "0.1.28"

Expand All @@ -55,9 +55,9 @@ 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.47.0", path = "../ecmascript/minifier"}
swc_ecma_transforms_react = {version = "0.56.0", path = "../ecmascript/transforms/react"}
swc_ecma_transforms_typescript = {version = "0.57.0", path = "../ecmascript/transforms/typescript"}
swc_ecma_minifier = {version = "0.48.0", path = "../ecmascript/minifier"}
swc_ecma_transforms_react = {version = "0.57.0", path = "../ecmascript/transforms/react"}
swc_ecma_transforms_typescript = {version = "0.58.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"}
Expand Down
4 changes: 2 additions & 2 deletions common/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_common"
repository = "https://github.com/swc-project/swc.git"
version = "0.14.2"
version = "0.14.3"

[features]
concurrent = ["parking_lot"]
Expand All @@ -27,7 +27,7 @@ once_cell = "1"
owning_ref = "0.4"
parking_lot = {version = "0.7.1", optional = true}
rustc-hash = "1.1.0"
scoped-tls = {version = "1"}
scoped-tls = "1"
serde = {version = "1.0.119", features = ["derive"]}
sourcemap = {version = "6", optional = true}
string_cache = "0.8.1"
Expand Down
12 changes: 12 additions & 0 deletions common/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use crate::{
sync::{Lock, LockCell, Lrc},
syntax_pos::{BytePos, FileLinesResult, FileName, Loc, MultiSpan, Span, NO_EXPANSION},
};
use scoped_tls::scoped_thread_local;
use std::{
borrow::Cow,
cell::RefCell,
Expand Down Expand Up @@ -825,3 +826,14 @@ impl Level {
}
}
}

scoped_thread_local!(
/// Used for error reporting in transform.
///
/// This should be only used for errors from the api which does not returning errors.
///
/// e.g.
/// - `parser` should not use this.
/// - `transforms` should use this to report error, as it does not return [Result].
pub static HANDLER: Handler
);
10 changes: 5 additions & 5 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.83.0"
version = "0.84.0"

[package.metadata.docs.rs]
all-features = true
Expand Down Expand Up @@ -35,11 +35,11 @@ typescript = ["typescript-parser", "swc_ecma_transforms/typescript"]
swc_ecma_ast = {version = "0.56.0", path = "./ast"}
swc_ecma_codegen = {version = "0.78.0", path = "./codegen", optional = true}
swc_ecma_dep_graph = {version = "0.45.0", path = "./dep-graph", optional = true}
swc_ecma_minifier = {version = "0.47.0", path = "./minifier", optional = true}
swc_ecma_minifier = {version = "0.48.0", path = "./minifier", optional = true}
swc_ecma_parser = {version = "0.76.0", path = "./parser", optional = true, default-features = false}
swc_ecma_preset_env = {version = "0.62.0", path = "./preset-env", optional = true}
swc_ecma_transforms = {version = "0.91.0", path = "./transforms", optional = true}
swc_ecma_utils = {version = "0.49.0", path = "./utils", optional = true}
swc_ecma_preset_env = {version = "0.63.0", path = "./preset-env", optional = true}
swc_ecma_transforms = {version = "0.92.0", 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}

[dev-dependencies]
4 changes: 2 additions & 2 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.35.0"
version = "0.36.0"

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

Expand All @@ -15,5 +15,5 @@ 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.0", path = "../parser"}
swc_ecma_utils = {version = "0.49.0", path = "../utils"}
swc_ecma_utils = {version = "0.50.0", path = "../utils"}
swc_ecma_visit = {version = "0.42.0", path = "../visit"}
8 changes: 4 additions & 4 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.47.1"
version = "0.48.0"

[features]
debug = ["backtrace"]
Expand All @@ -29,9 +29,9 @@ swc_common = {version = "0.14.0", path = "../../common"}
swc_ecma_ast = {version = "0.56.0", path = "../ast"}
swc_ecma_codegen = {version = "0.78.0", path = "../codegen"}
swc_ecma_parser = {version = "0.76.0", path = "../parser"}
swc_ecma_transforms = {version = "0.91.0", path = "../transforms/", features = ["optimization"]}
swc_ecma_transforms_base = {version = "0.41.1", path = "../transforms/base"}
swc_ecma_utils = {version = "0.49.0", path = "../utils"}
swc_ecma_transforms = {version = "0.92.0", path = "../transforms/", features = ["optimization"]}
swc_ecma_transforms_base = {version = "0.42.0", path = "../transforms/base"}
swc_ecma_utils = {version = "0.50.0", path = "../utils"}
swc_ecma_visit = {version = "0.42.0", path = "../visit"}
tracing = "0.1.28"
unicode-xid = "0.2.2"
Expand Down
6 changes: 3 additions & 3 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.62.0"
version = "0.63.0"

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

Expand All @@ -22,8 +22,8 @@ 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.91.0", path = "../transforms", features = ["compat", "proposal"]}
swc_ecma_utils = {version = "0.49.0", path = "../utils"}
swc_ecma_transforms = {version = "0.92.0", path = "../transforms", features = ["compat", "proposal"]}
swc_ecma_utils = {version = "0.50.0", path = "../utils"}
swc_ecma_visit = {version = "0.42.0", path = "../visit"}
walkdir = "2"

Expand Down
Loading

1 comment on commit e589d00

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: e589d00 Previous: cd2a277 Ratio
base_tr_fixer 20917 ns/iter (± 392) 30710 ns/iter (± 2902) 0.68
base_tr_resolver_and_hygiene 114794 ns/iter (± 11309) 179239 ns/iter (± 21849) 0.64
codegen_es2015 45405 ns/iter (± 613) 60230 ns/iter (± 7119) 0.75
codegen_es2016 45477 ns/iter (± 1124) 60557 ns/iter (± 4435) 0.75
codegen_es2017 45860 ns/iter (± 1027) 60380 ns/iter (± 5292) 0.76
codegen_es2018 45461 ns/iter (± 511) 60715 ns/iter (± 6451) 0.75
codegen_es2019 45607 ns/iter (± 678) 60595 ns/iter (± 13848) 0.75
codegen_es2020 45760 ns/iter (± 882) 60532 ns/iter (± 29146) 0.76
codegen_es3 45593 ns/iter (± 309) 59933 ns/iter (± 14447) 0.76
codegen_es5 45829 ns/iter (± 461) 60198 ns/iter (± 10374) 0.76
config_for_file 11525 ns/iter (± 3355) 17239 ns/iter (± 5737) 0.67
full_es2015 178163611 ns/iter (± 21767664) 218418369 ns/iter (± 13398777) 0.82
full_es2016 139232386 ns/iter (± 7415471) 169811367 ns/iter (± 18706662) 0.82
full_es2017 145849208 ns/iter (± 12110757) 190270774 ns/iter (± 27696946) 0.77
full_es2018 145048220 ns/iter (± 21210911) 188796596 ns/iter (± 19802119) 0.77
full_es2019 143232526 ns/iter (± 9198076) 183178825 ns/iter (± 19482599) 0.78
full_es2020 143536403 ns/iter (± 7127984) 173871978 ns/iter (± 15686027) 0.83
full_es3 203782787 ns/iter (± 18180471) 312359868 ns/iter (± 63524717) 0.65
full_es5 177624741 ns/iter (± 19454524) 278389540 ns/iter (± 44617715) 0.64
parser 564430 ns/iter (± 12922) 854072 ns/iter (± 116541) 0.66
transforms_es2015 892438 ns/iter (± 24127) 1546647 ns/iter (± 298716) 0.58
transforms_es2016 536332 ns/iter (± 16422) 867356 ns/iter (± 115821) 0.62
transforms_es2017 525642 ns/iter (± 16194) 855967 ns/iter (± 150834) 0.61
transforms_es2018 519697 ns/iter (± 14519) 852891 ns/iter (± 114185) 0.61
transforms_es2019 505572 ns/iter (± 24105) 845954 ns/iter (± 114860) 0.60
transforms_es2020 497272 ns/iter (± 18421) 847807 ns/iter (± 152507) 0.59
transforms_es3 1029280 ns/iter (± 41539) 1818204 ns/iter (± 246733) 0.57
transforms_es5 892257 ns/iter (± 83387) 1525629 ns/iter (± 310781) 0.58
ser_ast_node 149 ns/iter (± 6) 173 ns/iter (± 19) 0.86
ser_serde 157 ns/iter (± 4) 187 ns/iter (± 27) 0.84
emit_colors 7425664 ns/iter (± 9792034) 20176842 ns/iter (± 26273795) 0.37
emit_large 94608873 ns/iter (± 145818124) 98202241 ns/iter (± 144964565) 0.96
base_clone 2066642 ns/iter (± 35829) 4520902 ns/iter (± 1107733) 0.46
fold_span 3421250 ns/iter (± 27993) 6153242 ns/iter (± 1503449) 0.56
fold_span_panic 3634444 ns/iter (± 52023) 6721957 ns/iter (± 2247958) 0.54
visit_mut_span 2534712 ns/iter (± 38431) 4669386 ns/iter (± 1569751) 0.54
visit_mut_span_panic 2576202 ns/iter (± 40176) 4534011 ns/iter (± 1619750) 0.57
boxing_boxed 125 ns/iter (± 2) 169 ns/iter (± 36) 0.74
boxing_boxed_clone 59 ns/iter (± 1) 76 ns/iter (± 6) 0.78
boxing_unboxed 115 ns/iter (± 0) 161 ns/iter (± 22) 0.71
boxing_unboxed_clone 56 ns/iter (± 0) 73 ns/iter (± 8) 0.77

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.