From 650e1494d492a4129916b265aa688b1062fad119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Mon, 27 Sep 2021 18:19:15 +0900 Subject: [PATCH] fix: Migrate dependencies (#2307) *: - Migrate from `log` to `tracing`. (#2284) - Migrate from `fxhash` to `rustc-hash`. swc_common: - Add a cargo feature named `debug`. --- Cargo.lock | 248 ++++++++++++------ Cargo.toml | 38 +-- bundler/Cargo.toml | 26 +- bundler/examples/path.rs | 2 +- bundler/src/bundler/chunk/cjs.rs | 6 +- bundler/src/bundler/chunk/merge.rs | 30 +-- bundler/src/bundler/chunk/mod.rs | 8 +- bundler/src/bundler/chunk/plan/mod.rs | 8 +- bundler/src/bundler/chunk/plan/tests.rs | 2 +- bundler/src/bundler/finalize.rs | 2 +- bundler/src/bundler/import/mod.rs | 2 +- bundler/src/bundler/keywords.rs | 2 +- bundler/src/bundler/load.rs | 14 +- bundler/src/bundler/mod.rs | 8 +- bundler/src/inline.rs | 2 +- bundler/src/modules/mod.rs | 2 +- bundler/src/modules/sort/chunk.rs | 8 +- bundler/src/modules/sort/graph.rs | 2 +- bundler/src/modules/sort/mod.rs | 6 +- bundler/src/modules/sort/stmt.rs | 8 +- bundler/src/util/fast_graph.rs | 10 +- common/Cargo.toml | 7 +- common/src/comments.rs | 2 +- common/src/errors/diagnostic_builder.rs | 6 +- common/src/source_map.rs | 34 ++- css/Cargo.toml | 12 +- css/ast/Cargo.toml | 4 +- css/codegen/Cargo.toml | 12 +- css/parser/Cargo.toml | 10 +- css/stylis/Cargo.toml | 16 +- css/utils/Cargo.toml | 8 +- css/visit/Cargo.toml | 6 +- ecmascript/Cargo.toml | 20 +- ecmascript/ast/Cargo.toml | 4 +- ecmascript/codegen/Cargo.toml | 12 +- ecmascript/dep-graph/Cargo.toml | 12 +- ecmascript/ext-transforms/Cargo.toml | 12 +- ecmascript/jsdoc/Cargo.toml | 10 +- ecmascript/loader/Cargo.toml | 14 +- ecmascript/loader/src/resolvers/node.rs | 9 +- ecmascript/minifier/Cargo.toml | 26 +- ecmascript/minifier/src/analyzer/mod.rs | 4 +- .../minifier/src/analyzer/storage/normal.rs | 10 +- .../minifier/src/compress/hoist_decls.rs | 2 +- ecmascript/minifier/src/compress/mod.rs | 32 +-- .../src/compress/optimize/arguments.rs | 6 +- .../minifier/src/compress/optimize/bools.rs | 6 +- .../src/compress/optimize/collapse_vars.rs | 6 +- .../src/compress/optimize/conditionals.rs | 42 +-- .../src/compress/optimize/dead_code.rs | 2 +- .../src/compress/optimize/evaluate.rs | 26 +- .../minifier/src/compress/optimize/fns.rs | 2 +- .../src/compress/optimize/hoist_props.rs | 10 +- .../src/compress/optimize/if_return.rs | 22 +- .../minifier/src/compress/optimize/iife.rs | 46 ++-- .../minifier/src/compress/optimize/inline.rs | 56 ++-- .../src/compress/optimize/join_vars.rs | 2 +- .../minifier/src/compress/optimize/loops.rs | 14 +- .../minifier/src/compress/optimize/mod.rs | 70 ++--- .../minifier/src/compress/optimize/ops.rs | 28 +- .../src/compress/optimize/sequences.rs | 70 ++--- .../minifier/src/compress/optimize/strings.rs | 12 +- .../src/compress/optimize/switches.rs | 10 +- .../minifier/src/compress/optimize/unused.rs | 30 +-- .../minifier/src/compress/pure/arrows.rs | 2 +- .../minifier/src/compress/pure/bools.rs | 40 +-- .../minifier/src/compress/pure/conds.rs | 16 +- .../minifier/src/compress/pure/dead_code.rs | 8 +- .../minifier/src/compress/pure/evaluate.rs | 25 +- .../minifier/src/compress/pure/if_return.rs | 2 +- .../minifier/src/compress/pure/loops.rs | 6 +- ecmascript/minifier/src/compress/pure/misc.rs | 6 +- ecmascript/minifier/src/compress/pure/mod.rs | 2 +- .../minifier/src/compress/pure/numbers.rs | 6 +- .../minifier/src/compress/pure/properties.rs | 9 +- .../minifier/src/compress/pure/sequences.rs | 6 +- .../minifier/src/compress/pure/strings.rs | 12 +- ecmascript/minifier/src/compress/pure/vars.rs | 2 +- ecmascript/minifier/src/compress/util/mod.rs | 24 +- ecmascript/minifier/src/debug.rs | 2 +- ecmascript/minifier/src/eval.rs | 2 +- ecmascript/minifier/src/lib.rs | 8 +- ecmascript/minifier/src/metadata/mod.rs | 14 +- ecmascript/minifier/src/option/mod.rs | 2 +- ecmascript/minifier/src/option/terser.rs | 2 +- ecmascript/minifier/src/pass/global_defs.rs | 2 +- ecmascript/minifier/src/pass/hygiene/vars.rs | 2 +- .../minifier/src/pass/mangle_names/mod.rs | 2 +- .../src/pass/mangle_names/preserver.rs | 2 +- ecmascript/minifier/src/pass/postcompress.rs | 2 +- ecmascript/minifier/src/pass/precompress.rs | 2 +- ecmascript/minifier/src/util/mod.rs | 2 +- ecmascript/minifier/tests/compress.rs | 4 +- ecmascript/parser/Cargo.toml | 16 +- ecmascript/parser/src/lexer/number.rs | 6 +- ecmascript/parser/src/lexer/state.rs | 15 +- ecmascript/parser/src/parser/expr/ops.rs | 33 +-- ecmascript/parser/src/parser/macros.rs | 6 +- ecmascript/preset-env/Cargo.toml | 20 +- ecmascript/preset-env/src/corejs2/entry.rs | 5 +- ecmascript/preset-env/src/corejs2/mod.rs | 5 +- ecmascript/preset-env/src/corejs3/compat.rs | 2 +- ecmascript/preset-env/src/corejs3/entry.rs | 6 +- ecmascript/preset-env/src/corejs3/usage.rs | 5 +- ecmascript/preset-env/src/lib.rs | 2 +- ecmascript/transforms/Cargo.toml | 32 +-- ecmascript/transforms/base/Cargo.toml | 18 +- ecmascript/transforms/base/src/fixer.rs | 2 +- ecmascript/transforms/base/src/hygiene/mod.rs | 2 +- ecmascript/transforms/base/src/hygiene/ops.rs | 2 +- .../transforms/base/src/resolver/mod.rs | 2 +- ecmascript/transforms/classes/Cargo.toml | 12 +- ecmascript/transforms/compat/Cargo.toml | 22 +- .../compat/src/es2015/classes/mod.rs | 6 +- .../compat/src/es2015/duplicate_keys.rs | 2 +- .../es2020/class_properties/private_field.rs | 2 +- ecmascript/transforms/module/Cargo.toml | 24 +- ecmascript/transforms/module/src/amd.rs | 2 +- ecmascript/transforms/module/src/common_js.rs | 2 +- ecmascript/transforms/module/src/umd.rs | 2 +- ecmascript/transforms/module/src/util.rs | 5 +- ecmascript/transforms/optimization/Cargo.toml | 32 +-- .../src/simplify/const_propgation.rs | 2 +- .../optimization/src/simplify/dce/mod.rs | 22 +- .../src/simplify/dce/side_effect.rs | 4 +- .../optimization/src/simplify/inlining/mod.rs | 24 +- .../src/simplify/inlining/scope.rs | 55 ++-- ecmascript/transforms/proposal/Cargo.toml | 28 +- .../proposal/src/decorators/legacy.rs | 2 +- .../src/decorators/legacy/metadata.rs | 2 +- .../proposal/src/private_in_object.rs | 2 +- ecmascript/transforms/react/Cargo.toml | 24 +- ecmascript/transforms/testing/Cargo.toml | 18 +- ecmascript/transforms/typescript/Cargo.toml | 28 +- ecmascript/transforms/typescript/src/strip.rs | 2 +- ecmascript/utils/Cargo.toml | 10 +- ecmascript/visit/Cargo.toml | 6 +- node/base/Cargo.toml | 4 +- node/binding/Cargo.toml | 4 +- node/binding/src/bundle.rs | 2 +- node/binding/src/minify.rs | 2 +- node/bundler/Cargo.toml | 4 +- node/bundler/src/config/mod.rs | 2 +- node/bundler/src/loaders/swc.rs | 10 +- plugin/Cargo.toml | 10 +- plugin/runner/Cargo.toml | 14 +- plugin/testing/Cargo.toml | 14 +- src/lib.rs | 7 +- testing/Cargo.toml | 8 +- testing/src/lib.rs | 49 ++-- 150 files changed, 1076 insertions(+), 965 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 88704e94de7..491b1be9cf8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -246,12 +246,6 @@ version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - [[package]] name = "bytes" version = "1.0.1" @@ -675,15 +669,6 @@ dependencies = [ "slab", ] -[[package]] -name = "fxhash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder", -] - [[package]] name = "generational-arena" version = "0.2.8" @@ -939,7 +924,7 @@ dependencies = [ [[package]] name = "jsdoc" -version = "0.39.0" +version = "0.40.0" dependencies = [ "anyhow", "dashmap", @@ -1045,6 +1030,15 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "matchers" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" +dependencies = [ + "regex-automata", +] + [[package]] name = "matches" version = "0.1.9" @@ -1195,12 +1189,11 @@ version = "0.1.0" dependencies = [ "anyhow", "backtrace", - "fxhash", - "log", "napi", "napi-build", "napi-derive", "path-clean", + "rustc-hash", "serde", "serde_json", "swc", @@ -1212,6 +1205,7 @@ dependencies = [ "swc_ecma_parser", "swc_node_base", "swc_node_bundler", + "tracing", ] [[package]] @@ -1922,6 +1916,15 @@ dependencies = [ "regex-syntax", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax", +] + [[package]] name = "regex-syntax" version = "0.6.25" @@ -1998,6 +2001,12 @@ version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dead70b0b5e03e9c814bcb6b01e03e68f7c57a80aa48c72ec92152ab3e818d49" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc_version" version = "0.2.3" @@ -2155,6 +2164,15 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "sharded-slab" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "740223c51853f3145fe7c90360d2d4232f2b62e3449489c207eccde818979982" +dependencies = [ + "lazy_static", +] + [[package]] name = "siphasher" version = "0.3.6" @@ -2287,20 +2305,19 @@ checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" [[package]] name = "swc" -version = "0.57.0" +version = "0.58.0" dependencies = [ "ahash", "anyhow", "base64 0.13.0", "dashmap", "either", - "fxhash", - "log", "lru", "once_cell", "pathdiff", "rayon", "regex", + "rustc-hash", "serde", "serde_json", "sourcemap", @@ -2322,6 +2339,7 @@ dependencies = [ "swc_node_base", "swc_visit", "testing", + "tracing", "walkdir", ] @@ -2392,17 +2410,15 @@ dependencies = [ [[package]] name = "swc_bundler" -version = "0.60.0" +version = "0.61.0" dependencies = [ "ahash", "anyhow", "crc", "dashmap", - "fxhash", "hex", "indexmap", "is-macro", - "log", "ntest", "once_cell", "petgraph", @@ -2411,6 +2427,7 @@ dependencies = [ "relative-path", "reqwest", "retain_mut", + "rustc-hash", "sha-1", "swc_atoms 0.2.7", "swc_common", @@ -2423,13 +2440,14 @@ dependencies = [ "swc_ecma_visit", "tempfile", "testing", + "tracing", "url", "walkdir", ] [[package]] name = "swc_common" -version = "0.12.2" +version = "0.13.0" dependencies = [ "ahash", "arbitrary", @@ -2438,13 +2456,12 @@ dependencies = [ "cfg-if 0.1.10", "either", "from_variant", - "fxhash", - "log", "num-bigint", "once_cell", "owning_ref", "parking_lot 0.7.1", "rayon", + "rustc-hash", "scoped-tls", "serde", "serde_json", @@ -2453,13 +2470,14 @@ dependencies = [ "swc_eq_ignore_macros", "swc_visit", "termcolor", + "tracing", "unicode-width", "url", ] [[package]] name = "swc_css" -version = "0.6.1" +version = "0.7.0" dependencies = [ "swc_css_ast", "swc_css_codegen", @@ -2470,7 +2488,7 @@ dependencies = [ [[package]] name = "swc_css_ast" -version = "0.5.1" +version = "0.6.0" dependencies = [ "is-macro", "serde", @@ -2481,7 +2499,7 @@ dependencies = [ [[package]] name = "swc_css_codegen" -version = "0.4.0" +version = "0.5.0" dependencies = [ "auto_impl", "bitflags", @@ -2507,7 +2525,7 @@ dependencies = [ [[package]] name = "swc_css_parser" -version = "0.6.4" +version = "0.7.0" dependencies = [ "bitflags", "lexical", @@ -2523,7 +2541,7 @@ dependencies = [ [[package]] name = "swc_css_utils" -version = "0.2.0" +version = "0.3.0" dependencies = [ "swc_atoms 0.2.7", "swc_common", @@ -2533,7 +2551,7 @@ dependencies = [ [[package]] name = "swc_css_visit" -version = "0.4.0" +version = "0.5.0" dependencies = [ "swc_atoms 0.2.7", "swc_common", @@ -2543,7 +2561,7 @@ dependencies = [ [[package]] name = "swc_ecma_ast" -version = "0.52.0" +version = "0.53.0" dependencies = [ "arbitrary", "is-macro", @@ -2557,7 +2575,7 @@ dependencies = [ [[package]] name = "swc_ecma_codegen" -version = "0.71.0" +version = "0.72.0" dependencies = [ "bitflags", "num-bigint", @@ -2583,7 +2601,7 @@ dependencies = [ [[package]] name = "swc_ecma_dep_graph" -version = "0.40.0" +version = "0.41.0" dependencies = [ "swc_atoms 0.2.7", "swc_common", @@ -2595,7 +2613,7 @@ dependencies = [ [[package]] name = "swc_ecma_ext_transforms" -version = "0.29.0" +version = "0.30.0" dependencies = [ "phf", "swc_atoms 0.2.7", @@ -2608,16 +2626,15 @@ dependencies = [ [[package]] name = "swc_ecma_loader" -version = "0.18.2" +version = "0.19.0" dependencies = [ "anyhow", "dashmap", - "fxhash", - "log", "lru", "normpath", "once_cell", "regex", + "rustc-hash", "serde", "serde_json", "swc_atoms 0.2.7", @@ -2625,22 +2642,22 @@ dependencies = [ "swc_ecma_ast", "swc_ecma_visit", "testing", + "tracing", ] [[package]] name = "swc_ecma_minifier" -version = "0.29.0" +version = "0.30.0" dependencies = [ "ansi_term 0.12.1", "anyhow", - "fxhash", "indexmap", - "log", "once_cell", "pretty_assertions 0.6.1", "rayon", "regex", "retain_mut", + "rustc-hash", "serde", "serde_json", "serde_regex", @@ -2655,22 +2672,22 @@ dependencies = [ "swc_ecma_visit", "swc_node_base", "testing", + "tracing", "unicode-xid", "walkdir", ] [[package]] name = "swc_ecma_parser" -version = "0.71.0" +version = "0.72.0" dependencies = [ "either", "enum_kind", "env_logger 0.7.1", - "fxhash", "lexical", - "log", "num-bigint", "pretty_assertions 0.6.1", + "rustc-hash", "serde", "serde_json", "smallvec 1.6.1", @@ -2680,19 +2697,20 @@ dependencies = [ "swc_ecma_visit", "swc_node_base", "testing", + "tracing", "unicode-xid", "walkdir", ] [[package]] name = "swc_ecma_preset_env" -version = "0.44.0" +version = "0.45.0" dependencies = [ "dashmap", - "fxhash", "indexmap", "once_cell", "pretty_assertions 0.6.1", + "rustc-hash", "semver", "serde", "serde_json", @@ -2712,7 +2730,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms" -version = "0.73.0" +version = "0.74.0" dependencies = [ "pretty_assertions 0.6.1", "sourcemap", @@ -2739,11 +2757,11 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_base" -version = "0.32.0" +version = "0.33.0" dependencies = [ - "fxhash", "once_cell", "phf", + "rustc-hash", "scoped-tls", "smallvec 1.6.1", "swc_atoms 0.2.7", @@ -2758,7 +2776,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_classes" -version = "0.18.0" +version = "0.19.0" dependencies = [ "swc_atoms 0.2.7", "swc_common", @@ -2770,14 +2788,14 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_compat" -version = "0.36.0" +version = "0.37.0" dependencies = [ "arrayvec", - "fxhash", "indexmap", "is-macro", "num-bigint", "ordered-float", + "rustc-hash", "serde", "smallvec 1.6.1", "swc_atoms 0.2.7", @@ -2806,13 +2824,13 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_module" -version = "0.40.0" +version = "0.41.0" dependencies = [ "Inflector", "anyhow", - "fxhash", "indexmap", "pathdiff", + "rustc-hash", "serde", "swc_atoms 0.2.7", "swc_common", @@ -2829,14 +2847,13 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_optimization" -version = "0.43.0" +version = "0.44.0" dependencies = [ "dashmap", - "fxhash", "indexmap", - "log", "once_cell", "retain_mut", + "rustc-hash", "serde_json", "swc_atoms 0.2.7", "swc_common", @@ -2852,14 +2869,15 @@ dependencies = [ "swc_ecma_utils", "swc_ecma_visit", "testing", + "tracing", ] [[package]] name = "swc_ecma_transforms_proposal" -version = "0.40.0" +version = "0.41.0" dependencies = [ "either", - "fxhash", + "rustc-hash", "serde", "serde_json", "smallvec 1.6.1", @@ -2881,7 +2899,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_react" -version = "0.41.0" +version = "0.42.0" dependencies = [ "base64 0.13.0", "dashmap", @@ -2907,7 +2925,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_testing" -version = "0.33.0" +version = "0.34.0" dependencies = [ "ansi_term 0.12.1", "anyhow", @@ -2926,9 +2944,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_typescript" -version = "0.42.0" +version = "0.43.0" dependencies = [ - "fxhash", + "rustc-hash", "serde", "swc_atoms 0.2.7", "swc_common", @@ -2948,7 +2966,7 @@ dependencies = [ [[package]] name = "swc_ecma_utils" -version = "0.44.2" +version = "0.45.0" dependencies = [ "once_cell", "scoped-tls", @@ -2962,7 +2980,7 @@ dependencies = [ [[package]] name = "swc_ecma_visit" -version = "0.38.1" +version = "0.39.0" dependencies = [ "num-bigint", "swc_atoms 0.2.7", @@ -2973,7 +2991,7 @@ dependencies = [ [[package]] name = "swc_ecmascript" -version = "0.65.0" +version = "0.66.0" dependencies = [ "swc_ecma_ast", "swc_ecma_codegen", @@ -3008,7 +3026,7 @@ dependencies = [ [[package]] name = "swc_node_base" -version = "0.3.0" +version = "0.4.0" dependencies = [ "dashmap", "mimalloc-rust", @@ -3021,13 +3039,12 @@ version = "0.0.0" dependencies = [ "anyhow", "dashmap", - "fxhash", "is-macro", - "log", "once_cell", "pretty_assertions 0.6.1", "pretty_env_logger", "regex", + "rustc-hash", "serde", "serde_json", "string_enum", @@ -3045,12 +3062,13 @@ dependencies = [ "swc_node_base", "tempfile", "testing", + "tracing", "walkdir", ] [[package]] name = "swc_plugin" -version = "0.4.1" +version = "0.5.0" dependencies = [ "abi_stable", "anyhow", @@ -3065,7 +3083,7 @@ dependencies = [ [[package]] name = "swc_plugin_runner" -version = "0.5.0" +version = "0.6.0" dependencies = [ "abi_stable", "anyhow", @@ -3083,7 +3101,7 @@ dependencies = [ [[package]] name = "swc_plugin_testing" -version = "0.5.0" +version = "0.6.0" dependencies = [ "anyhow", "swc_atoms 0.2.7", @@ -3097,7 +3115,7 @@ dependencies = [ [[package]] name = "swc_stylis" -version = "0.3.0" +version = "0.4.0" dependencies = [ "swc_atoms 0.2.7", "swc_common", @@ -3165,17 +3183,17 @@ dependencies = [ [[package]] name = "testing" -version = "0.13.1" +version = "0.14.0" dependencies = [ "ansi_term 0.12.1", "difference", - "env_logger 0.7.1", - "log", "once_cell", "pretty_assertions 0.7.2", "regex", "swc_common", "testing_macros", + "tracing", + "tracing-subscriber", ] [[package]] @@ -3192,6 +3210,15 @@ dependencies = [ "syn", ] +[[package]] +name = "thread_local" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" +dependencies = [ + "once_cell", +] + [[package]] name = "time" version = "0.1.43" @@ -3283,24 +3310,79 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.26" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" +checksum = "84f96e095c0c82419687c20ddf5cb3eadb61f4e1405923c9dc8e53a1adacbda8" dependencies = [ "cfg-if 1.0.0", "pin-project-lite", + "tracing-attributes", "tracing-core", ] [[package]] -name = "tracing-core" -version = "0.1.18" +name = "tracing-attributes" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" +checksum = "98863d0dd09fa59a1b79c6750ad80dbda6b75f4e71c437a6a1a8cb91a8bcbd77" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46125608c26121c81b0c6d693eab5a420e416da7e43c426d2e8f7df8da8a3acf" dependencies = [ "lazy_static", ] +[[package]] +name = "tracing-log" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdd0568dbfe3baf7048b7908d2b32bca0d81cd56bec6d2a8f894b01d74f86be3" +dependencies = [ + "ansi_term 0.12.1", + "chrono", + "lazy_static", + "matchers", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec 1.6.1", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", +] + [[package]] name = "try-lock" version = "0.2.3" diff --git a/Cargo.toml b/Cargo.toml index 898994ad89a..0805ced4080 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc" repository = "https://github.com/swc-project/swc.git" -version = "0.57.0" +version = "0.58.0" [lib] name = "swc" @@ -43,26 +43,25 @@ anyhow = "1" base64 = "0.13.0" dashmap = "4.0.2" either = "1" -fxhash = "0.2.1" -log = "0.4" lru = "0.6.1" once_cell = "1" pathdiff = "0.2.0" regex = "1" +rustc-hash = "1.1.0" serde = {version = "1", features = ["derive"]} serde_json = "1" sourcemap = "6" swc_atoms = {version = "0.2", path = "./atoms"} -swc_bundler = {version = "0.60.0", path = "./bundler"} -swc_common = {version = "0.12.1", path = "./common", features = ["sourcemap", "concurrent"]} -swc_ecma_ast = {version = "0.52.0", path = "./ecmascript/ast"} -swc_ecma_codegen = {version = "0.71.0", path = "./ecmascript/codegen"} -swc_ecma_ext_transforms = {version = "0.29.0", path = "./ecmascript/ext-transforms"} -swc_ecma_loader = {version = "0.18.1", path = "./ecmascript/loader", features = ["lru", "node", "tsc"]} -swc_ecma_minifier = {version = "0.29.0", path = "./ecmascript/minifier"} -swc_ecma_parser = {version = "0.71.0", path = "./ecmascript/parser"} -swc_ecma_preset_env = {version = "0.44.0", path = "./ecmascript/preset-env"} -swc_ecma_transforms = {version = "0.73.0", path = "./ecmascript/transforms", features = [ +swc_bundler = {version = "0.61.0", path = "./bundler"} +swc_common = {version = "0.13.0", path = "./common", features = ["sourcemap", "concurrent"]} +swc_ecma_ast = {version = "0.53.0", path = "./ecmascript/ast"} +swc_ecma_codegen = {version = "0.72.0", path = "./ecmascript/codegen"} +swc_ecma_ext_transforms = {version = "0.30.0", path = "./ecmascript/ext-transforms"} +swc_ecma_loader = {version = "0.19.0", path = "./ecmascript/loader", features = ["lru", "node", "tsc"]} +swc_ecma_minifier = {version = "0.30.0", path = "./ecmascript/minifier"} +swc_ecma_parser = {version = "0.72.0", path = "./ecmascript/parser"} +swc_ecma_preset_env = {version = "0.45.0", path = "./ecmascript/preset-env"} +swc_ecma_transforms = {version = "0.74.0", path = "./ecmascript/transforms", features = [ "compat", "module", "optimization", @@ -70,16 +69,17 @@ swc_ecma_transforms = {version = "0.73.0", path = "./ecmascript/transforms", fea "react", "typescript", ]} -swc_ecma_transforms_base = {version = "0.32.0", path = "./ecmascript/transforms/base"} -swc_ecma_utils = {version = "0.44.2", path = "./ecmascript/utils"} -swc_ecma_visit = {version = "0.38.1", path = "./ecmascript/visit"} -swc_ecmascript = {version = "0.65.0", path = "./ecmascript"} +swc_ecma_transforms_base = {version = "0.33.0", path = "./ecmascript/transforms/base"} +swc_ecma_utils = {version = "0.45.0", path = "./ecmascript/utils"} +swc_ecma_visit = {version = "0.39.0", path = "./ecmascript/visit"} +swc_ecmascript = {version = "0.66.0", path = "./ecmascript"} swc_visit = {version = "0.2.3", path = "./visit"} +tracing = "0.1.28" [dev-dependencies] rayon = "1" -swc_node_base = {version = "0.3.0", path = "./node/base"} -testing = {version = "0.13.0", path = "./testing"} +swc_node_base = {version = "0.4.0", path = "./node/base"} +testing = {version = "0.14.0", path = "./testing"} walkdir = "2" [[example]] diff --git a/bundler/Cargo.toml b/bundler/Cargo.toml index 38f66e0ecd1..7a285ad05c5 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.60.0" +version = "0.61.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] @@ -21,33 +21,33 @@ ahash = "0.7" anyhow = "1" crc = "1.8" dashmap = {version = "4.0.2", optional = true} -fxhash = "0.2" indexmap = "1.6" is-macro = "0.1" -log = "0.4" once_cell = "1" petgraph = "0.5" radix_fmt = "1" rayon = {version = "1", optional = true} relative-path = "1.2" retain_mut = "0.1.2" +rustc-hash = "1.1.0" swc_atoms = {version = "0.2.4", path = "../atoms"} -swc_common = {version = "0.12.0", path = "../common"} -swc_ecma_ast = {version = "0.52.0", path = "../ecmascript/ast"} -swc_ecma_codegen = {version = "0.71.0", path = "../ecmascript/codegen"} -swc_ecma_loader = {version = "0.18.1", path = "../ecmascript/loader"} -swc_ecma_parser = {version = "0.71.0", path = "../ecmascript/parser"} -swc_ecma_transforms = {version = "0.73.0", path = "../ecmascript/transforms", features = ["optimization"]} -swc_ecma_utils = {version = "0.44.2", path = "../ecmascript/utils"} -swc_ecma_visit = {version = "0.38.1", path = "../ecmascript/visit"} +swc_common = {version = "0.13.0", path = "../common"} +swc_ecma_ast = {version = "0.53.0", path = "../ecmascript/ast"} +swc_ecma_codegen = {version = "0.72.0", path = "../ecmascript/codegen"} +swc_ecma_loader = {version = "0.19.0", path = "../ecmascript/loader"} +swc_ecma_parser = {version = "0.72.0", path = "../ecmascript/parser"} +swc_ecma_transforms = {version = "0.74.0", path = "../ecmascript/transforms", features = ["optimization"]} +swc_ecma_utils = {version = "0.45.0", path = "../ecmascript/utils"} +swc_ecma_visit = {version = "0.39.0", path = "../ecmascript/visit"} +tracing = "0.1.28" [dev-dependencies] hex = "0.4" ntest = "0.7.2" reqwest = {version = "0.11.4", features = ["blocking"]} sha-1 = "0.9" -swc_ecma_transforms = {version = "0.73.0", path = "../ecmascript/transforms", features = ["react", "typescript"]} +swc_ecma_transforms = {version = "0.74.0", path = "../ecmascript/transforms", features = ["react", "typescript"]} tempfile = "3.1.0" -testing = {version = "0.13.0", path = "../testing"} +testing = {version = "0.14.0", path = "../testing"} url = "2.1.1" walkdir = "2" diff --git a/bundler/examples/path.rs b/bundler/examples/path.rs index 66f5cd969d0..f60303188c3 100644 --- a/bundler/examples/path.rs +++ b/bundler/examples/path.rs @@ -7,7 +7,7 @@ use swc_ecma_codegen::{text_writer::JsWriter, Emitter}; use swc_ecma_parser::{lexer::Lexer, EsConfig, Parser, StringInput, Syntax}; fn main() { - testing::init(); + let _log = testing::init(); let globals = Globals::new(); let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); diff --git a/bundler/src/bundler/chunk/cjs.rs b/bundler/src/bundler/chunk/cjs.rs index 552d7f57fb3..056df7dc194 100644 --- a/bundler/src/bundler/chunk/cjs.rs +++ b/bundler/src/bundler/chunk/cjs.rs @@ -55,7 +55,7 @@ where return Ok(module); } - log::debug!("Merging as a common js module: {}", info.fm.name); + tracing::debug!("Merging as a common js module: {}", info.fm.name); let load_var = self.make_cjs_load_var(info, DUMMY_SP); @@ -81,7 +81,7 @@ where self.injected_ctxt, ); - log::debug!("Injected a variable named `load` for a common js module"); + tracing::debug!("Injected a variable named `load` for a common js module"); Ok(wrapped) } @@ -198,7 +198,7 @@ where self.replaced = true; *node = load.clone(); - log::trace!("Found, and replacing require"); + tracing::trace!("Found, and replacing require"); } _ => {} } diff --git a/bundler/src/bundler/chunk/merge.rs b/bundler/src/bundler/chunk/merge.rs index 4fb5c101e34..fea3e7cd74e 100644 --- a/bundler/src/bundler/chunk/merge.rs +++ b/bundler/src/bundler/chunk/merge.rs @@ -13,12 +13,12 @@ use crate::{ Bundler, Hook, ModuleRecord, }; use anyhow::Error; -use fxhash::{FxBuildHasher, FxHashMap, FxHashSet}; use indexmap::IndexSet; use petgraph::EdgeDirection; #[cfg(feature = "concurrent")] use rayon::iter::ParallelIterator; -use std::sync::atomic::Ordering; +use rustc_hash::{FxHashMap, FxHashSet, FxHasher}; +use std::{hash::BuildHasherDefault, sync::atomic::Ordering}; use swc_atoms::js_word; use swc_common::{sync::Lock, FileName, SyntaxContext, DUMMY_SP}; use swc_ecma_ast::*; @@ -100,7 +100,7 @@ where let all_deps_of_entry = self.collect_all_deps(&ctx.graph, entry_id, &mut Default::default()); - log::debug!("Merging dependenciess: {:?}", all_deps_of_entry); + tracing::debug!("Merging dependenciess: {:?}", all_deps_of_entry); let deps = all_deps_of_entry.iter().map(|id| { let dep_info = self.scope.get_module(*id).unwrap(); @@ -134,7 +134,7 @@ where graph: &ModuleGraph, start: ModuleId, dejavu: &mut FxHashSet, - ) -> IndexSet { + ) -> IndexSet> { let mut set = IndexSet::default(); for dep in graph.neighbors_directed(start, Outgoing) { @@ -405,14 +405,14 @@ where } fn finalize_merging_of_entry(&self, ctx: &Ctx, id: ModuleId, entry: &mut Modules) { - log::trace!("All modules are merged"); + tracing::trace!("All modules are merged"); - log::debug!("Injecting reexports"); + tracing::debug!("Injecting reexports"); self.inject_reexports(ctx, id, entry); // entry.print(&self.cm, "before inline"); - log::debug!("Inlining injected variables"); + tracing::debug!("Inlining injected variables"); inline(self.injected_ctxt, entry); @@ -460,7 +460,7 @@ where true }); - log::debug!("Renaming keywords"); + tracing::debug!("Renaming keywords"); entry.visit_mut_with(&mut KeywordRenamer::default()); @@ -476,10 +476,10 @@ where /// Remove exports with wrong syntax context fn remove_wrong_exports(&self, ctx: &Ctx, info: &TransformedModule, module: &mut Modules) { - log::debug!("Removing wrong exports"); + tracing::debug!("Removing wrong exports"); let item_count = module.iter().count(); - log::trace!("Item count = {}", item_count); + tracing::trace!("Item count = {}", item_count); module.retain_mut(|_, item| { match item { @@ -513,7 +513,7 @@ where true }); - log::debug!("Removed wrong exports"); + tracing::debug!("Removed wrong exports"); } /// This method handles imports and exports. @@ -720,7 +720,7 @@ where } // Create `export { local_default as default }` - log::trace!( + tracing::trace!( "Exporting `default` with `export default decl` ({})", local.sym ); @@ -786,7 +786,7 @@ where orig: local, exported: Some(exported), }); - log::trace!("Exporting `default` with `export default expr`"); + tracing::trace!("Exporting `default` with `export default expr`"); extra.push(ModuleItem::ModuleDecl(ModuleDecl::ExportNamed( NamedExport { span: export.span.with_ctxt(injected_ctxt), @@ -832,7 +832,7 @@ where id.span.with_ctxt(info.export_ctxt()), ); - log::trace!( + tracing::trace!( "Exporting `{}{:?}` with `export decl`", id.sym, id.span.ctxt @@ -869,7 +869,7 @@ where | Decl::TsModule(_) => continue, }; - log::trace!( + tracing::trace!( "Exporting `default` with `export default decl` ({})", local.sym ); diff --git a/bundler/src/bundler/chunk/mod.rs b/bundler/src/bundler/chunk/mod.rs index 32f85c338e0..9e74b9e0068 100644 --- a/bundler/src/bundler/chunk/mod.rs +++ b/bundler/src/bundler/chunk/mod.rs @@ -5,9 +5,9 @@ use crate::{ }; use ahash::AHashMap; use anyhow::{Context, Error}; -use fxhash::{FxHashMap, FxHashSet}; #[cfg(feature = "rayon")] use rayon::iter::ParallelIterator; +use rustc_hash::{FxHashMap, FxHashSet}; use std::time::Instant; mod cjs; @@ -47,7 +47,7 @@ where let start = Instant::now(); let (plan, graph, cycles) = self.determine_entries(entries).context("failed to plan")?; let dur = Instant::now() - start; - log::debug!("Dependency analysis took {:?}", dur); + tracing::debug!("Dependency analysis took {:?}", dur); if cfg!(debug_assertions) { for (i, id1) in plan.all.iter().enumerate() { @@ -87,7 +87,7 @@ where .collect::, _>>()?; let dur = Instant::now() - start; - log::debug!("Module preparation took {:?}", dur); + tracing::debug!("Module preparation took {:?}", dur); let entries = all .iter() @@ -104,7 +104,7 @@ where .map(|(id, mut entry)| { self.merge_into_entry(&ctx, id, &mut entry, &all); - log::debug!("Merged `{}` and it's dep into an entry", id); + tracing::debug!("Merged `{}` and it's dep into an entry", id); (id, entry) }) diff --git a/bundler/src/bundler/chunk/plan/mod.rs b/bundler/src/bundler/chunk/plan/mod.rs index f2e4a3170ff..105b177edbc 100644 --- a/bundler/src/bundler/chunk/plan/mod.rs +++ b/bundler/src/bundler/chunk/plan/mod.rs @@ -4,7 +4,7 @@ use crate::{ }; use ahash::AHashMap; use anyhow::{bail, Error}; -use fxhash::{FxHashMap, FxHashSet}; +use rustc_hash::{FxHashMap, FxHashSet}; #[cfg(test)] mod tests; @@ -68,7 +68,7 @@ where path: &mut Vec, ) { if cfg!(test) { - log::debug!("Adding {:?} to the graph (path = {:?})", module_id, path); + tracing::debug!("Adding {:?} to the graph (path = {:?})", module_id, path); } let visited = builder.all.contains(&module_id); // dbg!(visited); @@ -81,7 +81,7 @@ where if let Some(rpos) = cycle_rpos { let cycle = path[rpos..].to_vec(); - log::debug!("Found cycle: {:?}", cycle); + tracing::debug!("Found cycle: {:?}", cycle); builder.cycles.push(cycle); } @@ -109,7 +109,7 @@ where .iter() .chain(m.exports.reexports.iter()) { - log::debug!("Dep: {} -> {}", module_id, src.module_id); + tracing::debug!("Dep: {} -> {}", module_id, src.module_id); builder.graph.add_edge(module_id, src.module_id, ()); diff --git a/bundler/src/bundler/chunk/plan/tests.rs b/bundler/src/bundler/chunk/plan/tests.rs index 6b0ea8a9d99..aef5dcdabfc 100644 --- a/bundler/src/bundler/chunk/plan/tests.rs +++ b/bundler/src/bundler/chunk/plan/tests.rs @@ -1,6 +1,6 @@ use crate::bundler::tests::suite; use ahash::AHashMap; -use fxhash::{FxHashMap, FxHashSet}; +use rustc_hash::{FxHashMap, FxHashSet}; use std::collections::HashMap; fn assert_cycles(map: FxHashMap, cycle_entries: Vec<&str>) { diff --git a/bundler/src/bundler/finalize.rs b/bundler/src/bundler/finalize.rs index b748d5087e3..58abf7f8157 100644 --- a/bundler/src/bundler/finalize.rs +++ b/bundler/src/bundler/finalize.rs @@ -115,7 +115,7 @@ where let path = match self.scope.get_module(bundle.id).unwrap().fm.name { FileName::Real(ref v) => v.clone(), _ => { - log::error!("Cannot rename: not a real file"); + tracing::error!("Cannot rename: not a real file"); return bundle; } }; diff --git a/bundler/src/bundler/import/mod.rs b/bundler/src/bundler/import/mod.rs index e61a2cbcb85..c6923deee18 100644 --- a/bundler/src/bundler/import/mod.rs +++ b/bundler/src/bundler/import/mod.rs @@ -1,8 +1,8 @@ use super::Bundler; use crate::{load::Load, resolve::Resolve}; use anyhow::{Context, Error}; -use fxhash::{FxHashMap, FxHashSet}; use retain_mut::RetainMut; +use rustc_hash::{FxHashMap, FxHashSet}; use swc_atoms::{js_word, JsWord}; use swc_common::{sync::Lrc, FileName, Mark, Spanned, SyntaxContext, DUMMY_SP}; use swc_ecma_ast::*; diff --git a/bundler/src/bundler/keywords.rs b/bundler/src/bundler/keywords.rs index 900dde0cbc6..69ba09b03ef 100644 --- a/bundler/src/bundler/keywords.rs +++ b/bundler/src/bundler/keywords.rs @@ -1,5 +1,5 @@ use crate::id::Id; -use fxhash::FxHashMap; +use rustc_hash::FxHashMap; use swc_atoms::js_word; use swc_common::util::take::Take; use swc_ecma_ast::*; diff --git a/bundler/src/bundler/load.rs b/bundler/src/bundler/load.rs index 840ea87d786..795f6a2f2a4 100644 --- a/bundler/src/bundler/load.rs +++ b/bundler/src/bundler/load.rs @@ -66,11 +66,11 @@ where file_name: &FileName, ) -> Result, Error> { self.run(|| { - log::trace!("load_transformed: ({})", file_name); + tracing::trace!("load_transformed: ({})", file_name); // In case of common module if let Some(cached) = self.scope.get_module_by_path(&file_name) { - log::debug!("Cached: {}", file_name); + tracing::debug!("Cached: {}", file_name); return Ok(Some(cached)); } @@ -80,7 +80,7 @@ where .context("failed to analyze module")?; files.dedup_by_key(|v| v.1.clone()); - log::debug!( + tracing::debug!( "({:?}, {:?}, {:?}) Storing module: {}", v.id, v.local_ctxt(), @@ -93,7 +93,7 @@ where let results = files .into_par_iter() .map(|(_src, path)| { - log::trace!("loading dependency: {}", path); + tracing::trace!("loading dependency: {}", path); self.load_transformed(&path) }) .collect::>(); @@ -127,7 +127,7 @@ where data: ModuleData, ) -> Result<(TransformedModule, Vec<(Source, Lrc)>), Error> { self.run(|| { - log::trace!("transform_module({})", data.fm.name); + tracing::trace!("transform_module({})", data.fm.name); let (id, local_mark, export_mark) = self.scope.module_id_gen.gen(file_name); let mut module = data.module.fold_with(&mut resolver_with_mark(local_mark)); @@ -216,7 +216,7 @@ where raw: RawExports, ) -> Result<(Exports, Vec<(Source, Lrc)>), Error> { self.run(|| { - log::trace!("resolve_exports({})", base); + tracing::trace!("resolve_exports({})", base); let mut files = vec![]; let mut exports = Exports::default(); @@ -273,7 +273,7 @@ where info: RawImports, ) -> Result<(Imports, Vec<(Source, Lrc)>), Error> { self.run(|| { - log::trace!("resolve_imports({})", base); + tracing::trace!("resolve_imports({})", base); let mut files = vec![]; let mut merged = Imports::default(); diff --git a/bundler/src/bundler/mod.rs b/bundler/src/bundler/mod.rs index 49a77f9f855..841a8a9bb96 100644 --- a/bundler/src/bundler/mod.rs +++ b/bundler/src/bundler/mod.rs @@ -112,13 +112,13 @@ where ) -> Self { GLOBALS.set(&globals, || { let used_mark = Mark::fresh(Mark::root()); - log::debug!("Used mark: {:?}", DUMMY_SP.apply_mark(used_mark).ctxt()); + tracing::debug!("Used mark: {:?}", DUMMY_SP.apply_mark(used_mark).ctxt()); let helper_ctxt = SyntaxContext::empty().apply_mark(Mark::fresh(Mark::root())); - log::debug!("Helper ctxt: {:?}", helper_ctxt); + tracing::debug!("Helper ctxt: {:?}", helper_ctxt); let synthesized_ctxt = SyntaxContext::empty().apply_mark(Mark::fresh(Mark::root())); - log::debug!("Synthesized ctxt: {:?}", synthesized_ctxt); + tracing::debug!("Synthesized ctxt: {:?}", synthesized_ctxt); let injected_ctxt = SyntaxContext::empty().apply_mark(Mark::fresh(Mark::root())); - log::debug!("Injected ctxt: {:?}", injected_ctxt); + tracing::debug!("Injected ctxt: {:?}", injected_ctxt); Bundler { config, diff --git a/bundler/src/inline.rs b/bundler/src/inline.rs index 14440d1d0aa..f15239399fa 100644 --- a/bundler/src/inline.rs +++ b/bundler/src/inline.rs @@ -12,7 +12,7 @@ pub(crate) struct InlineData { /// Inline **injected** variables. pub(crate) fn inline(injected_ctxt: SyntaxContext, module: &mut Modules) { - log::debug!("Inlining injected variables"); + tracing::debug!("Inlining injected variables"); let mut v = Inliner { injected_ctxt, diff --git a/bundler/src/modules/mod.rs b/bundler/src/modules/mod.rs index c6ff6063571..04744047ccb 100644 --- a/bundler/src/modules/mod.rs +++ b/bundler/src/modules/mod.rs @@ -1,6 +1,6 @@ use crate::ModuleId; -use fxhash::FxHashMap; use retain_mut::RetainMut; +use rustc_hash::FxHashMap; use std::mem::take; use swc_common::{SourceMap, SyntaxContext, DUMMY_SP}; use swc_ecma_ast::*; diff --git a/bundler/src/modules/sort/chunk.rs b/bundler/src/modules/sort/chunk.rs index 4359ac37d1f..c8bce858ed5 100644 --- a/bundler/src/modules/sort/chunk.rs +++ b/bundler/src/modules/sort/chunk.rs @@ -1,8 +1,8 @@ use super::stmt::sort_stmts; use crate::{dep_graph::ModuleGraph, modules::Modules, ModuleId}; -use fxhash::FxHashSet; use indexmap::IndexSet; use petgraph::EdgeDirection::Outgoing; +use rustc_hash::FxHashSet; use std::{collections::VecDeque, iter::from_fn, mem::take, time::Instant}; use swc_common::{sync::Lrc, SourceMap, SyntaxContext}; use swc_ecma_ast::*; @@ -65,7 +65,7 @@ fn toposort_real_modules<'a>( let mut chunks = vec![]; - log::debug!( + tracing::debug!( "Topologically sorting modules based on the dependency graph: ({} items)", modules.len() ); @@ -73,7 +73,7 @@ fn toposort_real_modules<'a>( let start = Instant::now(); let sorted_ids = toposort_real_module_ids(queue, graph, &cycles).collect::>(); let end = Instant::now(); - log::debug!("Toposort of module ids took {:?}", end - start); + tracing::debug!("Toposort of module ids took {:?}", end - start); for ids in sorted_ids { if ids.is_empty() { continue; @@ -223,7 +223,7 @@ fn toposort_real_module_ids<'a>( continue; } - log::info!("Using slow, fallback logic for topological sorting"); + tracing::info!("Using slow, fallback logic for topological sorting"); all_modules_in_circle.extend(deps_of_circle); } diff --git a/bundler/src/modules/sort/graph.rs b/bundler/src/modules/sort/graph.rs index 3297003880b..ecefcdd860a 100644 --- a/bundler/src/modules/sort/graph.rs +++ b/bundler/src/modules/sort/graph.rs @@ -1,9 +1,9 @@ use crate::util::fast_graph::FastDiGraphMap; -use fxhash::FxHashSet; use petgraph::{ EdgeDirection, EdgeDirection::{Incoming, Outgoing}, }; +use rustc_hash::FxHashSet; use std::{collections::VecDeque, iter::repeat}; /// Is dependancy between nodes hard? diff --git a/bundler/src/modules/sort/mod.rs b/bundler/src/modules/sort/mod.rs index e6289172809..5b50e0dd4e3 100644 --- a/bundler/src/modules/sort/mod.rs +++ b/bundler/src/modules/sort/mod.rs @@ -23,13 +23,13 @@ impl Modules { cycles: &Vec>, cm: &Lrc, ) { - log::debug!("Sorting {:?}", entry_id); + tracing::debug!("Sorting {:?}", entry_id); let injected_ctxt = self.injected_ctxt; let start = Instant::now(); let chunks = self.take_chunks(entry_id, module_graph, cycles, cm); let dur = Instant::now() - start; - log::debug!("Sorting took {:?}", dur); + tracing::debug!("Sorting took {:?}", dur); let buf = chunks .into_iter() @@ -45,6 +45,6 @@ impl Modules { // print_hygiene("after sort", cm, &module); *self = Modules::from(entry_id, module, injected_ctxt); - log::debug!("Sorted {:?}", entry_id); + tracing::debug!("Sorted {:?}", entry_id); } } diff --git a/bundler/src/modules/sort/stmt.rs b/bundler/src/modules/sort/stmt.rs index ef62a673a28..d1d4a1678b8 100644 --- a/bundler/src/modules/sort/stmt.rs +++ b/bundler/src/modules/sort/stmt.rs @@ -1,8 +1,8 @@ use super::graph::Required; use crate::{id::Id, modules::sort::graph::StmtDepGraph}; -use fxhash::{FxHashMap, FxHashSet}; use indexmap::IndexSet; use petgraph::EdgeDirection::{Incoming as Dependants, Outgoing as Dependancies}; +use rustc_hash::{FxHashMap, FxHashSet}; use std::{collections::VecDeque, iter::from_fn, ops::Range}; use swc_atoms::js_word; use swc_common::{sync::Lrc, util::take::Take, SourceMap, Spanned, SyntaxContext, DUMMY_SP}; @@ -54,7 +54,7 @@ pub(super) fn sort_stmts( let mut id_graph = calc_deps(&stmts); - log::debug!("Analyzed dependencies between statements"); + tracing::debug!("Analyzed dependencies between statements"); let orders = iter( &mut id_graph, @@ -65,7 +65,7 @@ pub(super) fn sort_stmts( ) .collect::>(); - log::debug!("Sorted statements"); + tracing::debug!("Sorted statements"); debug_assert_eq!(total_len, orders.len()); @@ -627,7 +627,7 @@ impl Visit for RequirementCalculartor { } fn calc_deps(new: &[ModuleItem]) -> StmtDepGraph { - log::debug!("Analyzing dependencies between statements"); + tracing::debug!("Analyzing dependencies between statements"); let mut graph = StmtDepGraph::default(); let mut declared_by = FxHashMap::>::default(); diff --git a/bundler/src/util/fast_graph.rs b/bundler/src/util/fast_graph.rs index eafe7084132..690194cec4a 100644 --- a/bundler/src/util/fast_graph.rs +++ b/bundler/src/util/fast_graph.rs @@ -3,7 +3,6 @@ #![allow(dead_code)] // We don't want to modify copied source code. -use fxhash::{FxBuildHasher, FxHashSet}; use indexmap::{ map::{Iter as IndexMapIter, IterMut as IndexMapIterMut, Keys}, IndexMap, @@ -13,10 +12,11 @@ use petgraph::{ visit::{GraphBase, IntoNeighbors, IntoNeighborsDirected, NodeCount, Visitable}, Directed, Direction, EdgeType, Incoming, IntoWeightedEdge, Outgoing, Undirected, }; +use rustc_hash::{FxHashSet, FxHasher}; use std::{ cmp::Ordering, fmt, - hash::{self, Hash}, + hash::{self, BuildHasherDefault, Hash}, iter::{Cloned, DoubleEndedIterator, FromIterator}, marker::PhantomData, ops::Deref, @@ -55,8 +55,8 @@ pub type FastDiGraphMap = FastGraphMap; /// Depends on crate feature `graphmap` (default). #[derive(Clone)] pub struct FastGraphMap { - nodes: IndexMap, FxBuildHasher>, - edges: IndexMap<(N, N), E, FxBuildHasher>, + nodes: IndexMap, BuildHasherDefault>, + edges: IndexMap<(N, N), E, BuildHasherDefault>, ty: PhantomData, } @@ -578,7 +578,7 @@ where Ty: EdgeType, { from: N, - edges: &'a IndexMap<(N, N), E, FxBuildHasher>, + edges: &'a IndexMap<(N, N), E, BuildHasherDefault>, iter: Neighbors<'a, N, Ty>, } diff --git a/common/Cargo.toml b/common/Cargo.toml index 178add21ee7..394d501edfc 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -6,10 +6,11 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_common" repository = "https://github.com/swc-project/swc.git" -version = "0.12.2" +version = "0.13.0" [features] concurrent = ["parking_lot"] +debug = [] default = [] tty-emitter = ["atty", "termcolor"] @@ -21,12 +22,11 @@ atty = {version = "0.2", optional = true} cfg-if = "0.1.2" either = "1.5" from_variant = {version = "0.1.3", path = "../macros/from_variant"} -fxhash = "0.2.1" -log = "0.4" num-bigint = "0.2" once_cell = "1" owning_ref = "0.4" parking_lot = {version = "0.7.1", optional = true} +rustc-hash = "1.1.0" scoped-tls = {version = "1"} serde = {version = "1.0.119", features = ["derive"]} sourcemap = {version = "6", optional = true} @@ -34,6 +34,7 @@ string_cache = "0.8.1" swc_eq_ignore_macros = {version = "0.1", path = "../macros/eq_ignore"} swc_visit = {version = "0.2.4", path = "../visit"} termcolor = {version = "1.0", optional = true} +tracing = "0.1.28" unicode-width = "0.1.4" url = "2.2.2" diff --git a/common/src/comments.rs b/common/src/comments.rs index 607c7acfeb9..c5d489d9e70 100644 --- a/common/src/comments.rs +++ b/common/src/comments.rs @@ -2,7 +2,7 @@ use crate::{ pos::Spanned, syntax_pos::{BytePos, Span, DUMMY_SP}, }; -use fxhash::FxHashMap; +use rustc_hash::FxHashMap; use std::{ cell::{Ref, RefCell}, rc::Rc, diff --git a/common/src/errors/diagnostic_builder.rs b/common/src/errors/diagnostic_builder.rs index afe9c7ef816..cc5d6527985 100644 --- a/common/src/errors/diagnostic_builder.rs +++ b/common/src/errors/diagnostic_builder.rs @@ -10,12 +10,12 @@ use super::{Applicability, Diagnostic, DiagnosticId, DiagnosticStyledString, Handler, Level}; use crate::syntax_pos::{MultiSpan, Span}; -use log::debug; use std::{ fmt::{self, Debug}, ops::{Deref, DerefMut}, thread::panicking, }; +use tracing::debug; /// Used for emitting structured error messages and other diagnostic /// information. @@ -114,7 +114,9 @@ impl<'a> DiagnosticBuilder<'a> { }; // Logging here is useful to help track down where in logs an error was // actually emitted. - debug!("buffer: diagnostic={:?}", diagnostic); + if cfg!(feature = "debug") { + debug!("buffer: diagnostic={:?}", diagnostic); + } buffered_diagnostics.push(*diagnostic); } diff --git a/common/src/source_map.rs b/common/src/source_map.rs index e526fe584ba..5603b7d08cd 100644 --- a/common/src/source_map.rs +++ b/common/src/source_map.rs @@ -23,7 +23,6 @@ use crate::{ rustc_data_structures::stable_hasher::StableHasher, sync::{Lock, LockGuard, Lrc, MappedLockGuard}, }; -use log::debug; #[cfg(feature = "sourcemap")] use sourcemap::SourceMapBuilder; use std::{ @@ -35,6 +34,7 @@ use std::{ path::{Path, PathBuf}, sync::atomic::{AtomicUsize, Ordering::SeqCst}, }; +use tracing::debug; // _____________________________________________________________________________ // SourceFile, MultiByteChar, FileName, FileLines @@ -311,15 +311,17 @@ impl SourceMap { .sum(); col.0 - special_chars + non_narrow }; - debug!( - "byte pos {:?} is on the line at byte pos {:?}", - pos, linebpos - ); - debug!( - "char pos {:?} is on the line at char pos {:?}", - chpos, linechpos - ); - debug!("byte is on line: {}", line); + if cfg!(feature = "debug") { + debug!( + "byte pos {:?} is on the line at byte pos {:?}", + pos, linebpos + ); + debug!( + "char pos {:?} is on the line at char pos {:?}", + chpos, linechpos + ); + debug!("byte is on line: {}", line); + } // assert!(chpos >= linechpos); Loc { file: f, @@ -457,16 +459,22 @@ impl SourceMap { } pub fn span_to_lines(&self, sp: Span) -> FileLinesResult { - debug!("span_to_lines(sp={:?})", sp); + if cfg!(feature = "debug") { + debug!("span_to_lines(sp={:?})", sp); + } if sp.lo() > sp.hi() { return Err(SpanLinesError::IllFormedSpan(sp)); } let lo = self.lookup_char_pos(sp.lo()); - debug!("span_to_lines: lo={:?}", lo); + if cfg!(feature = "debug") { + debug!("span_to_lines: lo={:?}", lo); + } let hi = self.lookup_char_pos(sp.hi()); - debug!("span_to_lines: hi={:?}", hi); + if cfg!(feature = "debug") { + debug!("span_to_lines: hi={:?}", hi); + } if lo.file.start_pos != hi.file.start_pos { return Err(SpanLinesError::DistinctSources(DistinctSources { diff --git a/css/Cargo.toml b/css/Cargo.toml index b96c541bcc9..bc99b4dec07 100644 --- a/css/Cargo.toml +++ b/css/Cargo.toml @@ -6,11 +6,11 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_css" repository = "https://github.com/swc-project/swc.git" -version = "0.6.1" +version = "0.7.0" [dependencies] -swc_css_ast = {version = "0.5.0", path = "./ast"} -swc_css_codegen = {version = "0.4.0", path = "./codegen"} -swc_css_parser = {version = "0.6.0", path = "./parser"} -swc_css_utils = {version = "0.2.0", path = "./utils/"} -swc_css_visit = {version = "0.4.0", path = "./visit"} +swc_css_ast = {version = "0.6.0", path = "./ast"} +swc_css_codegen = {version = "0.5.0", path = "./codegen"} +swc_css_parser = {version = "0.7.0", path = "./parser"} +swc_css_utils = {version = "0.3.0", path = "./utils/"} +swc_css_visit = {version = "0.5.0", path = "./visit"} diff --git a/css/ast/Cargo.toml b/css/ast/Cargo.toml index b636bafdbda..fc651f7a7f2 100644 --- a/css/ast/Cargo.toml +++ b/css/ast/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_css_ast" repository = "https://github.com/swc-project/swc.git" -version = "0.5.1" +version = "0.6.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -15,4 +15,4 @@ is-macro = "0.1.9" serde = {version = "1.0.127", features = ["derive"]} string_enum = {version = "0.3.1", path = "../../macros/string_enum/"} swc_atoms = {version = "0.2.7", path = "../../atoms"} -swc_common = {version = "0.12.0", path = "../../common"} +swc_common = {version = "0.13.0", path = "../../common"} diff --git a/css/codegen/Cargo.toml b/css/codegen/Cargo.toml index edd128f8bcb..03f3518e83f 100644 --- a/css/codegen/Cargo.toml +++ b/css/codegen/Cargo.toml @@ -6,17 +6,17 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_css_codegen" repository = "https://github.com/swc-project/swc.git" -version = "0.4.0" +version = "0.5.0" [dependencies] auto_impl = "0.4.1" bitflags = "1.3.2" swc_atoms = {version = "0.2.7", path = "../../atoms"} -swc_common = {version = "0.12.0", path = "../../common"} -swc_css_ast = {version = "0.5.0", path = "../ast/"} +swc_common = {version = "0.13.0", path = "../../common"} +swc_css_ast = {version = "0.6.0", path = "../ast/"} swc_css_codegen_macros = {version = "0.2.0", path = "macros/"} [dev-dependencies] -swc_css_parser = {version = "0.6.0", path = "../parser"} -swc_css_visit = {version = "0.4.0", path = "../visit"} -testing = {version = "0.13.0", path = "../../testing"} +swc_css_parser = {version = "0.7.0", path = "../parser"} +swc_css_visit = {version = "0.5.0", path = "../visit"} +testing = {version = "0.14.0", path = "../../testing"} diff --git a/css/parser/Cargo.toml b/css/parser/Cargo.toml index 3316c6e3729..6b1916c460e 100644 --- a/css/parser/Cargo.toml +++ b/css/parser/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_css_parser" repository = "https://github.com/swc-project/swc.git" -version = "0.6.4" +version = "0.7.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] @@ -16,12 +16,12 @@ debug = [] bitflags = "1.2.1" lexical = "5.2.2" swc_atoms = {version = "0.2.7", path = "../../atoms"} -swc_common = {version = "0.12.0", path = "../../common"} -swc_css_ast = {version = "0.5.0", path = "../ast"} +swc_common = {version = "0.13.0", path = "../../common"} +swc_css_ast = {version = "0.6.0", path = "../ast"} unicode-xid = "0.2.2" [dev-dependencies] serde = "1.0.127" serde_json = "1.0.66" -swc_css_visit = {version = "0.4.0", path = "../visit"} -testing = {version = "0.13.0", path = "../../testing"} +swc_css_visit = {version = "0.5.0", path = "../visit"} +testing = {version = "0.14.0", path = "../../testing"} diff --git a/css/stylis/Cargo.toml b/css/stylis/Cargo.toml index 7fedbb1a497..fa6a18bf9a1 100644 --- a/css/stylis/Cargo.toml +++ b/css/stylis/Cargo.toml @@ -6,18 +6,18 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_stylis" repository = "https://github.com/swc-project/swc.git" -version = "0.3.0" +version = "0.4.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] swc_atoms = {version = "0.2.7", path = "../../atoms"} -swc_common = {version = "0.12.0", path = "../../common"} -swc_css_ast = {version = "0.5.0", path = "../ast"} -swc_css_utils = {version = "0.2.0", path = "../utils/"} -swc_css_visit = {version = "0.4.0", path = "../visit"} +swc_common = {version = "0.13.0", path = "../../common"} +swc_css_ast = {version = "0.6.0", path = "../ast"} +swc_css_utils = {version = "0.3.0", path = "../utils/"} +swc_css_visit = {version = "0.5.0", path = "../visit"} [dev-dependencies] -swc_css_codegen = {version = "0.4.0", path = "../codegen"} -swc_css_parser = {version = "0.6.0", path = "../parser"} -testing = {version = "0.13.0", path = "../../testing"} +swc_css_codegen = {version = "0.5.0", path = "../codegen"} +swc_css_parser = {version = "0.7.0", path = "../parser"} +testing = {version = "0.14.0", path = "../../testing"} diff --git a/css/utils/Cargo.toml b/css/utils/Cargo.toml index 2d1eaea5168..c32f76c305e 100644 --- a/css/utils/Cargo.toml +++ b/css/utils/Cargo.toml @@ -6,11 +6,11 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_css_utils" 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 [dependencies] swc_atoms = {version = "0.2.7", path = "../../atoms"} -swc_common = {version = "0.12.0", path = "../../common"} -swc_css_ast = {version = "0.5.0", path = "../ast"} -swc_css_visit = {version = "0.4.0", path = "../visit"} +swc_common = {version = "0.13.0", path = "../../common"} +swc_css_ast = {version = "0.6.0", path = "../ast"} +swc_css_visit = {version = "0.5.0", path = "../visit"} diff --git a/css/visit/Cargo.toml b/css/visit/Cargo.toml index 847cc33125b..9292f54ff60 100644 --- a/css/visit/Cargo.toml +++ b/css/visit/Cargo.toml @@ -6,12 +6,12 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_css_visit" repository = "https://github.com/swc-project/swc.git" -version = "0.4.0" +version = "0.5.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] swc_atoms = {version = "0.2.7", path = "../../atoms"} -swc_common = {version = "0.12.0", path = "../../common"} -swc_css_ast = {version = "0.5.0", path = "../ast/"} +swc_common = {version = "0.13.0", path = "../../common"} +swc_css_ast = {version = "0.6.0", path = "../ast/"} swc_visit = {version = "0.2.6", path = "../../visit"} diff --git a/ecmascript/Cargo.toml b/ecmascript/Cargo.toml index a40d79e35db..3b8ec559acc 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.65.0" +version = "0.66.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.52.0", path = "./ast"} -swc_ecma_codegen = {version = "0.71.0", path = "./codegen", optional = true} -swc_ecma_dep_graph = {version = "0.40.0", path = "./dep-graph", optional = true} -swc_ecma_minifier = {version = "0.29.0", path = "./minifier", optional = true} -swc_ecma_parser = {version = "0.71.0", path = "./parser", optional = true, default-features = false} -swc_ecma_preset_env = {version = "0.44.0", path = "./preset-env", optional = true} -swc_ecma_transforms = {version = "0.73.0", path = "./transforms", optional = true} -swc_ecma_utils = {version = "0.44.2", path = "./utils", optional = true} -swc_ecma_visit = {version = "0.38.1", path = "./visit", optional = true} +swc_ecma_ast = {version = "0.53.0", path = "./ast"} +swc_ecma_codegen = {version = "0.72.0", path = "./codegen", optional = true} +swc_ecma_dep_graph = {version = "0.41.0", path = "./dep-graph", optional = true} +swc_ecma_minifier = {version = "0.30.0", path = "./minifier", optional = true} +swc_ecma_parser = {version = "0.72.0", path = "./parser", optional = true, default-features = false} +swc_ecma_preset_env = {version = "0.45.0", path = "./preset-env", optional = true} +swc_ecma_transforms = {version = "0.74.0", path = "./transforms", optional = true} +swc_ecma_utils = {version = "0.45.0", path = "./utils", optional = true} +swc_ecma_visit = {version = "0.39.0", path = "./visit", optional = true} [dev-dependencies] diff --git a/ecmascript/ast/Cargo.toml b/ecmascript/ast/Cargo.toml index 3a02026e445..52fc1d32806 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.52.0" +version = "0.53.0" [features] default = [] @@ -19,7 +19,7 @@ num-bigint = {version = "0.2", features = ["serde"]} serde = {version = "1.0.88", features = ["derive"]} string_enum = {version = "0.3.1", path = "../../macros/string_enum"} swc_atoms = {version = "0.2", path = "../../atoms"} -swc_common = {version = "0.12.0", path = "../../common"} +swc_common = {version = "0.13.0", path = "../../common"} [dev-dependencies] serde_json = "1" diff --git a/ecmascript/codegen/Cargo.toml b/ecmascript/codegen/Cargo.toml index 303a061ec6b..d4eb14a83c2 100644 --- a/ecmascript/codegen/Cargo.toml +++ b/ecmascript/codegen/Cargo.toml @@ -7,18 +7,18 @@ include = ["Cargo.toml", "src/**/*.rs"] license = "Apache-2.0/MIT" name = "swc_ecma_codegen" repository = "https://github.com/swc-project/swc.git" -version = "0.71.0" +version = "0.72.0" [dependencies] bitflags = "1" num-bigint = {version = "0.2", features = ["serde"]} sourcemap = "6" swc_atoms = {version = "0.2", path = "../../atoms"} -swc_common = {version = "0.12.0", path = "../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../ast"} +swc_common = {version = "0.13.0", path = "../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../ast"} swc_ecma_codegen_macros = {version = "0.5.2", path = "./macros"} -swc_ecma_parser = {version = "0.71.0", path = "../parser"} +swc_ecma_parser = {version = "0.72.0", path = "../parser"} [dev-dependencies] -swc_common = {version = "0.12.0", path = "../../common", features = ["sourcemap"]} -testing = {version = "0.13.0", path = "../../testing"} +swc_common = {version = "0.13.0", path = "../../common", features = ["sourcemap"]} +testing = {version = "0.14.0", path = "../../testing"} diff --git a/ecmascript/dep-graph/Cargo.toml b/ecmascript/dep-graph/Cargo.toml index dec95bae581..8f5df8a8072 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.40.0" +version = "0.41.0" [dependencies] swc_atoms = {version = "0.2", path = "../../atoms"} -swc_common = {version = "0.12.0", path = "../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../ast"} -swc_ecma_visit = {version = "0.38.1", path = "../visit"} +swc_common = {version = "0.13.0", path = "../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../ast"} +swc_ecma_visit = {version = "0.39.0", path = "../visit"} [dev-dependencies] -swc_ecma_parser = {version = "0.71.0", path = "../parser"} -testing = {version = "0.13.0", path = "../../testing"} +swc_ecma_parser = {version = "0.72.0", path = "../parser"} +testing = {version = "0.14.0", path = "../../testing"} diff --git a/ecmascript/ext-transforms/Cargo.toml b/ecmascript/ext-transforms/Cargo.toml index 9d2e13bb0c1..a04651b1224 100644 --- a/ecmascript/ext-transforms/Cargo.toml +++ b/ecmascript/ext-transforms/Cargo.toml @@ -5,15 +5,15 @@ documentation = "https://rustdoc.swc.rs/swc_ecma_ext_transforms/" edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_ext_transforms" -version = "0.29.0" +version = "0.30.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] phf = {version = "0.8.0", features = ["macros"]} swc_atoms = {version = "0.2", path = "../../atoms"} -swc_common = {version = "0.12.0", path = "../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../ast"} -swc_ecma_parser = {version = "0.71.0", path = "../parser"} -swc_ecma_utils = {version = "0.44.2", path = "../utils"} -swc_ecma_visit = {version = "0.38.1", path = "../visit"} +swc_common = {version = "0.13.0", path = "../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../ast"} +swc_ecma_parser = {version = "0.72.0", path = "../parser"} +swc_ecma_utils = {version = "0.45.0", path = "../utils"} +swc_ecma_visit = {version = "0.39.0", path = "../visit"} diff --git a/ecmascript/jsdoc/Cargo.toml b/ecmascript/jsdoc/Cargo.toml index df9ec82e659..aeea7642db3 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.39.0" +version = "0.40.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -13,12 +13,12 @@ version = "0.39.0" nom = "5.1.2" serde = {version = "1", features = ["derive"]} swc_atoms = {version = "0.2", path = "../../atoms"} -swc_common = {version = "0.12.0", path = "../../common"} +swc_common = {version = "0.13.0", path = "../../common"} [dev-dependencies] anyhow = "1" dashmap = "4.0.2" -swc_ecma_ast = {version = "0.52.0", path = "../ast"} -swc_ecma_parser = {version = "0.71.0", path = "../parser"} -testing = {version = "0.13.0", path = "../../testing"} +swc_ecma_ast = {version = "0.53.0", path = "../ast"} +swc_ecma_parser = {version = "0.72.0", path = "../parser"} +testing = {version = "0.14.0", path = "../../testing"} walkdir = "2" diff --git a/ecmascript/loader/Cargo.toml b/ecmascript/loader/Cargo.toml index 5522d899e63..e623f2f7cf0 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.18.2" +version = "0.19.0" [package.metadata.docs.rs] all-features = true @@ -21,21 +21,21 @@ tsc = ["dashmap", "once_cell", "regex"] [dependencies] anyhow = "1.0.41" -fxhash = "0.2.1" -log = "0.4" dashmap = {version = "4.0.2", optional = true} lru = {version = "0.6.5", optional = true} once_cell = {version = "1.8.0", optional = true} regex = {version = "1", optional = true} +rustc-hash = "1.1.0" 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.12.0", path = "../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../ast"} -swc_ecma_visit = {version = "0.38.1", path = "../visit"} +swc_common = {version = "0.13.0", path = "../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../ast"} +swc_ecma_visit = {version = "0.39.0", path = "../visit"} +tracing = "0.1.28" [dev-dependencies] -testing = {version = "0.13.0", path = "../../testing"} +testing = {version = "0.14.0", path = "../../testing"} [target.'cfg(windows)'.dependencies] normpath = {version = "0.2", optional = true} diff --git a/ecmascript/loader/src/resolvers/node.rs b/ecmascript/loader/src/resolvers/node.rs index d9a3d6f3b71..030514b9f89 100644 --- a/ecmascript/loader/src/resolvers/node.rs +++ b/ecmascript/loader/src/resolvers/node.rs @@ -4,9 +4,9 @@ use crate::{resolve::Resolve, NODE_BUILTINS}; use anyhow::{bail, Context, Error}; -use fxhash::FxHashMap; #[cfg(windows)] use normpath::BasePath; +use rustc_hash::FxHashMap; use serde::Deserialize; use std::{ fs::File, @@ -15,6 +15,7 @@ use std::{ }; use swc_common::FileName; use swc_ecma_ast::TargetEnv; +use tracing::debug; use dashmap::{DashMap, DashSet}; use once_cell::sync::Lazy; @@ -266,11 +267,9 @@ impl NodeModulesResolver { impl Resolve for NodeModulesResolver { fn resolve(&self, base: &FileName, target: &str) -> Result { - log::debug!( + debug!( "Resolve {} from {:#?} for {:#?}", - target, - base, - self.target_env + target, base, self.target_env ); let base = match base { diff --git a/ecmascript/minifier/Cargo.toml b/ecmascript/minifier/Cargo.toml index 2653c549daa..3d4beb4ad0c 100644 --- a/ecmascript/minifier/Cargo.toml +++ b/ecmascript/minifier/Cargo.toml @@ -7,38 +7,38 @@ 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.29.0" +version = "0.30.0" [features] debug = [] [dependencies] -fxhash = "0.2.1" indexmap = "1.7.0" -log = "0.4" once_cell = "1.5.2" pretty_assertions = {version = "0.6.1", optional = true} rayon = "1.5.1" regex = "1.5.3" retain_mut = "0.1.2" +rustc-hash = "1.1.0" serde = {version = "1.0.118", features = ["derive"]} serde_json = "1.0.61" serde_regex = "1.1.0" swc_atoms = {version = "0.2", path = "../../atoms"} -swc_common = {version = "0.12.0", path = "../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../ast"} -swc_ecma_codegen = {version = "0.71.0", path = "../codegen"} -swc_ecma_parser = {version = "0.71.0", path = "../parser"} -swc_ecma_transforms = {version = "0.73.0", path = "../transforms/", features = ["optimization"]} -swc_ecma_transforms_base = {version = "0.32.0", path = "../transforms/base"} -swc_ecma_utils = {version = "0.44.2", path = "../utils"} -swc_ecma_visit = {version = "0.38.1", path = "../visit"} +swc_common = {version = "0.13.0", path = "../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../ast"} +swc_ecma_codegen = {version = "0.72.0", path = "../codegen"} +swc_ecma_parser = {version = "0.72.0", path = "../parser"} +swc_ecma_transforms = {version = "0.74.0", path = "../transforms/", features = ["optimization"]} +swc_ecma_transforms_base = {version = "0.33.0", path = "../transforms/base"} +swc_ecma_utils = {version = "0.45.0", path = "../utils"} +swc_ecma_visit = {version = "0.39.0", path = "../visit"} +tracing = "0.1.28" unicode-xid = "0.2.2" [dev-dependencies] ansi_term = "0.12.1" anyhow = "1" pretty_assertions = "0.6.1" -swc_node_base = {version = "0.3.0", path = "../../node/base"} -testing = {version = "0.13.0", path = "../../testing"} +swc_node_base = {version = "0.4.0", path = "../../node/base"} +testing = {version = "0.14.0", path = "../../testing"} walkdir = "2.3.1" diff --git a/ecmascript/minifier/src/analyzer/mod.rs b/ecmascript/minifier/src/analyzer/mod.rs index fce3e747301..fb8fcfaf06b 100644 --- a/ecmascript/minifier/src/analyzer/mod.rs +++ b/ecmascript/minifier/src/analyzer/mod.rs @@ -6,7 +6,7 @@ use crate::{ marks::Marks, util::{can_end_conditionally, idents_used_by, now}, }; -use fxhash::{FxHashMap, FxHashSet}; +use rustc_hash::{FxHashMap, FxHashSet}; use std::time::Instant; use swc_atoms::JsWord; use swc_common::{SyntaxContext, DUMMY_SP}; @@ -48,7 +48,7 @@ where if let Some(start_time) = start_time { let end_time = Instant::now(); - log::debug!("Scope analysis took {:?}", end_time - start_time); + tracing::debug!("Scope analysis took {:?}", end_time - start_time); } v.data diff --git a/ecmascript/minifier/src/analyzer/storage/normal.rs b/ecmascript/minifier/src/analyzer/storage/normal.rs index 10680afb3dc..f102a89871b 100644 --- a/ecmascript/minifier/src/analyzer/storage/normal.rs +++ b/ecmascript/minifier/src/analyzer/storage/normal.rs @@ -2,7 +2,7 @@ use std::collections::hash_map::Entry; use super::{ScopeDataLike, Storage, VarDataLike}; use crate::analyzer::{ctx::Ctx, ProgramData, ScopeData, ScopeKind, VarUsageInfo}; -use fxhash::FxHashSet; +use rustc_hash::FxHashSet; use swc_ecma_ast::*; use swc_ecma_utils::{ident::IdentLike, Id}; @@ -31,7 +31,7 @@ impl Storage for ProgramData { } for (id, mut var_info) in child.vars { - // log::trace!("merge({:?},{}{:?})", kind, id.0, id.1); + // tracing::trace!("merge({:?},{}{:?})", kind, id.0, id.1); match self.vars.entry(id) { Entry::Occupied(mut e) => { e.get_mut().inline_prevented |= var_info.inline_prevented; @@ -106,7 +106,7 @@ impl Storage for ProgramData { has_init: bool, kind: Option, ) -> &mut VarUsageInfo { - // log::trace!("declare_decl({}{:?})", i.sym, i.span.ctxt); + // tracing::trace!("declare_decl({}{:?})", i.sym, i.span.ctxt); let v = self .vars @@ -162,7 +162,7 @@ impl ScopeDataLike for ScopeData { impl ProgramData { fn report(&mut self, i: Id, ctx: Ctx, is_modify: bool, dejavu: &mut FxHashSet) { - // log::trace!("report({}{:?})", i.0, i.1); + // tracing::trace!("report({}{:?})", i.0, i.1); let is_first = dejavu.is_empty(); @@ -171,7 +171,7 @@ impl ProgramData { } let e = self.vars.entry(i.clone()).or_insert_with(|| { - // log::trace!("insert({}{:?})", i.0, i.1); + // tracing::trace!("insert({}{:?})", i.0, i.1); VarUsageInfo { is_fn_local: true, diff --git a/ecmascript/minifier/src/compress/hoist_decls.rs b/ecmascript/minifier/src/compress/hoist_decls.rs index b6d8faf497f..98052c47b46 100644 --- a/ecmascript/minifier/src/compress/hoist_decls.rs +++ b/ecmascript/minifier/src/compress/hoist_decls.rs @@ -2,7 +2,7 @@ use crate::{ analyzer::{ProgramData, UsageAnalyzer}, util::{is_hoisted_var_decl_without_init, sort::is_sorted_by_key, IsModuleItem}, }; -use fxhash::FxHashSet; +use rustc_hash::FxHashSet; use swc_common::{pass::Repeated, util::take::Take, DUMMY_SP}; use swc_ecma_ast::*; use swc_ecma_utils::{find_ids, ident::IdentLike, Id, StmtLike}; diff --git a/ecmascript/minifier/src/compress/mod.rs b/ecmascript/minifier/src/compress/mod.rs index bb718a8c1c1..7714eb9c1eb 100644 --- a/ecmascript/minifier/src/compress/mod.rs +++ b/ecmascript/minifier/src/compress/mod.rs @@ -134,7 +134,7 @@ where where N: Send + Sync + for<'aa> VisitMutWith>, { - log::debug!("visit_par(left_depth = {})", self.left_parallel_depth); + tracing::debug!("visit_par(left_depth = {})", self.left_parallel_depth); if self.left_parallel_depth == 0 || cfg!(target_arch = "wasm32") { for node in nodes { @@ -187,7 +187,7 @@ where N: CompileUnit + VisitWith + for<'aa> VisitMutWith>, { if cfg!(feature = "debug") { - log::debug!( + tracing::debug!( "Optimizing a compile unit within `{:?}`", thread::current().name() ); @@ -236,7 +236,7 @@ where if self.options.passes != 0 && self.options.passes + 1 <= self.pass { let done = dump(&*n); - log::debug!("===== Done =====\n{}", done); + tracing::debug!("===== Done =====\n{}", done); return; } @@ -247,14 +247,14 @@ where let start = if cfg!(feature = "debug") { let start = n.dump(); - log::debug!("===== Start =====\n{}", start); + tracing::debug!("===== Start =====\n{}", start); start } else { String::new() }; { - log::info!( + tracing::info!( "compress: Running expression simplifier (pass = {})", self.pass ); @@ -265,16 +265,16 @@ where n.apply(&mut visitor); self.changed |= visitor.changed(); if visitor.changed() { - log::debug!("compressor: Simplified expressions"); + tracing::debug!("compressor: Simplified expressions"); if cfg!(feature = "debug") { - log::debug!("===== Simplified =====\n{}", dump(&*n)); + tracing::debug!("===== Simplified =====\n{}", dump(&*n)); } } if let Some(start_time) = start_time { let end_time = Instant::now(); - log::info!( + tracing::info!( "compress: expr_simplifier took {:?} (pass = {})", end_time - start_time, self.pass @@ -295,7 +295,7 @@ where } { - log::info!( + tracing::info!( "compress/pure: Running pure optimizer (pass = {})", self.pass ); @@ -309,7 +309,7 @@ where if let Some(start_time) = start_time { let end_time = Instant::now(); - log::info!( + tracing::info!( "compress/pure: Pure optimizer took {:?} (pass = {})", end_time - start_time, self.pass @@ -317,13 +317,13 @@ where if cfg!(feature = "debug") && visitor.changed() { let start = n.dump(); - log::debug!("===== After pure =====\n{}", start); + tracing::debug!("===== After pure =====\n{}", start); } } } { - log::info!("compress: Running optimizer (pass = {})", self.pass); + tracing::info!("compress: Running optimizer (pass = {})", self.pass); let start_time = now(); // TODO: reset_opt_flags @@ -345,14 +345,14 @@ where if let Some(start_time) = start_time { let end_time = Instant::now(); - log::info!( + tracing::info!( "compress: Optimizer took {:?} (pass = {})", end_time - start_time, self.pass ); } // let done = dump(&*n); - // log::debug!("===== Result =====\n{}", done); + // tracing::debug!("===== Result =====\n{}", done); } if self.options.conditionals || self.options.dead_code { @@ -370,7 +370,7 @@ where if let Some(start_time) = start_time { let end_time = Instant::now(); - log::info!( + tracing::info!( "compress: dead_branch_remover took {:?} (pass = {})", end_time - start_time, self.pass @@ -381,7 +381,7 @@ where let simplified = dump(&*n); if start != simplified { - log::debug!( + tracing::debug!( "===== Removed dead branches =====\n{}\n==== ===== ===== ===== ======\n{}", start, simplified diff --git a/ecmascript/minifier/src/compress/optimize/arguments.rs b/ecmascript/minifier/src/compress/optimize/arguments.rs index 511d9d4ce0b..e532883ce7c 100644 --- a/ecmascript/minifier/src/compress/optimize/arguments.rs +++ b/ecmascript/minifier/src/compress/optimize/arguments.rs @@ -35,7 +35,7 @@ where } self.changed = true; - log::debug!("arguments: Optimizing computed access to arguments"); + tracing::debug!("arguments: Optimizing computed access to arguments"); member.computed = false; member.prop = Box::new(Expr::Ident(Ident { span: prop.span, @@ -112,7 +112,7 @@ impl ArgReplacer<'_> { let new_args = idx + 1 - self.params.len(); self.changed = true; - log::debug!("arguments: Injecting {} parameters", new_args); + tracing::debug!("arguments: Injecting {} parameters", new_args); let mut start = self.params.len(); self.params.extend( repeat_with(|| { @@ -190,7 +190,7 @@ impl VisitMut for ArgReplacer<'_> { if let Some(param) = self.params.get(idx) { match ¶m.pat { Pat::Ident(i) => { - log::debug!( + tracing::debug!( "arguments: Replacing access to arguments to \ normal reference", ); diff --git a/ecmascript/minifier/src/compress/optimize/bools.rs b/ecmascript/minifier/src/compress/optimize/bools.rs index f2cb7bd0043..d1a8e75f2b3 100644 --- a/ecmascript/minifier/src/compress/optimize/bools.rs +++ b/ecmascript/minifier/src/compress/optimize/bools.rs @@ -55,7 +55,7 @@ where // => // // `_ || 'undefined' == typeof require` - log::debug!( + tracing::debug!( "bools: Negating: (!a && !b) => !(a || b) (because both expression are good for \ negation)", ); @@ -77,7 +77,7 @@ where self.with_ctx(ctx).negate(&mut e.right); if cfg!(feature = "debug") { - log::trace!("[Change] {} => {}", start, dump(&*e)); + tracing::trace!("[Change] {} => {}", start, dump(&*e)); } true @@ -98,7 +98,7 @@ where None => match &mut *stmt.cons { Stmt::Expr(cons) => { self.changed = true; - log::debug!("conditionals: `if (foo) bar;` => `foo && bar`"); + tracing::debug!("conditionals: `if (foo) bar;` => `foo && bar`"); *s = Stmt::Expr(ExprStmt { span: stmt.span, expr: Box::new(Expr::Bin(BinExpr { diff --git a/ecmascript/minifier/src/compress/optimize/collapse_vars.rs b/ecmascript/minifier/src/compress/optimize/collapse_vars.rs index b58a002884e..44613514005 100644 --- a/ecmascript/minifier/src/compress/optimize/collapse_vars.rs +++ b/ecmascript/minifier/src/compress/optimize/collapse_vars.rs @@ -1,6 +1,6 @@ use super::Optimizer; use crate::mode::Mode; -use fxhash::FxHashMap; +use rustc_hash::FxHashMap; use swc_ecma_ast::*; use swc_ecma_utils::{ident::IdentLike, Id}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith}; @@ -66,7 +66,7 @@ where _ => return, }; - log::debug!( + tracing::debug!( "collpase_vars: Decided to inline {}{:?}", left.id.sym, left.id.span.ctxt @@ -92,7 +92,7 @@ impl VisitMut for Inliner<'_> { match e { Expr::Ident(i) => { if let Some(value) = self.values.remove(&i.to_id()) { - log::debug!("collapse_vars: Inlining {}{:?}", i.sym, i.span.ctxt); + tracing::debug!("collapse_vars: Inlining {}{:?}", i.sym, i.span.ctxt); *e = *value.expect("should be used only once"); } diff --git a/ecmascript/minifier/src/compress/optimize/conditionals.rs b/ecmascript/minifier/src/compress/optimize/conditionals.rs index 10e2ad34a60..3c8f14dfafc 100644 --- a/ecmascript/minifier/src/compress/optimize/conditionals.rs +++ b/ecmascript/minifier/src/compress/optimize/conditionals.rs @@ -34,7 +34,7 @@ where if negate_cost(&stmt.test, true, false).unwrap_or(isize::MAX) < 0 { self.changed = true; - log::debug!("if_return: Negating `cond` of an if statement which has cons and alt"); + tracing::debug!("if_return: Negating `cond` of an if statement which has cons and alt"); let ctx = Ctx { in_bool_ctx: true, ..self.ctx @@ -47,7 +47,7 @@ where match &*alt { Stmt::Return(..) | Stmt::Continue(ContinueStmt { label: None, .. }) => { self.changed = true; - log::debug!( + tracing::debug!( "if_return: Negating an if statement because the alt is return / continue" ); self.negate(&mut stmt.test); @@ -67,7 +67,7 @@ where if !cond.cons.may_have_side_effects() { self.changed = true; - log::debug!("conditionals: `cond ? useless : alt` => `cond || alt`"); + tracing::debug!("conditionals: `cond ? useless : alt` => `cond || alt`"); *e = Expr::Bin(BinExpr { span: cond.span, op: op!("||"), @@ -79,7 +79,7 @@ where if !cond.alt.may_have_side_effects() { self.changed = true; - log::debug!("conditionals: `cond ? cons : useless` => `cond && cons`"); + tracing::debug!("conditionals: `cond ? cons : useless` => `cond && cons`"); *e = Expr::Bin(BinExpr { span: cond.span, op: op!("&&"), @@ -127,7 +127,7 @@ where } self.changed = true; - log::debug!("conditionals: Merging if statements with same `cons`"); + tracing::debug!("conditionals: Merging if statements with same `cons`"); let mut cur: Option = None; let mut new = Vec::with_capacity(stmts.len()); @@ -214,7 +214,7 @@ where expr: stmt.test.take(), }); self.changed = true; - log::debug!("conditionals: `if (foo);` => `foo` "); + tracing::debug!("conditionals: `if (foo);` => `foo` "); return; } } @@ -244,7 +244,7 @@ where Expr::Unary(UnaryExpr { op: op!("!"), arg, .. }) => { - log::debug!("Optimizing `if (!foo); else bar();` as `foo && bar();`"); + tracing::debug!("Optimizing `if (!foo); else bar();` as `foo && bar();`"); let mut expr = Box::new(Expr::Bin(BinExpr { span: DUMMY_SP, @@ -259,7 +259,7 @@ where }); } _ => { - log::debug!("Optimizing `if (foo); else bar();` as `foo || bar();`"); + tracing::debug!("Optimizing `if (foo); else bar();` as `foo || bar();`"); let mut expr = Box::new(Expr::Bin(BinExpr { span: DUMMY_SP, @@ -299,7 +299,7 @@ where if self.options.conditionals || self.options.bools { // if (a) b(); else c(); => a ? b() : c() - log::debug!( + tracing::debug!( "Compressing if statement as conditional expression (even though cons and alt is \ not compressable)" ); @@ -337,7 +337,7 @@ where // x ? x : y => x || y if cond.test.is_ident() && cond.test.eq_ignore_span(&cond.cons) { - log::debug!("Compressing `x ? x : y` as `x || y`"); + tracing::debug!("Compressing `x ? x : y` as `x || y`"); self.changed = true; *e = Expr::Bin(BinExpr { span: cond.span, @@ -362,7 +362,7 @@ where _ => true, } { - log::debug!("conditionals: cons is same as alt"); + tracing::debug!("conditionals: cons is same as alt"); return Some(Expr::Seq(SeqExpr { span: DUMMY_SP, exprs: vec![test.take(), Box::new(cons.take())], @@ -398,7 +398,7 @@ where .count(); if diff_count == 1 { - log::debug!( + tracing::debug!( "conditionals: Merging cons and alt as only one argument differs" ); self.changed = true; @@ -464,7 +464,7 @@ where })), }); - log::debug!( + tracing::debug!( "Compreessing if into cond as there's no side effect and the number of \ arguments is 1" ); @@ -477,7 +477,7 @@ where } if !side_effect_free && is_for_if_stmt { - log::debug!("Compreessing if into cond while preserving side effects"); + tracing::debug!("Compreessing if into cond while preserving side effects"); return Some(Expr::Cond(CondExpr { span: DUMMY_SP.with_ctxt(self.done_ctxt), test: test.take(), @@ -526,7 +526,7 @@ where }); } - log::debug!( + tracing::debug!( "Compreessing if statement into a condiotnal expression of `new` as \ there's no side effect and the number of arguments is 1" ); @@ -548,7 +548,7 @@ where && cons.left.eq_ignore_span(&alt.left) && is_simple_lhs(&cons.left) => { - log::debug!("Merging assignments in cons and alt of if statement"); + tracing::debug!("Merging assignments in cons and alt of if statement"); Some(Expr::Assign(AssignExpr { span: DUMMY_SP, op: cons.op, @@ -564,7 +564,7 @@ where // a ? b ? c() : d() : d() => a && b ? c() : d() (Expr::Cond(cons), alt) if (*cons.alt).eq_ignore_span(&*alt) => { - log::debug!("conditionals: a ? b ? c() : d() : d() => a && b ? c() : d()"); + tracing::debug!("conditionals: a ? b ? c() : d() : d() => a && b ? c() : d()"); return Some(Expr::Cond(CondExpr { span: DUMMY_SP.with_ctxt(self.done_ctxt), test: Box::new(Expr::Bin(BinExpr { @@ -583,7 +583,7 @@ where // (z || condition(), "fuji"); (cons, Expr::Seq(alt)) if (**alt.exprs.last().unwrap()).eq_ignore_span(&*cons) => { self.changed = true; - log::debug!("conditionals: Reducing seq expr in alt"); + tracing::debug!("conditionals: Reducing seq expr in alt"); // alt.exprs.pop(); let first = Box::new(Expr::Bin(BinExpr { @@ -606,7 +606,7 @@ where // (z && condition(), "fuji"); (Expr::Seq(cons), alt) if (**cons.exprs.last().unwrap()).eq_ignore_span(&*alt) => { self.changed = true; - log::debug!("conditionals: Reducing seq expr in cons"); + tracing::debug!("conditionals: Reducing seq expr in cons"); // cons.exprs.pop(); let first = Box::new(Expr::Bin(BinExpr { @@ -665,7 +665,7 @@ where }; self.changed = true; - log::debug!("if_return: Injecting else because it's shorter"); + tracing::debug!("if_return: Injecting else because it's shorter"); let mut new = vec![]; new.reserve(pos_of_if + 1); @@ -756,7 +756,7 @@ where } self.changed = true; - log::debug!("conditionals: Dropped useless `else` token"); + tracing::debug!("conditionals: Dropped useless `else` token"); *stmts = new_stmts; } } diff --git a/ecmascript/minifier/src/compress/optimize/dead_code.rs b/ecmascript/minifier/src/compress/optimize/dead_code.rs index a7e7f27b465..127dbdfca10 100644 --- a/ecmascript/minifier/src/compress/optimize/dead_code.rs +++ b/ecmascript/minifier/src/compress/optimize/dead_code.rs @@ -59,7 +59,7 @@ where .map(|var| var.is_fn_local) .unwrap_or(false) { - log::debug!( + tracing::debug!( "dead_code: Dropping an assigment to a varaible declared in \ function because function is being terminated" ); diff --git a/ecmascript/minifier/src/compress/optimize/evaluate.rs b/ecmascript/minifier/src/compress/optimize/evaluate.rs index bc4ace6179f..7bb1030038a 100644 --- a/ecmascript/minifier/src/compress/optimize/evaluate.rs +++ b/ecmascript/minifier/src/compress/optimize/evaluate.rs @@ -53,7 +53,7 @@ where sym: js_word!("undefined"), .. }) => { - log::debug!("evaluate: `undefined` -> `void 0`"); + tracing::debug!("evaluate: `undefined` -> `void 0`"); self.changed = true; *e = *undefined(*span); return; @@ -64,7 +64,7 @@ where sym: js_word!("Infinity"), .. }) => { - log::debug!("evaluate: `Infinity` -> `1 / 0`"); + tracing::debug!("evaluate: `Infinity` -> `1 / 0`"); self.changed = true; *e = Expr::Bin(BinExpr { span: span.with_ctxt(self.done_ctxt), @@ -137,7 +137,7 @@ where 1 => match &*args[0].expr { Expr::Lit(Lit::Str(exp)) => { self.changed = true; - log::debug!( + tracing::debug!( "evaluate: Converting RegExpr call into a regexp literal `/{}/`", exp.value ); @@ -153,7 +153,7 @@ where _ => match (&*args[0].expr, &*args[1].expr) { (Expr::Lit(Lit::Str(exp)), Expr::Lit(Lit::Str(flags))) => { self.changed = true; - log::debug!( + tracing::debug!( "evaluate: Converting RegExpr call into a regexp literal `/{}/{}`", exp.value, flags.value @@ -197,7 +197,7 @@ where match char::from_u32(v) { Some(v) => { self.changed = true; - log::debug!( + tracing::debug!( "evanluate: Evaluated `String.charCodeAt({})` as `{}`", char_code, v @@ -315,7 +315,7 @@ where Expr::Call(..) => { if let Some(value) = eval_as_number(&e) { self.changed = true; - log::debug!("evaluate: Evaluated an expression as `{}`", value); + tracing::debug!("evaluate: Evaluated an expression as `{}`", value); *e = Expr::Lit(Lit::Num(Number { span: e.span(), @@ -335,7 +335,7 @@ where if let Known(l) = l { if let Known(r) = r { self.changed = true; - log::debug!("evaluate: Evaulated `{:?} ** {:?}`", l, r); + tracing::debug!("evaluate: Evaulated `{:?} ** {:?}`", l, r); let value = l.powf(r); *e = Expr::Lit(Lit::Num(Number { @@ -380,7 +380,7 @@ where } self.changed = true; - log::debug!("evaluate: `0 / 0` => `NaN`"); + tracing::debug!("evaluate: `0 / 0` => `NaN`"); // Sign does not matter for NaN *e = Expr::Ident(Ident::new( @@ -391,7 +391,7 @@ where } (FpCategory::Normal, FpCategory::Zero) => { self.changed = true; - log::debug!("evaluate: `constant / 0` => `Infinity`"); + tracing::debug!("evaluate: `constant / 0` => `Infinity`"); // Sign does not matter for NaN *e = if ln.is_sign_positive() == rn.is_sign_positive() { @@ -450,7 +450,9 @@ where // As we used as_pure_bool, we can drop it. if v && e.op == op!("&&") { self.changed = true; - log::debug!("Removing `b` from `a && b && c` because b is always truthy"); + tracing::debug!( + "Removing `b` from `a && b && c` because b is always truthy" + ); left.right.take(); return; @@ -458,7 +460,9 @@ where if !v && e.op == op!("||") { self.changed = true; - log::debug!("Removing `b` from `a || b || c` because b is always falsy"); + tracing::debug!( + "Removing `b` from `a || b || c` because b is always falsy" + ); left.right.take(); return; diff --git a/ecmascript/minifier/src/compress/optimize/fns.rs b/ecmascript/minifier/src/compress/optimize/fns.rs index 1637f83acb2..496c8d1b01c 100644 --- a/ecmascript/minifier/src/compress/optimize/fns.rs +++ b/ecmascript/minifier/src/compress/optimize/fns.rs @@ -70,7 +70,7 @@ where } self.changed = true; - log::debug!("fns: Reordering statements"); + tracing::debug!("fns: Reordering statements"); let mut fns = vec![]; let mut other = vec![]; diff --git a/ecmascript/minifier/src/compress/optimize/hoist_props.rs b/ecmascript/minifier/src/compress/optimize/hoist_props.rs index 3039c65c86e..cdd747fcabe 100644 --- a/ecmascript/minifier/src/compress/optimize/hoist_props.rs +++ b/ecmascript/minifier/src/compress/optimize/hoist_props.rs @@ -92,7 +92,7 @@ where match &p.key { PropName::Str(s) => { - log::debug!( + tracing::debug!( "hoist_props: Storing a varaible to inline \ properties" ); @@ -100,7 +100,7 @@ where .insert((name.to_id(), s.value.clone()), value); } PropName::Ident(i) => { - log::debug!( + tracing::debug!( "hoist_props: Storing a varaible to inline \ properties" ); @@ -157,7 +157,7 @@ where ); } None => { - log::debug!( + tracing::debug!( "hoist_props: Stored {}{:?} to inline property access", name.id.sym, name.id.span.ctxt @@ -183,7 +183,7 @@ where if let Some(value) = self.vars_for_prop_hoisting.remove(&obj.to_id()) { member.obj = ExprOrSuper::Expr(value); self.changed = true; - log::debug!("hoist_props: Inlined a property"); + tracing::debug!("hoist_props: Inlined a property"); return; } @@ -196,7 +196,7 @@ where if let Some(value) = self.simple_props.get(&(obj.to_id(), prop.sym.clone())) { - log::debug!("hoist_props: Inlining `{}.{}`", obj.sym, prop.sym); + tracing::debug!("hoist_props: Inlining `{}.{}`", obj.sym, prop.sym); self.changed = true; *e = *value.clone() } diff --git a/ecmascript/minifier/src/compress/optimize/if_return.rs b/ecmascript/minifier/src/compress/optimize/if_return.rs index 1a4b52da947..ee4e00e7420 100644 --- a/ecmascript/minifier/src/compress/optimize/if_return.rs +++ b/ecmascript/minifier/src/compress/optimize/if_return.rs @@ -33,7 +33,7 @@ where .. }) => { self.changed = true; - log::debug!("if_return: Merging nested if statements"); + tracing::debug!("if_return: Merging nested if statements"); s.test = Box::new(Expr::Bin(BinExpr { span: s.test.span(), @@ -75,7 +75,7 @@ where } self.changed = true; - log::debug!("if_return: Merging `else if` into `else`"); + tracing::debug!("if_return: Merging `else if` into `else`"); match &mut **alt_of_alt { Stmt::Block(alt_of_alt) => { @@ -186,7 +186,7 @@ where None => true, }); let skip = idx_of_not_mergable.map(|v| v + 1).unwrap_or(0); - log::trace!("if_return: Skip = {}", skip); + tracing::trace!("if_return: Skip = {}", skip); let mut last_idx = stmts.len() - 1; { @@ -212,7 +212,7 @@ where } if last_idx <= skip { - log::trace!("if_return: [x] Aborting because of skip"); + tracing::trace!("if_return: [x] Aborting because of skip"); return; } @@ -222,7 +222,7 @@ where // There's no return statment so merging requires injecting unnecessary `void 0` if return_count == 0 { - log::trace!("if_return: [x] Aborting because we failed to find return"); + tracing::trace!("if_return: [x] Aborting because we failed to find return"); return; } @@ -248,7 +248,7 @@ where (_, Some(Stmt::If(IfStmt { alt: None, .. }) | Stmt::Expr(..))) if if_return_count <= 1 => { - log::trace!( + tracing::trace!( "if_return: [x] Aborting because last stmt is a not return stmt" ); return; @@ -262,7 +262,7 @@ where ) => match &**cons { Stmt::Return(ReturnStmt { arg: Some(..), .. }) => {} _ => { - log::trace!( + tracing::trace!( "if_return: [x] Aborting because stmt before last is an if stmt \ and cons of it is not a return stmt" ); @@ -318,13 +318,13 @@ where } } - log::debug!("if_return: Merging returns"); + tracing::debug!("if_return: Merging returns"); if cfg!(feature = "debug") { let block = BlockStmt { span: DUMMY_SP, stmts: stmts.clone(), }; - log::trace!("if_return: {}", dump(&block)) + tracing::trace!("if_return: {}", dump(&block)) } self.changed = true; @@ -538,7 +538,7 @@ where _ => false, }; // if !res { - // log::trace!("Cannot merge: {}", dump(s)); + // tracing::trace!("Cannot merge: {}", dump(s)); // } res @@ -639,7 +639,7 @@ fn can_merge_as_if_return(s: &Stmt) -> bool { let c = cost(s); if cfg!(feature = "debug") { - log::trace!("merging cost of `{}` = {:?}", dump(s), c); + tracing::trace!("merging cost of `{}` = {:?}", dump(s), c); } c.unwrap_or(0) < 0 diff --git a/ecmascript/minifier/src/compress/optimize/iife.rs b/ecmascript/minifier/src/compress/optimize/iife.rs index 3142ea116f5..ec53e9ca6f6 100644 --- a/ecmascript/minifier/src/compress/optimize/iife.rs +++ b/ecmascript/minifier/src/compress/optimize/iife.rs @@ -4,7 +4,7 @@ use crate::{ mode::Mode, util::{idents_used_by, make_number}, }; -use fxhash::FxHashMap; +use rustc_hash::FxHashMap; use std::{ collections::HashMap, mem::{replace, swap}, @@ -38,7 +38,7 @@ where match callee { Expr::Fn(..) => { - log::debug!("negate_iife: Negating iife"); + tracing::debug!("negate_iife: Negating iife"); *e = Expr::Unary(UnaryExpr { span: DUMMY_SP, op: op!("!"), @@ -72,7 +72,7 @@ where match callee { Expr::Fn(..) => { - log::debug!("negate_iife: Swapping cons and alt"); + tracing::debug!("negate_iife: Swapping cons and alt"); cond.test = Box::new(Expr::Unary(UnaryExpr { span: DUMMY_SP, op: op!("!"), @@ -218,7 +218,7 @@ where let should_be_inlined = self.can_be_inlined_for_iife(arg); if should_be_inlined { - log::debug!( + tracing::debug!( "iife: Trying to inline argument ({}{:?})", param.id.sym, param.id.span.ctxt @@ -226,7 +226,7 @@ where vars.insert(param.to_id(), arg.clone()); } } else { - log::debug!( + tracing::debug!( "iife: Trying to inline argument ({}{:?}) (undefined)", param.id.sym, param.id.span.ctxt @@ -245,11 +245,11 @@ where let mut optimizer = self.with_ctx(ctx); match find_body(callee) { Some(Either::Left(body)) => { - log::debug!("inline: Inlining arguments"); + tracing::debug!("inline: Inlining arguments"); optimizer.inline_vars_in_node(body, vars); } Some(Either::Right(body)) => { - log::debug!("inline: Inlining arguments"); + tracing::debug!("inline: Inlining arguments"); optimizer.inline_vars_in_node(body, vars); } _ => {} @@ -261,7 +261,7 @@ where where N: VisitMutWith, { - log::debug!("inline: inline_vars_in_node"); + tracing::debug!("inline: inline_vars_in_node"); let ctx = Ctx { inline_prevented: false, ..self.ctx @@ -316,19 +316,19 @@ where }; if self.ctx.inline_prevented { - log::trace!("iife: [x] Inline is prevented"); + tracing::trace!("iife: [x] Inline is prevented"); return; } match callee { Expr::Arrow(f) => { if f.is_async { - log::trace!("iife: [x] Cannot inline async fn"); + tracing::trace!("iife: [x] Cannot inline async fn"); return; } if f.is_generator { - log::trace!("iife: [x] Cannot inline generator"); + tracing::trace!("iife: [x] Cannot inline generator"); return; } @@ -362,7 +362,7 @@ where let new = self.inline_fn_like(¶m_ids, body, &mut call.args); if let Some(new) = new { self.changed = true; - log::debug!("inline: Inlining a function call (arrow)"); + tracing::debug!("inline: Inlining a function call (arrow)"); *e = new; } @@ -428,7 +428,7 @@ where } exprs.push(body.take()); - log::debug!("inline: Inlining a call to an arrow function"); + tracing::debug!("inline: Inlining a call to an arrow function"); *e = Expr::Seq(SeqExpr { span: DUMMY_SP, exprs, @@ -445,18 +445,18 @@ where _ => false, }); if has_decl { - log::trace!("iife: [x] Found decl"); + tracing::trace!("iife: [x] Found decl"); return; } } if f.function.is_async { - log::trace!("iife: [x] Cannot inline async fn"); + tracing::trace!("iife: [x] Cannot inline async fn"); return; } if f.function.is_generator { - log::trace!("iife: [x] Cannot inline generator"); + tracing::trace!("iife: [x] Cannot inline generator"); return; } @@ -465,25 +465,25 @@ where Pat::Object(..) | Pat::Array(..) | Pat::Assign(..) | Pat::Rest(..) => true, _ => false, }) { - log::trace!("iife: [x] Found complex pattern"); + tracing::trace!("iife: [x] Found complex pattern"); return; } if let Some(i) = &f.ident { if idents_used_by(&f.function.body).contains(&i.to_id()) { - log::trace!("iife: [x] Recursive?"); + tracing::trace!("iife: [x] Recursive?"); return; } } for arg in &call.args { if arg.spread.is_some() { - log::trace!("iife: [x] Found spread argument"); + tracing::trace!("iife: [x] Found spread argument"); return; } match &*arg.expr { Expr::Fn(..) | Expr::Arrow(..) => { - log::trace!("iife: [x] Found callable argument"); + tracing::trace!("iife: [x] Found callable argument"); return; } _ => {} @@ -504,14 +504,14 @@ where .collect::>(); if !self.can_inline_fn_like(¶m_ids, body) { - log::trace!("iife: [x] Body is not inliable"); + tracing::trace!("iife: [x] Body is not inliable"); return; } let new = self.inline_fn_like(¶m_ids, body, &mut call.args); if let Some(new) = new { self.changed = true; - log::debug!("inline: Inlining a function call"); + tracing::debug!("inline: Inlining a function call"); *e = new; } @@ -593,7 +593,7 @@ where } self.changed = true; - log::debug!("inline: Inling an iife"); + tracing::debug!("inline: Inling an iife"); let mut exprs = vec![]; diff --git a/ecmascript/minifier/src/compress/optimize/inline.rs b/ecmascript/minifier/src/compress/optimize/inline.rs index 0fa36910163..ebc2ecb1af0 100644 --- a/ecmascript/minifier/src/compress/optimize/inline.rs +++ b/ecmascript/minifier/src/compress/optimize/inline.rs @@ -30,7 +30,7 @@ where && self.ctx.in_top_level(); if cfg!(feature = "debug") { - log::trace!( + tracing::trace!( "inline: store_var_for_inining({}, should_preserve = {:?})", dump(&var.name), should_preserve @@ -71,7 +71,7 @@ where if should_preserve && usage.var_kind != Some(VarDeclKind::Const) { if cfg!(feature = "debug") { - log::trace!( + tracing::trace!( "inline: [x] Preserving non-const variable `{}` because it's \ top-level", dump(&var.name) @@ -82,7 +82,7 @@ where if usage.cond_init || usage.used_above_decl { if cfg!(feature = "debug") { - log::trace!("inline: [x] It's cond init or used before decl",); + tracing::trace!("inline: [x] It's cond init or used before decl",); } return; } @@ -113,14 +113,14 @@ where { } else { if cfg!(feature = "debug") { - log::trace!("inline: [x] It's not fn-local"); + tracing::trace!("inline: [x] It's not fn-local"); } return; } } _ => { if cfg!(feature = "debug") { - log::trace!("inline: [x] It's not fn-local"); + tracing::trace!("inline: [x] It's not fn-local"); } return; } @@ -182,7 +182,7 @@ where _ => true, } { - log::debug!( + tracing::debug!( "inline: Decided to inline '{}{:?}' because it's simple", i.id.sym, i.id.span.ctxt @@ -194,7 +194,7 @@ where self.lits.insert(i.to_id(), init.take()); } else { - log::debug!( + tracing::debug!( "inline: Decided to copy '{}{:?}' because it's simple", i.id.sym, i.id.span.ctxt @@ -207,7 +207,7 @@ where if self.ctx.inline_as_assignment { if cfg!(feature = "debug") { - log::trace!("inline: [x] inline_as_assignment is true"); + tracing::trace!("inline: [x] inline_as_assignment is true"); } return; } @@ -266,7 +266,7 @@ where return; } - log::debug!( + tracing::debug!( "inline: Decided to inline var '{}' because it's used only once", i.id ); @@ -323,7 +323,7 @@ where .and_then(|data| data.vars.get(&i.to_id())) { if !usage.reassigned { - log::trace!("typeofs: Storing typeof `{}{:?}`", i.sym, i.span.ctxt); + tracing::trace!("typeofs: Storing typeof `{}{:?}`", i.sym, i.span.ctxt); match &*decl { Decl::Fn(..) => { self.typeofs.insert(i.to_id(), js_word!("function")); @@ -353,12 +353,12 @@ where }; if cfg!(feature = "debug") { - log::trace!("inline: Trying to inline decl ({}{:?})", i.sym, i.span.ctxt); + tracing::trace!("inline: Trying to inline decl ({}{:?})", i.sym, i.span.ctxt); } if self.options.inline == 0 && !self.options.reduce_vars { if cfg!(feature = "debug") { - log::trace!("inline: [x] Inline disabled"); + tracing::trace!("inline: [x] Inline disabled"); } return; } @@ -367,14 +367,14 @@ where && self.ctx.in_top_level() { if cfg!(feature = "debug") { - log::trace!("inline: [x] Top level"); + tracing::trace!("inline: [x] Top level"); } return; } if self.has_noinline(decl.span()) { if cfg!(feature = "debug") { - log::trace!("inline: [x] Has noinline"); + tracing::trace!("inline: [x] Has noinline"); } return; } @@ -382,21 +382,21 @@ where // Respect `top_retain` if self.ctx.in_top_level() && self.options.top_retain.contains(&i.sym) { if cfg!(feature = "debug") { - log::trace!("inline: [x] top_retain"); + tracing::trace!("inline: [x] top_retain"); } return; } if self.ctx.is_exported { if cfg!(feature = "debug") { - log::trace!("inline: [x] exported"); + tracing::trace!("inline: [x] exported"); } return; } if self.ctx.inline_as_assignment { if cfg!(feature = "debug") { - log::trace!("inline: [x] inline_as_assignment=true"); + tracing::trace!("inline: [x] inline_as_assignment=true"); } return; } @@ -417,14 +417,14 @@ where { if usage.declared_as_catch_param { if cfg!(feature = "debug") { - log::trace!("inline: [x] Declared as a catch paramter"); + tracing::trace!("inline: [x] Declared as a catch paramter"); } return; } if usage.reassigned || usage.inline_prevented { if cfg!(feature = "debug") { - log::trace!( + tracing::trace!( "inline: [x] reassigned = {}, inline_prevented = {}", usage.reassigned, usage.inline_prevented @@ -441,7 +441,7 @@ where if !UsageFinder::find(&i, body) && self.is_fn_body_simple_enough_to_inline(body) { - log::debug!( + tracing::debug!( "inline: Decided to inline function '{}{:?}' as it's very \ simple", f.ident.sym, @@ -500,14 +500,14 @@ where self.changed = true; match &decl { Decl::Class(c) => { - log::debug!( + tracing::debug!( "inline: Decided to inline class '{}{:?}' as it's used only once", c.ident.sym, c.ident.span.ctxt ); } Decl::Fn(f) => { - log::debug!( + tracing::debug!( "inline: Decided to inline function '{}{:?}' as it's used only once", f.ident.sym, f.ident.span.ctxt @@ -538,7 +538,7 @@ where return; } else { if cfg!(feature = "debug") { - log::trace!("inline: [x] Usage: {:?}", usage); + tracing::trace!("inline: [x] Usage: {:?}", usage); } } } @@ -582,7 +582,7 @@ where } self.changed = true; - log::debug!("inline: Replacing a variable with cheap expression"); + tracing::debug!("inline: Replacing a variable with cheap expression"); *e = *value; return; @@ -606,7 +606,7 @@ where if self.ctx.inline_as_assignment { if let Some(value) = self.state.vars_for_inlining.remove(&i.to_id()) { self.changed = true; - log::debug!( + tracing::debug!( "inline: Inlining '{}{:?}' using assignment", i.sym, i.span.ctxt @@ -620,7 +620,7 @@ where }); if cfg!(feature = "debug") { - log::trace!("inline: [Change] {}", dump(&*e)) + tracing::trace!("inline: [Change] {}", dump(&*e)) } return; } @@ -628,7 +628,7 @@ where if let Some(value) = self.state.vars_for_inlining.get(&i.to_id()) { self.changed = true; - log::debug!( + tracing::debug!( "inline: Replacing '{}{:?}' with an expression", i.sym, i.span.ctxt @@ -637,7 +637,7 @@ where *e = *value.clone(); if cfg!(feature = "debug") { - log::trace!("inline: [Change] {}", dump(&*e)) + tracing::trace!("inline: [Change] {}", dump(&*e)) } } } diff --git a/ecmascript/minifier/src/compress/optimize/join_vars.rs b/ecmascript/minifier/src/compress/optimize/join_vars.rs index 0a0258937f0..ce143779cf0 100644 --- a/ecmascript/minifier/src/compress/optimize/join_vars.rs +++ b/ecmascript/minifier/src/compress/optimize/join_vars.rs @@ -50,7 +50,7 @@ where } } - log::debug!("join_vars: Joining variables"); + tracing::debug!("join_vars: Joining variables"); self.changed = true; let mut cur: Option = None; diff --git a/ecmascript/minifier/src/compress/optimize/loops.rs b/ecmascript/minifier/src/compress/optimize/loops.rs index 74ff75c09fc..7ac55aa4e6d 100644 --- a/ecmascript/minifier/src/compress/optimize/loops.rs +++ b/ecmascript/minifier/src/compress/optimize/loops.rs @@ -43,7 +43,7 @@ where } self.changed = true; - log::debug!("loops: Removing a for loop with instant break"); + tracing::debug!("loops: Removing a for loop with instant break"); self.prepend_stmts .extend(f.init.take().map(|init| match init { VarDeclOrExpr::VarDecl(var) => Stmt::Decl(Decl::Var(var)), @@ -76,7 +76,7 @@ where let changed = UnreachableHandler::preserve_vars(stmt); self.changed |= changed; if changed { - log::debug!( + tracing::debug!( "loops: Removing unreachable while statement without side effects" ); } @@ -84,7 +84,9 @@ where let changed = UnreachableHandler::preserve_vars(&mut w.body); self.changed |= changed; if changed { - log::debug!("loops: Removing unreachable body of a while statement"); + tracing::debug!( + "loops: Removing unreachable body of a while statement" + ); } } } @@ -96,7 +98,7 @@ where let changed = UnreachableHandler::preserve_vars(&mut f.body); self.changed |= changed; if changed { - log::debug!("loops: Removing unreachable body of a for statement"); + tracing::debug!("loops: Removing unreachable body of a for statement"); } self.changed |= f.init.is_some() | f.update.is_some(); @@ -118,7 +120,7 @@ where } else if let Known(true) = val { if purity.is_pure() { self.changed = true; - log::debug!( + tracing::debug!( "loops: Remving `test` part of a for stmt as it's always true" ); f.test = None; @@ -154,7 +156,7 @@ where } else { s.init = None; self.changed = true; - log::debug!( + tracing::debug!( "loops: Removed side-effect-free expressions in `init` of a for stmt" ); } diff --git a/ecmascript/minifier/src/compress/optimize/mod.rs b/ecmascript/minifier/src/compress/optimize/mod.rs index cd32e4d0574..967ba284b8e 100644 --- a/ecmascript/minifier/src/compress/optimize/mod.rs +++ b/ecmascript/minifier/src/compress/optimize/mod.rs @@ -8,8 +8,8 @@ use crate::{ option::CompressOptions, util::{contains_leaping_yield, make_number, MoudleItemExt}, }; -use fxhash::FxHashMap; use retain_mut::RetainMut; +use rustc_hash::FxHashMap; use std::{fmt::Write, mem::take}; use swc_atoms::{js_word, JsWord}; use swc_common::{ @@ -590,7 +590,7 @@ where } } - log::debug!("Compressing array.join()"); + tracing::debug!("Compressing array.join()"); self.changed = true; *e = Expr::Lit(Lit::Str(Str { @@ -630,7 +630,7 @@ where match lit { Lit::Bool(v) => { self.changed = true; - log::debug!("Compressing boolean literal"); + tracing::debug!("Compressing boolean literal"); *e = Expr::Unary(UnaryExpr { span: v.span, op: op!("!"), @@ -674,13 +674,13 @@ where match e { Expr::Ident(..) | Expr::This(_) | Expr::Invalid(_) | Expr::Lit(..) => { - log::debug!("ignore_return_value: Dropping unused expr"); + tracing::debug!("ignore_return_value: Dropping unused expr"); self.changed = true; return None; } // Function expression cannot have a side effect. Expr::Fn(_) => { - log::debug!( + tracing::debug!( "ignore_return_value: Dropping unused fn expr as it does not have any side \ effect" ); @@ -822,7 +822,7 @@ where _ => false, } && args.is_empty() => { - log::debug!("ignore_return_value: Dropping a pure call"); + tracing::debug!("ignore_return_value: Dropping a pure call"); self.changed = true; return None; } @@ -902,7 +902,7 @@ where Expr::Array(arr) => { let mut exprs = vec![]; self.changed = true; - log::debug!("ignore_return_value: Inverting an array literal"); + tracing::debug!("ignore_return_value: Inverting an array literal"); for elem in arr.elems.take() { match elem { Some(mut elem) => { @@ -925,7 +925,7 @@ where Expr::Object(obj) => { let mut exprs = vec![]; self.changed = true; - log::debug!("ignore_return_value: Inverting an object literal"); + tracing::debug!("ignore_return_value: Inverting an object literal"); for prop in obj.props.take() { match prop { PropOrSpread::Spread(mut e) => { @@ -994,14 +994,14 @@ where _ => false, } => { - log::debug!("ignore_return_value: Preserving negated iife"); + tracing::debug!("ignore_return_value: Preserving negated iife"); return Some(e.take()); } // `delete` is handled above Expr::Unary(expr) => { self.changed = true; - log::debug!("ignore_return_value: Reducing unary ({})", expr.op); + tracing::debug!("ignore_return_value: Reducing unary ({})", expr.op); return self.ignore_return_value(&mut expr.arg); } @@ -1012,7 +1012,7 @@ where op, .. }) => { - log::debug!("ignore_return_value: Reducing binary ({})", *op); + tracing::debug!("ignore_return_value: Reducing binary ({})", *op); let left = self.ignore_return_value(&mut **left).map(Box::new); let right = self.ignore_return_value(&mut **right).map(Box::new); @@ -1025,7 +1025,7 @@ where } Expr::Cond(cond) => { - log::trace!("ignore_return_value: Cond expr"); + tracing::trace!("ignore_return_value: Cond expr"); self.restore_negated_iife(cond); @@ -1052,12 +1052,12 @@ where span: cond.span, test: cond.test.take(), cons: cons.unwrap_or_else(|| { - log::debug!("ignore_return_value: Dropped `cons`"); + tracing::debug!("ignore_return_value: Dropped `cons`"); self.changed = true; undefined(cons_span) }), alt: alt.unwrap_or_else(|| { - log::debug!("ignore_return_value: Dropped `alt`"); + tracing::debug!("ignore_return_value: Dropped `alt`"); self.changed = true; undefined(alt_span) }), @@ -1103,7 +1103,7 @@ where // Make return type undefined. if let Some(last) = exprs.last_mut() { - log::debug!("ignore_return_value: Shifting void"); + tracing::debug!("ignore_return_value: Shifting void"); self.changed = true; *last = Box::new(Expr::Unary(UnaryExpr { span: DUMMY_SP, @@ -1114,7 +1114,7 @@ where } if exprs.is_empty() { - log::debug!("ignore_return_value: Dropping empty seq"); + tracing::debug!("ignore_return_value: Dropping empty seq"); return None; } @@ -1202,7 +1202,7 @@ where }) .unwrap_or(js_word!("")); - log::debug!("Converting call to RegExp into a regexp literal"); + tracing::debug!("Converting call to RegExp into a regexp literal"); self.changed = true; *e = Expr::Lit(Lit::Regex(Regex { span, @@ -1269,8 +1269,8 @@ where self.changed = true; if cfg!(feature = "debug") { - log::debug!("Merging variable declarations"); - log::trace!( + tracing::debug!("Merging variable declarations"); + tracing::trace!( "[Before]: {}", dump(&BlockStmt { span: DUMMY_SP, @@ -1311,7 +1311,7 @@ where new.extend(var_decl.take().map(Decl::Var).map(Stmt::Decl)); if cfg!(feature = "debug") { - log::trace!( + tracing::trace!( "[Change] merged: {}", dump(&BlockStmt { span: DUMMY_SP, @@ -1338,7 +1338,7 @@ where Stmt::Decl(..) => false, _ => true, }) { - log::debug!("optimizer: Removing nested block"); + tracing::debug!("optimizer: Removing nested block"); self.changed = true; bs.stmts = block.stmts.take(); } @@ -1357,7 +1357,7 @@ where _ => false, }) { - log::debug!("optimizer: Unwrapping a block with variable statements"); + tracing::debug!("optimizer: Unwrapping a block with variable statements"); self.changed = true; *s = bs.stmts[0].take(); return; @@ -1367,7 +1367,7 @@ where if let Stmt::Block(block) = &stmt { if block.stmts.is_empty() { self.changed = true; - log::debug!("optimizer: Removing empty block"); + tracing::debug!("optimizer: Removing empty block"); *stmt = Stmt::Empty(EmptyStmt { span: DUMMY_SP }); } } @@ -1377,12 +1377,12 @@ where match &bs.stmts[0] { Stmt::Expr(..) | Stmt::If(..) => { *s = bs.stmts[0].take(); - log::debug!("optimizer: Unwrapping block stmt"); + tracing::debug!("optimizer: Unwrapping block stmt"); self.changed = true; } Stmt::Decl(Decl::Fn(..)) if !self.ctx.in_strict => { *s = bs.stmts[0].take(); - log::debug!("optimizer: Unwrapping block stmt in non strcit mode"); + tracing::debug!("optimizer: Unwrapping block stmt in non strcit mode"); self.changed = true; } _ => {} @@ -1455,7 +1455,7 @@ where match &mut *stmt.cons { Stmt::Expr(cons) => { self.changed = true; - log::debug!("Converting if statement to a form `test && cons`"); + tracing::debug!("Converting if statement to a form `test && cons`"); *s = Stmt::Expr(ExprStmt { span: stmt.span, expr: Box::new(stmt.test.take().make_bin(op!("&&"), *cons.expr.take())), @@ -1586,7 +1586,7 @@ where span: DUMMY_SP, value: 0.0, }))); - log::trace!("injecting zero to preserve `this` in call"); + tracing::trace!("injecting zero to preserve `this` in call"); *callee = Box::new(Expr::Seq(SeqExpr { span: callee.span(), @@ -1731,7 +1731,7 @@ where Expr::Bin(bin) => { let expr = self.optimize_lit_cmp(bin); if let Some(expr) = expr { - log::debug!("Optimizing: Literal comparison"); + tracing::debug!("Optimizing: Literal comparison"); self.changed = true; *e = expr; } @@ -2001,7 +2001,7 @@ where self.with_ctx(ctx).handle_stmt_likes(stmts); for (from, to) in self.state.inlined_vars.drain() { - log::debug!("inline: Inlining `{}{:?}`", from.0, from.1); + tracing::debug!("inline: Inlining `{}{:?}`", from.0, from.1); replace_id_with_expr(stmts, from, to); } @@ -2035,7 +2035,7 @@ where match s.as_deref() { Some(Stmt::Empty(..)) => { self.changed = true; - log::debug!("misc: Removing empty statement"); + tracing::debug!("misc: Removing empty statement"); *s = None; } _ => {} @@ -2177,7 +2177,7 @@ where _ => false, } { - log::debug!("Removing 'use strict'"); + tracing::debug!("Removing 'use strict'"); *s = Stmt::Empty(EmptyStmt { span: DUMMY_SP }); return; } @@ -2188,9 +2188,9 @@ where if can_be_removed { self.changed = true; - log::debug!("unused: Dropping an expression without side effect"); + tracing::debug!("unused: Dropping an expression without side effect"); if cfg!(feature = "debug") { - log::trace!("unused: [Change] Dropping \n{}\n", dump(&*expr)); + tracing::trace!("unused: [Change] Dropping \n{}\n", dump(&*expr)); } *s = Stmt::Empty(EmptyStmt { span: DUMMY_SP }); return; @@ -2374,7 +2374,9 @@ where if let Some(e) = &var.init { if is_pure_undefined(e) { self.changed = true; - log::debug!("Dropping explicit initializer which evaluates to `undefined`"); + tracing::debug!( + "Dropping explicit initializer which evaluates to `undefined`" + ); var.init = None; } diff --git a/ecmascript/minifier/src/compress/optimize/ops.rs b/ecmascript/minifier/src/compress/optimize/ops.rs index 88257a97d08..cde022dfca0 100644 --- a/ecmascript/minifier/src/compress/optimize/ops.rs +++ b/ecmascript/minifier/src/compress/optimize/ops.rs @@ -47,7 +47,7 @@ where if e.op == op!("===") || e.op == op!("!==") { if (e.left.is_ident() || e.left.is_member()) && e.left.eq_ignore_span(&e.right) { self.changed = true; - log::debug!("Reducing comparison of same variable ({})", e.op); + tracing::debug!("Reducing comparison of same variable ({})", e.op); e.op = if e.op == op!("===") { op!("==") @@ -67,7 +67,9 @@ where if lt == rt { e.op = op!("=="); self.changed = true; - log::debug!("Reduced `===` to `==` because types of operands are identical") + tracing::debug!( + "Reduced `===` to `==` because types of operands are identical" + ) } } } @@ -89,7 +91,7 @@ where let value = if n.op == op!("==") { l == r } else { l != r }; - log::debug!("Optimizing: literal comparison => bool"); + tracing::debug!("Optimizing: literal comparison => bool"); self.changed = true; return Some(Expr::Lit(Lit::Bool(Bool { span: n.span, @@ -129,7 +131,7 @@ where | Expr::Bin(BinExpr { op: op!(">"), .. }) => { if let Known(Type::Bool) = arg.get_type() { self.changed = true; - log::debug!("Optimizing: `!!expr` => `expr`"); + tracing::debug!("Optimizing: `!!expr` => `expr`"); *e = *arg.take(); } @@ -212,7 +214,7 @@ where _ => return, }; - log::debug!("Compressing: `e = 3 & e` => `e &= 3`"); + tracing::debug!("Compressing: `e = 3 & e` => `e &= 3`"); self.changed = true; e.op = op; @@ -272,13 +274,13 @@ where if rb { self.changed = true; - log::debug!("Optimizing: e && true => !!e"); + tracing::debug!("Optimizing: e && true => !!e"); self.negate_twice(&mut bin.left); *e = *bin.left.take(); } else { self.changed = true; - log::debug!("Optimizing: e && false => e"); + tracing::debug!("Optimizing: e && false => e"); *e = *bin.left.take(); } @@ -292,7 +294,7 @@ where if !rb { self.changed = true; - log::debug!("Optimizing: e || false => !!e"); + tracing::debug!("Optimizing: e || false => !!e"); self.negate_twice(&mut bin.left); *e = *bin.left.take(); @@ -352,7 +354,7 @@ where match l { Expr::Lit(Lit::Null(..)) => { - log::debug!("Removing null from lhs of ??"); + tracing::debug!("Removing null from lhs of ??"); self.changed = true; *e = r.take(); return; @@ -362,7 +364,7 @@ where | Expr::Lit(Lit::BigInt(..)) | Expr::Lit(Lit::Bool(..)) | Expr::Lit(Lit::Regex(..)) => { - log::debug!("Removing rhs of ?? as lhs cannot be null nor undefined"); + tracing::debug!("Removing rhs of ?? as lhs cannot be null nor undefined"); self.changed = true; *e = l.take(); return; @@ -386,7 +388,7 @@ where }) => match &**arg { Expr::Ident(arg) => { if let Some(value) = self.typeofs.get(&arg.to_id()).cloned() { - log::debug!( + tracing::debug!( "Converting typeof of variable to literal as we know the value" ); self.changed = true; @@ -401,7 +403,7 @@ where } Expr::Arrow(..) | Expr::Fn(..) => { - log::debug!("Converting typeof to 'function' as we know the value"); + tracing::debug!("Converting typeof to 'function' as we know the value"); self.changed = true; *e = Expr::Lit(Lit::Str(Str { span: *span, @@ -413,7 +415,7 @@ where } Expr::Array(..) | Expr::Object(..) => { - log::debug!("Converting typeof to 'object' as we know the value"); + tracing::debug!("Converting typeof to 'object' as we know the value"); self.changed = true; *e = Expr::Lit(Lit::Str(Str { span: *span, diff --git a/ecmascript/minifier/src/compress/optimize/sequences.rs b/ecmascript/minifier/src/compress/optimize/sequences.rs index e4dded80e6d..6efc92ed5ad 100644 --- a/ecmascript/minifier/src/compress/optimize/sequences.rs +++ b/ecmascript/minifier/src/compress/optimize/sequences.rs @@ -134,7 +134,7 @@ where } } - log::debug!("sequences: Compressing statements as a sequences"); + tracing::debug!("sequences: Compressing statements as a sequences"); self.changed = true; let mut exprs = vec![]; @@ -414,7 +414,9 @@ where } } self.changed = true; - log::debug!("sequences: Splitted a sequence exprssion to multiple expression statements"); + tracing::debug!( + "sequences: Splitted a sequence exprssion to multiple expression statements" + ); *stmts = new_stmts; } @@ -448,7 +450,7 @@ where if !can_work { return; } - log::debug!("sequences: Lifting"); + tracing::debug!("sequences: Lifting"); self.changed = true; } @@ -522,7 +524,7 @@ where continue; } self.changed = true; - log::debug!("sequences: Hoisting `var` without init"); + tracing::debug!("sequences: Hoisting `var` without init"); let s = Stmt::Decl(Decl::Var(VarDecl { span: v.span, kind: VarDeclKind::Var, @@ -567,7 +569,7 @@ where if lhs.sym == last_id.sym && lhs.span.ctxt == last_id.span.ctxt { e.exprs.pop(); self.changed = true; - log::debug!("sequences: Shifting assignment"); + tracing::debug!("sequences: Shifting assignment"); return; } }; @@ -592,7 +594,7 @@ where if let Some(last) = e.exprs.last() { if is_pure_undefined(&last) { self.changed = true; - log::debug!("sequences: Shifting void"); + tracing::debug!("sequences: Shifting void"); e.exprs.pop(); let last = e.exprs.last_mut().unwrap(); @@ -637,14 +639,14 @@ where if !self.options.sequences() && !self.options.collapse_vars { if cfg!(feature = "debug") { - log::trace!("sequences: [x] Disabled"); + tracing::trace!("sequences: [x] Disabled"); } return; } if self.ctx.in_top_level() && !self.options.top_level() { if cfg!(feature = "debug") { - log::trace!("sequences: [x] Top level"); + tracing::trace!("sequences: [x] Top level"); } return; } @@ -677,7 +679,7 @@ where exprs.push(buf); if cfg!(feature = "debug") { - log::trace!( + tracing::trace!( "sequences: Merging statements: {:?}", exprs.iter().map(|v| v.len()).collect::>() ); @@ -780,7 +782,7 @@ where Mergable::Expr(e2) => { if !self.is_skippable_for_seq(Some(a), &*e2) { if cfg!(feature = "debug") && false { - log::trace!("Cannot skip: {}", dump(&**e2)); + tracing::trace!("Cannot skip: {}", dump(&**e2)); } break; @@ -922,19 +924,19 @@ where Expr::Update(..) => return false, Expr::Cond(b) => { - log::trace!("seq: Try test of cond"); + tracing::trace!("seq: Try test of cond"); return self.merge_sequential_expr(a, &mut *b.test); } Expr::Unary(b) => { - log::trace!("seq: Try arg of unary"); + tracing::trace!("seq: Try arg of unary"); return self.merge_sequential_expr(a, &mut b.arg); } Expr::Bin(BinExpr { op, left, right, .. }) => { - log::trace!("seq: Try left of bin"); + tracing::trace!("seq: Try left of bin"); if self.merge_sequential_expr(a, &mut **left) { return true; } @@ -948,7 +950,7 @@ where _ => {} } - log::trace!("seq: Try right of bin"); + tracing::trace!("seq: Try right of bin"); return self.merge_sequential_expr(a, &mut **right); } @@ -957,7 +959,7 @@ where computed: false, .. }) => { - log::trace!("seq: Try object of member"); + tracing::trace!("seq: Try object of member"); return self.merge_sequential_expr(a, &mut **obj); } @@ -967,7 +969,7 @@ where computed: true, .. }) => { - log::trace!("seq: Try object of member (computed)"); + tracing::trace!("seq: Try object of member (computed)"); if self.merge_sequential_expr(a, &mut **obj) { return true; } @@ -976,14 +978,14 @@ where return false; } - log::trace!("seq: Try prop of member (computed)"); + tracing::trace!("seq: Try prop of member (computed)"); return self.merge_sequential_expr(a, &mut **prop); } Expr::Assign(b @ AssignExpr { op: op!("="), .. }) => { match &mut b.left { PatOrExpr::Expr(b) => { - log::trace!("seq: Try lhs of assign"); + tracing::trace!("seq: Try lhs of assign"); if self.merge_sequential_expr(a, &mut **b) { return true; } @@ -998,7 +1000,7 @@ where } PatOrExpr::Pat(b) => match &mut **b { Pat::Expr(b) => { - log::trace!("seq: Try lhs of assign"); + tracing::trace!("seq: Try lhs of assign"); if self.merge_sequential_expr(a, &mut **b) { return true; } @@ -1015,7 +1017,7 @@ where }, } - log::trace!("seq: Try rhs of assign"); + tracing::trace!("seq: Try rhs of assign"); return self.merge_sequential_expr(a, &mut b.right); } @@ -1040,7 +1042,7 @@ where }, } - log::trace!("seq: Try rhs of assign with op"); + tracing::trace!("seq: Try rhs of assign with op"); return self.merge_sequential_expr(a, &mut b.right); } @@ -1048,7 +1050,7 @@ where for elem in &mut b.elems { match elem { Some(elem) => { - log::trace!("seq: Try element of array"); + tracing::trace!("seq: Try element of array"); if self.merge_sequential_expr(a, &mut elem.expr) { return true; } @@ -1074,7 +1076,7 @@ where .. }) => { let is_this_undefined = b_callee.is_ident(); - log::trace!("seq: Try callee of call"); + tracing::trace!("seq: Try callee of call"); if self.merge_sequential_expr(a, &mut **b_callee) { if is_this_undefined { match &**b_callee { @@ -1083,7 +1085,7 @@ where span: DUMMY_SP, value: 0.0, }))); - log::trace!("injecting zero to preserve `this` in call"); + tracing::trace!("injecting zero to preserve `this` in call"); *b_callee = Box::new(Expr::Seq(SeqExpr { span: b_callee.span(), @@ -1103,7 +1105,7 @@ where } for arg in b_args { - log::trace!("seq: Try arg of call"); + tracing::trace!("seq: Try arg of call"); if self.merge_sequential_expr(a, &mut arg.expr) { return true; } @@ -1119,7 +1121,7 @@ where Expr::New(NewExpr { callee: b_callee, .. }) => { - log::trace!("seq: Try callee of new"); + tracing::trace!("seq: Try callee of new"); if self.merge_sequential_expr(a, &mut **b_callee) { return true; } @@ -1129,7 +1131,7 @@ where Expr::Seq(SeqExpr { exprs: b_exprs, .. }) => { for b_expr in b_exprs { - log::trace!("seq: Try elem of seq"); + tracing::trace!("seq: Try elem of seq"); if self.merge_sequential_expr(a, &mut **b_expr) { return true; @@ -1206,7 +1208,7 @@ where } // if cfg!(feature = "debug") && false { - // log::trace!( + // tracing::trace!( // "sequences: Trying to merge `{}` => `{}`", // dump(&*a), // dump(&*b) @@ -1243,7 +1245,7 @@ where }; b.visit_with(&Invalid { span: DUMMY_SP }, &mut v); if v.expr_usage != 1 || v.pat_usage != 0 { - log::trace!( + tracing::trace!( "[X] sequences: Aborting merging of an update expression \ because of usage counts ({}, ref = {}, pat = {})", a_id, @@ -1294,7 +1296,7 @@ where let left_id = match get_lhs_ident(left) { Some(v) => v, None => { - log::trace!("[X] sequences: Aborting because lhs is not an id"); + tracing::trace!("[X] sequences: Aborting because lhs is not an id"); return false; } }; @@ -1305,7 +1307,7 @@ where .and_then(|data| data.vars.get(&left_id.to_id())) { if usage.declared_as_fn_expr { - log::trace!( + tracing::trace!( "sequences: [X] Declared as fn expr ({}, {:?})", left_id.sym, left_id.span.ctxt @@ -1387,7 +1389,7 @@ where } if used_by_b.contains(id) { - log::trace!("[X] sequences: Aborting because of deps"); + tracing::trace!("[X] sequences: Aborting because of deps"); return false; } } @@ -1402,7 +1404,7 @@ where }; b.visit_with(&Invalid { span: DUMMY_SP }, &mut v); if v.expr_usage != 1 || v.pat_usage != 0 { - log::trace!( + tracing::trace!( "[X] sequences: Aborting because of usage counts ({}{:?}, ref = {}, pat = {})", left_id.sym, left_id.span.ctxt, @@ -1414,7 +1416,7 @@ where } self.changed = true; - log::debug!( + tracing::debug!( "sequences: Inlining sequential expressions (`{}{:?}`)", left_id.sym, left_id.span.ctxt diff --git a/ecmascript/minifier/src/compress/optimize/strings.rs b/ecmascript/minifier/src/compress/optimize/strings.rs index 20313301888..0f24dac13a8 100644 --- a/ecmascript/minifier/src/compress/optimize/strings.rs +++ b/ecmascript/minifier/src/compress/optimize/strings.rs @@ -38,7 +38,7 @@ where match &*args[0].expr { Expr::Lit(Lit::Str(..)) => { self.changed = true; - log::debug!( + tracing::debug!( "strings: Unsafely reduced `RegExp` call in a string context" ); @@ -67,7 +67,7 @@ where Expr::Lit(Lit::Str(..)) => { *n = *e.expr.take(); self.changed = true; - log::debug!("string: Removed a paren in a string context"); + tracing::debug!("string: Removed a paren in a string context"); } _ => {} } @@ -81,7 +81,7 @@ where let value = n.as_string(); if let Known(value) = value { self.changed = true; - log::debug!( + tracing::debug!( "strings: Converted an expression into a string literal (in string context)" ); *n = Expr::Lit(Lit::Str(Str { @@ -96,7 +96,7 @@ where match n { Expr::Lit(Lit::Num(v)) => { self.changed = true; - log::debug!( + tracing::debug!( "strings: Converted a numeric literal ({}) into a string literal (in string \ context)", v.value @@ -116,7 +116,7 @@ where return; } self.changed = true; - log::debug!( + tracing::debug!( "strings: Converted a regex (/{}/{}) into a string literal (in string context)", v.exp, v.flags @@ -143,7 +143,7 @@ where .unwrap_or(false) { self.changed = true; - log::debug!( + tracing::debug!( "strings: Converting a reference ({}{:?}) into `undefined` (in string \ context)", i.sym, diff --git a/ecmascript/minifier/src/compress/optimize/switches.rs b/ecmascript/minifier/src/compress/optimize/switches.rs index 567afb0d793..54570dddc02 100644 --- a/ecmascript/minifier/src/compress/optimize/switches.rs +++ b/ecmascript/minifier/src/compress/optimize/switches.rs @@ -57,9 +57,9 @@ where return; } - log::debug!("switches: Removing unreachable cases from a constant switch"); + tracing::debug!("switches: Removing unreachable cases from a constant switch"); } else { - log::debug!("switches: Removing a constant switch"); + tracing::debug!("switches: Removing a constant switch"); } self.changed = true; @@ -217,7 +217,7 @@ where if !preserve_cases { if let Some(last_non_empty) = last_non_empty { if last_non_empty + 1 != cases.len() { - log::debug!("switches: Removing empty cases at the end"); + tracing::debug!("switches: Removing empty cases at the end"); self.changed = true; cases.drain(last_non_empty + 1..); } @@ -227,7 +227,7 @@ where if let Some(last) = cases.last_mut() { match last.cons.last() { Some(Stmt::Break(BreakStmt { label: None, .. })) => { - log::debug!("switches: Removing `break` at the end"); + tracing::debug!("switches: Removing `break` at the end"); self.changed = true; last.cons.pop(); } @@ -288,7 +288,7 @@ where if let Some(idx) = found { self.changed = true; - log::debug!("switches: Merging cases with same cons"); + tracing::debug!("switches: Merging cases with same cons"); cases[idx].cons.clear(); } } diff --git a/ecmascript/minifier/src/compress/optimize/unused.rs b/ecmascript/minifier/src/compress/optimize/unused.rs index 98c3f28cc40..c3b878cbe12 100644 --- a/ecmascript/minifier/src/compress/optimize/unused.rs +++ b/ecmascript/minifier/src/compress/optimize/unused.rs @@ -100,7 +100,7 @@ where } if cfg!(feature = "debug") { - log::trace!("unused: drop_unused_vars({})", dump(&*name)); + tracing::trace!("unused: drop_unused_vars({})", dump(&*name)); } // Top-level @@ -110,7 +110,7 @@ where if !self.options.top_level() && self.options.top_retain.is_empty() { if self.ctx.in_top_level() { if cfg!(feature = "debug") { - log::trace!( + tracing::trace!( "unused: [X] Preserving `var` `{}` because it's top-level", dump(&*name) ); @@ -123,7 +123,7 @@ where Some(VarDeclKind::Let) | Some(VarDeclKind::Const) => { if !self.options.top_level() && self.ctx.is_top_level_for_block_level_vars() { if cfg!(feature = "debug") { - log::trace!( + tracing::trace!( "unused: [X] Preserving block scoped var `{}` because it's \ top-level", dump(&*name) @@ -143,7 +143,7 @@ where { if scope.has_eval_call || scope.has_with_stmt { if cfg!(feature = "debug") { - log::trace!( + tracing::trace!( "unused: [X] Preserving `{}` because of usages", dump(&*name) ); @@ -192,7 +192,7 @@ where && self.options.top_retain.contains(&i.id.sym) { if cfg!(feature = "debug") { - log::trace!("unused: [X] Top-retain") + tracing::trace!("unused: [X] Top-retain") } return; } @@ -205,7 +205,7 @@ where .unwrap_or(false) { self.changed = true; - log::debug!( + tracing::debug!( "unused: Dropping a variable '{}{:?}' because it is not used", i.id.sym, i.id.span.ctxt @@ -215,7 +215,7 @@ where return; } else { if cfg!(feature = "debug") { - log::trace!("unused: Cannot drop ({}) becaue it's used", dump(&*i)); + tracing::trace!("unused: Cannot drop ({}) becaue it's used", dump(&*i)); } } } @@ -347,7 +347,7 @@ where .unwrap_or(false) { self.changed = true; - log::debug!( + tracing::debug!( "unused: Dropping a decl '{}{:?}' because it is not used", ident.sym, ident.span.ctxt @@ -396,7 +396,7 @@ where } if cfg!(feature = "debug") { - log::trace!( + tracing::trace!( "unused: drop_unused_assignments: Target: `{}`", dump(&assign.left) ) @@ -407,7 +407,7 @@ where && self.ctx.in_top_level() { if cfg!(feature = "debug") { - log::trace!( + tracing::trace!( "unused: Preserving assignment to `{}` because it's top-level", dump(&assign.left) ) @@ -418,7 +418,7 @@ where match &mut assign.left { PatOrExpr::Expr(_) => { if cfg!(feature = "debug") { - log::trace!( + tracing::trace!( "unused: Preserving assignment to `{}` because it's an expression", dump(&assign.left) ) @@ -437,7 +437,7 @@ where .and_then(|data| data.vars.get(&i.to_id())) { if var.is_fn_local && var.usage_count == 0 && var.declared { - log::debug!( + tracing::debug!( "unused: Dropping assignment to var '{}{:?}', which is never used", i.id.sym, i.id.span.ctxt @@ -447,7 +447,7 @@ where return; } else { if cfg!(feature = "debug") { - log::trace!( + tracing::trace!( "unused: Preserving assignment to `{}` because of usage: {:?}", dump(&assign.left), var @@ -481,7 +481,7 @@ where if can_remove_ident { self.changed = true; - log::debug!("Removing ident of an class / function expression"); + tracing::debug!("Removing ident of an class / function expression"); *name = None; } } @@ -505,7 +505,7 @@ where } self.changed = true; - log::debug!( + tracing::debug!( "unused: Removing the name of a function expression because it's not used by \ it'" ); diff --git a/ecmascript/minifier/src/compress/pure/arrows.rs b/ecmascript/minifier/src/compress/pure/arrows.rs index eb728a2d9f4..d9a08c2a3b4 100644 --- a/ecmascript/minifier/src/compress/pure/arrows.rs +++ b/ecmascript/minifier/src/compress/pure/arrows.rs @@ -19,7 +19,7 @@ where if s.stmts.len() == 1 { if let Stmt::Return(s) = &mut s.stmts[0] { if let Some(arg) = &mut s.arg { - log::debug!("arrows: Optimizing the body of an arrow"); + tracing::debug!("arrows: Optimizing the body of an arrow"); *b = BlockStmtOrExpr::Expr(arg.take()); return; } diff --git a/ecmascript/minifier/src/compress/pure/bools.rs b/ecmascript/minifier/src/compress/pure/bools.rs index fd5fbced661..dda1c807cd0 100644 --- a/ecmascript/minifier/src/compress/pure/bools.rs +++ b/ecmascript/minifier/src/compress/pure/bools.rs @@ -51,7 +51,7 @@ where { return; } - log::debug!("bools: Optimizing `!(a && b)` as `!a || !b`"); + tracing::debug!("bools: Optimizing `!(a && b)` as `!a || !b`"); self.changed = true; self.negate(arg, false); *e = *arg.take(); @@ -75,7 +75,7 @@ where { return; } - log::debug!("bools: Optimizing `!!(a || b)` as `!a && !b`"); + tracing::debug!("bools: Optimizing `!!(a || b)` as `!a && !b`"); self.negate(arg_of_arg, false); *e = *arg.take(); @@ -122,7 +122,7 @@ where if should_optimize(&e.left, &e.right, &self.options) || should_optimize(&e.right, &e.left, &self.options) { - log::debug!("bools: Compressing comparison of `typeof` with literal"); + tracing::debug!("bools: Compressing comparison of `typeof` with literal"); self.changed = true; e.op = match e.op { op!("===") => { @@ -176,9 +176,9 @@ where if can_remove { if *op == op!("&&") { - log::debug!("booleans: Compressing `!foo && true` as `!foo`"); + tracing::debug!("booleans: Compressing `!foo && true` as `!foo`"); } else { - log::debug!("booleans: Compressing `!foo || false` as `!foo`"); + tracing::debug!("booleans: Compressing `!foo || false` as `!foo`"); } self.changed = true; *e = *left.take(); @@ -256,7 +256,7 @@ where } else { self.changed = true; let span = delete.arg.span(); - log::debug!("booleans: Compressing `delete` as sequence expression"); + tracing::debug!("booleans: Compressing `delete` as sequence expression"); *e = Expr::Seq(SeqExpr { span, exprs: vec![delete.arg.take(), Box::new(make_bool(span, true))], @@ -271,7 +271,7 @@ where if convert_to_true { self.changed = true; let span = delete.arg.span(); - log::debug!("booleans: Compressing `delete` => true"); + tracing::debug!("booleans: Compressing `delete` => true"); *e = make_bool(span, true); return; } @@ -290,7 +290,7 @@ where if exprs.is_empty() { return; } - log::debug!("bools: Optimizing negated sequences"); + tracing::debug!("bools: Optimizing negated sequences"); { let last = exprs.last_mut().unwrap(); @@ -344,7 +344,7 @@ where arg, }) => match &mut **arg { Expr::Lit(Lit::Num(Number { value, .. })) => { - log::debug!("Optimizing: number => number (in bool context)"); + tracing::debug!("Optimizing: number => number (in bool context)"); self.changed = true; *n = Expr::Lit(Lit::Num(Number { @@ -356,7 +356,7 @@ where Expr::Unary(UnaryExpr { op: op!("!"), arg, .. }) => { - log::debug!("bools: !!expr => expr (in bool ctx)"); + tracing::debug!("bools: !!expr => expr (in bool ctx)"); self.changed = true; *n = *arg.take(); return; @@ -369,7 +369,7 @@ where op: op!("typeof"), arg, }) => { - log::debug!("Optimizing: typeof => true (in bool context)"); + tracing::debug!("Optimizing: typeof => true (in bool context)"); self.changed = true; match &**arg { @@ -394,7 +394,7 @@ where } Expr::Lit(Lit::Str(s)) => { - log::debug!("Converting string as boolean expressions"); + tracing::debug!("Converting string as boolean expressions"); self.changed = true; *n = Expr::Lit(Lit::Num(Number { span: s.span, @@ -407,7 +407,7 @@ where return; } if self.options.bools { - log::debug!("booleans: Converting number as boolean expressions"); + tracing::debug!("booleans: Converting number as boolean expressions"); self.changed = true; *n = Expr::Lit(Lit::Num(Number { span: num.span, @@ -424,7 +424,7 @@ where }) => { // Optimize if (a ?? false); as if (a); if let Value::Known(false) = right.as_pure_bool() { - log::debug!( + tracing::debug!( "Dropping right operand of `??` as it's always false (in bool context)" ); self.changed = true; @@ -441,7 +441,7 @@ where // `a || false` => `a` (as it will be casted to boolean anyway) if let Value::Known(false) = right.as_pure_bool() { - log::debug!("bools: `expr || false` => `expr` (in bool context)"); + tracing::debug!("bools: `expr || false` => `expr` (in bool context)"); self.changed = true; *n = *left.take(); return; @@ -452,7 +452,7 @@ where let span = n.span(); let v = n.as_pure_bool(); if let Value::Known(v) = v { - log::debug!("Optimizing expr as {} (in bool context)", v); + tracing::debug!("Optimizing expr as {} (in bool context)", v); *n = make_bool(span, v); return; } @@ -541,7 +541,7 @@ where } if self.can_swap_bin_operands(&left, &right, false) { - log::debug!("Swapping operands of binary exprssion"); + tracing::debug!("Swapping operands of binary exprssion"); swap(left, right); return true; } @@ -556,7 +556,7 @@ where | Expr::Bin(e @ BinExpr { op: op!("<"), .. }) => { if self.options.comparisons && self.can_swap_bin_operands(&e.left, &e.right, true) { self.changed = true; - log::debug!("comparisons: Swapping operands of {}", e.op); + tracing::debug!("comparisons: Swapping operands of {}", e.op); e.op = if e.op == op!("<=") { op!(">=") @@ -635,7 +635,7 @@ where match (lt, rt) { (Type::Undefined, Type::Null) | (Type::Null, Type::Undefined) => { if op == op!("===") { - log::debug!( + tracing::debug!( "Reducing `!== null || !== undefined` check to `!= null`" ); return Some(BinExpr { @@ -645,7 +645,7 @@ where right: Box::new(Expr::Lit(Lit::Null(Null { span: DUMMY_SP }))), }); } else { - log::debug!( + tracing::debug!( "Reducing `=== null || === undefined` check to `== null`" ); return Some(BinExpr { diff --git a/ecmascript/minifier/src/compress/pure/conds.rs b/ecmascript/minifier/src/compress/pure/conds.rs index 54e2f309d49..147485af572 100644 --- a/ecmascript/minifier/src/compress/pure/conds.rs +++ b/ecmascript/minifier/src/compress/pure/conds.rs @@ -23,7 +23,7 @@ where if let Value::Known(Type::Bool) = lt { let lb = cond.cons.as_pure_bool(); if let Value::Known(true) = lb { - log::debug!("conditionals: `foo ? true : bar` => `!!foo || bar`"); + tracing::debug!("conditionals: `foo ? true : bar` => `!!foo || bar`"); // Negate twice to convert `test` to boolean. self.negate_twice(&mut cond.test); @@ -40,7 +40,7 @@ where // TODO: Verify this rule. if let Value::Known(false) = lb { - log::debug!("conditionals: `foo ? false : bar` => `!foo && bar`"); + tracing::debug!("conditionals: `foo ? false : bar` => `!foo && bar`"); self.changed = true; self.negate(&mut cond.test, false); @@ -59,7 +59,7 @@ where if let Value::Known(Type::Bool) = rt { let rb = cond.alt.as_pure_bool(); if let Value::Known(false) = rb { - log::debug!("conditionals: `foo ? bar : false` => `!!foo && bar`"); + tracing::debug!("conditionals: `foo ? bar : false` => `!!foo && bar`"); self.changed = true; // Negate twice to convert `test` to boolean. @@ -75,7 +75,7 @@ where } if let Value::Known(true) = rb { - log::debug!("conditionals: `foo ? bar : true` => `!foo || bar"); + tracing::debug!("conditionals: `foo ? bar : true` => `!foo || bar"); self.changed = true; self.negate(&mut cond.test, false); @@ -107,7 +107,7 @@ where (Expr::Bin(cons @ BinExpr { op: op!("||"), .. }), alt) if (*cons.right).eq_ignore_span(&*alt) => { - log::debug!("conditionals: `x ? y || z : z` => `x || y && z`"); + tracing::debug!("conditionals: `x ? y || z : z` => `x || y && z`"); self.changed = true; *e = Expr::Bin(BinExpr { @@ -133,14 +133,14 @@ where } self.changed = true; - log::debug!("conditionals: `a ? foo : bar` => `!a ? bar : foo` (considered cost)"); + tracing::debug!("conditionals: `a ? foo : bar` => `!a ? bar : foo` (considered cost)"); let start_str = dump(&*cond); self.negate(&mut cond.test, true); swap(&mut cond.cons, &mut cond.alt); if cfg!(feature = "debug") { - log::trace!( + tracing::trace!( "[Change] Negated cond: `{}` => `{}`", start_str, dump(&*cond) @@ -177,7 +177,7 @@ where // `!!b || true` => true if let Value::Known(true) = rb { self.changed = true; - log::debug!("conditionals: `!!foo || true` => `true`"); + tracing::debug!("conditionals: `!!foo || true` => `true`"); *e = make_bool(bin.span, true); return; } diff --git a/ecmascript/minifier/src/compress/pure/dead_code.rs b/ecmascript/minifier/src/compress/pure/dead_code.rs index 60288d952e8..3948615275f 100644 --- a/ecmascript/minifier/src/compress/pure/dead_code.rs +++ b/ecmascript/minifier/src/compress/pure/dead_code.rs @@ -45,7 +45,7 @@ where } self.changed = true; - log::debug!("Dropping useless block"); + tracing::debug!("Dropping useless block"); let mut new = vec![]; for stmt in stmts.take() { @@ -73,7 +73,7 @@ where op: op!("void"), arg, })) => { - log::debug!("unused: Removing `return void` in end of a function"); + tracing::debug!("unused: Removing `return void` in end of a function"); self.changed = true; *s = Stmt::Expr(ExprStmt { span: *span, @@ -103,7 +103,7 @@ where } self.changed = true; - log::debug!("dead_code: Removing dead codes"); + tracing::debug!("dead_code: Removing dead codes"); let mut new = vec![]; @@ -170,7 +170,7 @@ where } self.changed = true; - log::debug!("dead_code: Removing unreachable statements"); + tracing::debug!("dead_code: Removing unreachable statements"); let extras = stmts.drain(last..).collect::>(); diff --git a/ecmascript/minifier/src/compress/pure/evaluate.rs b/ecmascript/minifier/src/compress/pure/evaluate.rs index d90d585fc45..d65b78bba99 100644 --- a/ecmascript/minifier/src/compress/pure/evaluate.rs +++ b/ecmascript/minifier/src/compress/pure/evaluate.rs @@ -78,7 +78,7 @@ where match call.args.len() { 0 => { self.changed = true; - log::debug!("evaluate: Dropping array.slice call"); + tracing::debug!("evaluate: Dropping array.slice call"); *e = *obj.take(); return; } @@ -87,7 +87,10 @@ where let start = start.floor() as usize; self.changed = true; - log::debug!("evaluate: Reducing array.slice({}) call", start); + tracing::debug!( + "evaluate: Reducing array.slice({}) call", + start + ); if start >= arr.elems.len() { *e = Expr::Array(ArrayLit { @@ -112,7 +115,7 @@ where if let Value::Known(end) = end { let end = end.floor() as usize; self.changed = true; - log::debug!( + tracing::debug!( "evaluate: Reducing array.slice({}, {}) call", start, end @@ -198,7 +201,7 @@ where } self.changed = true; - log::debug!( + tracing::debug!( "evaludate: Reduced `funtion.valueOf()` into a function expression" ); @@ -229,7 +232,7 @@ where .. }) => { self.changed = true; - log::debug!( + tracing::debug!( "evaluate: Reducing a call to `Number` into an unary operation" ); @@ -289,7 +292,7 @@ where let value = num_to_fixed(num.value, precision + 1); self.changed = true; - log::debug!( + tracing::debug!( "evaluate: Evaluating `{}.toFixed({})` as `{}`", num, precision, @@ -323,7 +326,7 @@ where // if is_pure_undefined_or_null(&obj) { self.changed = true; - log::debug!( + tracing::debug!( "evaluate: Reduced an optioanl chaining operation because object is \ always null or undefined" ); @@ -340,7 +343,7 @@ where }) => { if is_pure_undefined_or_null(&callee) { self.changed = true; - log::debug!( + tracing::debug!( "evaluate: Reduced a call expression with optioanl chaining operation \ because object is always null or undefined" ); @@ -408,7 +411,7 @@ where match c { Some(v) => { self.changed = true; - log::debug!( + tracing::debug!( "evaluate: Evaluated `charCodeAt` of a string literal as `{}`", v ); @@ -419,7 +422,7 @@ where } None => { self.changed = true; - log::debug!( + tracing::debug!( "evaluate: Evaluated `charCodeAt` of a string literal as `NaN`", ); *e = Expr::Ident(Ident::new( @@ -435,7 +438,7 @@ where }; self.changed = true; - log::debug!("evaluate: Evaluated `{}` of a string literal", method); + tracing::debug!("evaluate: Evaluated `{}` of a string literal", method); *e = Expr::Lit(Lit::Str(Str { value: new_val.into(), ..s diff --git a/ecmascript/minifier/src/compress/pure/if_return.rs b/ecmascript/minifier/src/compress/pure/if_return.rs index 65964a8f416..dffc6aa8589 100644 --- a/ecmascript/minifier/src/compress/pure/if_return.rs +++ b/ecmascript/minifier/src/compress/pure/if_return.rs @@ -70,7 +70,7 @@ impl Pure<'_, M> { }; self.changed = true; - log::debug!( + tracing::debug!( "if_return: Negating `foo` in `if (foo) return; bar()` to make it `if (!foo) bar()`" ); diff --git a/ecmascript/minifier/src/compress/pure/loops.rs b/ecmascript/minifier/src/compress/pure/loops.rs index e76a076425f..58b19585caf 100644 --- a/ecmascript/minifier/src/compress/pure/loops.rs +++ b/ecmascript/minifier/src/compress/pure/loops.rs @@ -19,7 +19,7 @@ where match s { Stmt::While(stmt) => { self.changed = true; - log::debug!("loops: Converting a while loop to a for loop"); + tracing::debug!("loops: Converting a while loop to a for loop"); *s = Stmt::For(ForStmt { span: stmt.span, init: None, @@ -32,7 +32,7 @@ where let val = stmt.test.as_pure_bool(); if let Value::Known(true) = val { self.changed = true; - log::debug!("loops: Converting an always-true do-while loop to a for loop"); + tracing::debug!("loops: Converting an always-true do-while loop to a for loop"); *s = Stmt::For(ForStmt { span: stmt.span, @@ -81,7 +81,7 @@ where // will remove block and with the next pass we can apply // this pass. self.changed = true; - log::debug!("loops: Compressing for-if-break into a for statement"); + tracing::debug!("loops: Compressing for-if-break into a for statement"); // We negate because this `test` is used as a condition for `break`. self.negate(test, true); diff --git a/ecmascript/minifier/src/compress/pure/misc.rs b/ecmascript/minifier/src/compress/pure/misc.rs index 790856bd938..9aec2a26fb7 100644 --- a/ecmascript/minifier/src/compress/pure/misc.rs +++ b/ecmascript/minifier/src/compress/pure/misc.rs @@ -11,7 +11,7 @@ where Some(e) => { if is_pure_undefined(e) { self.changed = true; - log::debug!("Dropped `undefined` from `return undefined`"); + tracing::debug!("Dropped `undefined` from `return undefined`"); s.arg.take(); } } @@ -22,7 +22,7 @@ where pub(super) fn remove_useless_return(&mut self, stmts: &mut Vec) { if let Some(Stmt::Return(ReturnStmt { arg: None, .. })) = stmts.last() { self.changed = true; - log::debug!("misc: Removing useless return"); + tracing::debug!("misc: Removing useless return"); stmts.pop(); } } @@ -68,7 +68,7 @@ where Stmt::Return(ret) => { self.changed = true; if cfg!(feature = "debug") { - log::trace!("Dropping `return` token"); + tracing::trace!("Dropping `return` token"); } let span = ret.span; diff --git a/ecmascript/minifier/src/compress/pure/mod.rs b/ecmascript/minifier/src/compress/pure/mod.rs index d2a26bfdc8e..9d795800481 100644 --- a/ecmascript/minifier/src/compress/pure/mod.rs +++ b/ecmascript/minifier/src/compress/pure/mod.rs @@ -423,7 +423,7 @@ where Stmt::Debugger(..) => { self.changed = true; *s = Stmt::Empty(EmptyStmt { span: DUMMY_SP }); - log::debug!("drop_debugger: Dropped a debugger statement"); + tracing::debug!("drop_debugger: Dropped a debugger statement"); return; } _ => {} diff --git a/ecmascript/minifier/src/compress/pure/numbers.rs b/ecmascript/minifier/src/compress/pure/numbers.rs index 8d759b66692..9f33abf1dba 100644 --- a/ecmascript/minifier/src/compress/pure/numbers.rs +++ b/ecmascript/minifier/src/compress/pure/numbers.rs @@ -13,7 +13,7 @@ where let value = if value.is_empty() { 0f64 } else { 1f64 }; self.changed = true; - log::debug!("numbers: Converting a string literal to {:?}", value); + tracing::debug!("numbers: Converting a string literal to {:?}", value); *e = Expr::Lit(Lit::Num(Number { span: *span, value })); return; } @@ -41,7 +41,7 @@ where .. }) => { self.changed = true; - log::debug!("numbers: Lifting `-`"); + tracing::debug!("numbers: Lifting `-`"); *e = Expr::Unary(UnaryExpr { span: arg.span, @@ -59,7 +59,7 @@ where Expr::Lit(Lit::Num(Number { span, value, .. })) => { if value.is_sign_negative() { self.changed = true; - log::debug!("numbers: Lifting `-` in a literal"); + tracing::debug!("numbers: Lifting `-` in a literal"); *e = Expr::Unary(UnaryExpr { span: arg.span, diff --git a/ecmascript/minifier/src/compress/pure/properties.rs b/ecmascript/minifier/src/compress/pure/properties.rs index 3c01ec6e584..af487902553 100644 --- a/ecmascript/minifier/src/compress/pure/properties.rs +++ b/ecmascript/minifier/src/compress/pure/properties.rs @@ -29,7 +29,7 @@ where Expr::Lit(Lit::Str(s)) => { if is_valid_identifier(&s.value, true) { self.changed = true; - log::debug!( + tracing::debug!( "properties: Computed member => member expr with identifier as a prop" ); @@ -92,7 +92,7 @@ where if is_valid_identifier(&s.value, false) { self.changed = true; - log::debug!("misc: Optimizing string property name"); + tracing::debug!("misc: Optimizing string property name"); *name = PropName::Ident(Ident { span: s.span, sym: s.value.clone(), @@ -189,7 +189,10 @@ where Prop::Shorthand(_) => {} Prop::KeyValue(p) => { if prop_name_eq(&p.key, &key.sym) { - log::debug!("properties: Inlining a key-value property `{}`", key.sym); + tracing::debug!( + "properties: Inlining a key-value property `{}`", + key.sym + ); self.changed = true; *e = *p.value.clone(); return; diff --git a/ecmascript/minifier/src/compress/pure/sequences.rs b/ecmascript/minifier/src/compress/pure/sequences.rs index 9ca2b97ba28..02dac0628d4 100644 --- a/ecmascript/minifier/src/compress/pure/sequences.rs +++ b/ecmascript/minifier/src/compress/pure/sequences.rs @@ -54,7 +54,7 @@ where } self.changed = true; - log::debug!("sequences: Lifting sequence in a binary expression"); + tracing::debug!("sequences: Lifting sequence in a binary expression"); let left_last = left.exprs.pop().unwrap(); @@ -102,7 +102,7 @@ where new_seq.extend(test.exprs.drain(..test.exprs.len() - 1)); self.changed = true; - log::debug!("sequences: Lifting sequences in a assignment with cond expr"); + tracing::debug!("sequences: Lifting sequences in a assignment with cond expr"); let new_cond = CondExpr { span: cond.span, test: test.exprs.pop().unwrap(), @@ -202,7 +202,7 @@ where }); b.take(); self.changed = true; - log::debug!( + tracing::debug!( "sequences: Reducing `(a = foo, a.call())` to `((a = foo).call())`" ); diff --git a/ecmascript/minifier/src/compress/pure/strings.rs b/ecmascript/minifier/src/compress/pure/strings.rs index 0029d14ce7d..570c180be84 100644 --- a/ecmascript/minifier/src/compress/pure/strings.rs +++ b/ecmascript/minifier/src/compress/pure/strings.rs @@ -119,7 +119,7 @@ where if let Some(l_last) = l.quasis.last_mut() { self.changed = true; - log::debug!( + tracing::debug!( "template: Concatted a string (`{}`) on rhs of `+` to a template literal", rs.value ); @@ -139,7 +139,7 @@ where if let Some(r_first) = r.quasis.first_mut() { self.changed = true; - log::debug!( + tracing::debug!( "template: Prepended a string (`{}`) on lhs of `+` to a template literal", ls.value ); @@ -177,7 +177,7 @@ where debug_assert!(l.quasis.len() == l.exprs.len() + 1, "{:?} is invalid", l); self.changed = true; - log::debug!("strings: Merged to template literals"); + tracing::debug!("strings: Merged to template literals"); } _ => {} @@ -210,7 +210,7 @@ where let left_span = left.span; self.changed = true; - log::debug!( + tracing::debug!( "strings: Concatting `{} + {}` to `{}`", second_str, third_str, @@ -258,7 +258,7 @@ where .. })) => { self.changed = true; - log::debug!( + tracing::debug!( "string: Dropping empty string literal (in lhs) because it \ does not changes type" ); @@ -275,7 +275,7 @@ where .. })) => { self.changed = true; - log::debug!( + tracing::debug!( "string: Dropping empty string literal (in rhs) because it \ does not changes type" ); diff --git a/ecmascript/minifier/src/compress/pure/vars.rs b/ecmascript/minifier/src/compress/pure/vars.rs index 9d1ddbf370d..9e2efc4a574 100644 --- a/ecmascript/minifier/src/compress/pure/vars.rs +++ b/ecmascript/minifier/src/compress/pure/vars.rs @@ -72,7 +72,7 @@ where } self.changed = true; - log::debug!("collapse_vars: Collapsing variables without an initializer"); + tracing::debug!("collapse_vars: Collapsing variables without an initializer"); let vars = { let mut v = VarMover { diff --git a/ecmascript/minifier/src/compress/util/mod.rs b/ecmascript/minifier/src/compress/util/mod.rs index 933e48d0194..fa1feec15c5 100644 --- a/ecmascript/minifier/src/compress/util/mod.rs +++ b/ecmascript/minifier/src/compress/util/mod.rs @@ -43,7 +43,7 @@ pub(super) fn negate(e: &mut Expr, in_bool_ctx: bool) { unreachable!() } }; - log::debug!("negate: binary"); + tracing::debug!("negate: binary"); return; } @@ -53,7 +53,7 @@ pub(super) fn negate(e: &mut Expr, in_bool_ctx: bool) { op: op @ op!("&&"), .. }) if is_ok_to_negate_rhs(&right) => { - log::debug!("negate: a && b => !a || !b"); + tracing::debug!("negate: a && b => !a || !b"); negate(&mut **left, in_bool_ctx); negate(&mut **right, in_bool_ctx); @@ -67,7 +67,7 @@ pub(super) fn negate(e: &mut Expr, in_bool_ctx: bool) { op: op @ op!("||"), .. }) if is_ok_to_negate_rhs(&right) => { - log::debug!("negate: a || b => !a && !b"); + tracing::debug!("negate: a || b => !a && !b"); negate(&mut **left, in_bool_ctx); negate(&mut **right, in_bool_ctx); @@ -78,7 +78,7 @@ pub(super) fn negate(e: &mut Expr, in_bool_ctx: bool) { Expr::Cond(CondExpr { cons, alt, .. }) if is_ok_to_negate_for_cond(&cons) && is_ok_to_negate_for_cond(&alt) => { - log::debug!("negate: cond"); + tracing::debug!("negate: cond"); negate(&mut **cons, in_bool_ctx); negate(&mut **alt, in_bool_ctx); @@ -87,7 +87,7 @@ pub(super) fn negate(e: &mut Expr, in_bool_ctx: bool) { Expr::Seq(SeqExpr { exprs, .. }) => { if let Some(last) = exprs.last_mut() { - log::debug!("negate: seq"); + tracing::debug!("negate: seq"); negate(&mut **last, in_bool_ctx); return; @@ -104,7 +104,7 @@ pub(super) fn negate(e: &mut Expr, in_bool_ctx: bool) { op: op!("!"), arg, .. }) => match &mut **arg { Expr::Unary(UnaryExpr { op: op!("!"), .. }) => { - log::debug!("negate: !!bool => !bool"); + tracing::debug!("negate: !!bool => !bool"); *e = *arg.take(); return; } @@ -113,13 +113,13 @@ pub(super) fn negate(e: &mut Expr, in_bool_ctx: bool) { op: op!("instanceof"), .. }) => { - log::debug!("negate: !bool => bool"); + tracing::debug!("negate: !bool => bool"); *e = *arg.take(); return; } _ => { if in_bool_ctx { - log::debug!("negate: !expr => expr (in bool context)"); + tracing::debug!("negate: !expr => expr (in bool context)"); *e = *arg.take(); return; } @@ -129,7 +129,7 @@ pub(super) fn negate(e: &mut Expr, in_bool_ctx: bool) { _ => {} } - log::debug!("negate: e => !e"); + tracing::debug!("negate: e => !e"); *e = Expr::Unary(UnaryExpr { span: DUMMY_SP, @@ -138,7 +138,7 @@ pub(super) fn negate(e: &mut Expr, in_bool_ctx: bool) { }); if cfg!(feature = "debug") { - log::trace!("[Change] Negated `{}` as `{}`", start_str, dump(&*e)); + tracing::trace!("[Change] Negated `{}` as `{}`", start_str, dump(&*e)); } } @@ -195,7 +195,7 @@ pub(crate) fn is_ok_to_negate_rhs(rhs: &Expr) -> bool { } if cfg!(feature = "debug") { - log::warn!("unimplemented: is_ok_to_negate_rhs: `{}`", dump(&*rhs)); + tracing::warn!("unimplemented: is_ok_to_negate_rhs: `{}`", dump(&*rhs)); } false @@ -304,7 +304,7 @@ pub(crate) fn negate_cost(e: &Expr, in_bool_ctx: bool, is_ret_val_ignored: bool) let cost = cost(e, in_bool_ctx, None, is_ret_val_ignored); if cfg!(feature = "debug") { - log::trace!( + tracing::trace!( "negation cost of `{}` = {}\nin_book_ctx={:?}\nis_ret_val_ignored={:?}", dump(&e.clone().fold_with(&mut as_folder(fixer(None)))), cost, diff --git a/ecmascript/minifier/src/debug.rs b/ecmascript/minifier/src/debug.rs index c76338b6663..c37517228b3 100644 --- a/ecmascript/minifier/src/debug.rs +++ b/ecmascript/minifier/src/debug.rs @@ -102,5 +102,5 @@ pub(crate) fn invoke(module: &Module) { ); } - log::info!("[SWC_RUN]\n{}", String::from_utf8_lossy(&output.stdout)) + tracing::info!("[SWC_RUN]\n{}", String::from_utf8_lossy(&output.stdout)) } diff --git a/ecmascript/minifier/src/eval.rs b/ecmascript/minifier/src/eval.rs index f3345c86937..438b29fc331 100644 --- a/ecmascript/minifier/src/eval.rs +++ b/ecmascript/minifier/src/eval.rs @@ -3,7 +3,7 @@ use crate::{ marks::Marks, mode::Mode, }; -use fxhash::FxHashMap; +use rustc_hash::FxHashMap; use std::sync::{Arc, Mutex}; use swc_atoms::js_word; use swc_common::{util::take::Take, DUMMY_SP}; diff --git a/ecmascript/minifier/src/lib.rs b/ecmascript/minifier/src/lib.rs index 9301982220d..be4c826062c 100644 --- a/ecmascript/minifier/src/lib.rs +++ b/ecmascript/minifier/src/lib.rs @@ -73,14 +73,14 @@ pub fn optimize( } } if let Some(start) = start { - log::info!("global_defs took {:?}", Instant::now() - start); + tracing::info!("global_defs took {:?}", Instant::now() - start); } if let Some(options) = &options.compress { let start = now(); m.visit_mut_with(&mut precompress_optimizer(options, marks)); if let Some(start) = start { - log::info!("precompress took {:?}", Instant::now() - start); + tracing::info!("precompress took {:?}", Instant::now() - start); } } @@ -119,14 +119,14 @@ pub fn optimize( m = GLOBALS .with(|globals| m.fold_with(&mut compressor(globals, marks, &options, &Minification))); if let Some(start) = start { - log::info!("compressor took {:?}", Instant::now() - start); + tracing::info!("compressor took {:?}", Instant::now() - start); } // Again, we don't need to validate ast let start = now(); m.visit_mut_with(&mut postcompress_optimizer(options)); if let Some(start) = start { - log::info!("postcompressor took {:?}", Instant::now() - start); + tracing::info!("postcompressor took {:?}", Instant::now() - start); } } diff --git a/ecmascript/minifier/src/metadata/mod.rs b/ecmascript/minifier/src/metadata/mod.rs index 6b30322e4b7..2bd9d36ca0c 100644 --- a/ecmascript/minifier/src/metadata/mod.rs +++ b/ecmascript/minifier/src/metadata/mod.rs @@ -176,10 +176,10 @@ impl VisitMut for InfoMarker<'_> { m.visit_mut_children_with(self); if self.state.is_bundle { - log::info!("Running minifier in the bundle mode"); + tracing::info!("Running minifier in the bundle mode"); m.span = m.span.apply_mark(self.marks.bundle_of_standalones); } else { - log::info!("Running minifier in the normal mode"); + tracing::info!("Running minifier in the normal mode"); } } @@ -275,7 +275,7 @@ where if external_bingdings.contains(&used_id) { if cfg!(feature = "debug") { - log::debug!( + tracing::debug!( "bundle: Due to {}{:?} (top-level), it's not a bundle", used_id.0, used_id.1 @@ -287,14 +287,14 @@ where if used_id.1 == top_level_ctxt { // if cfg!(feature = "debug") { - // log::debug!("bundle: Ignoring {}{:?} (top level)", used_id.0, used_id.1); - // } + // tracing::debug!("bundle: Ignoring {}{:?} (top level)", used_id.0, + // used_id.1); } continue; } if bindings.contains(used_id) { // if cfg!(feature = "debug") { - // log::debug!( + // tracing::debug!( // "bundle: Ignoring {}{:?} (local to fn)", // used_id.0, // used_id.1 @@ -304,7 +304,7 @@ where } if cfg!(feature = "debug") { - log::debug!( + tracing::debug!( "bundle: Due to {}{:?}, it's not a bundle", used_id.0, used_id.1 diff --git a/ecmascript/minifier/src/option/mod.rs b/ecmascript/minifier/src/option/mod.rs index a2b520f575f..8e216442b12 100644 --- a/ecmascript/minifier/src/option/mod.rs +++ b/ecmascript/minifier/src/option/mod.rs @@ -1,5 +1,5 @@ -use fxhash::FxHashMap; use regex::Regex; +use rustc_hash::FxHashMap; use serde::{Deserialize, Serialize}; use swc_atoms::JsWord; use swc_common::Mark; diff --git a/ecmascript/minifier/src/option/terser.rs b/ecmascript/minifier/src/option/terser.rs index 631d9109fa5..90b3b6c220b 100644 --- a/ecmascript/minifier/src/option/terser.rs +++ b/ecmascript/minifier/src/option/terser.rs @@ -2,7 +2,7 @@ use super::{true_by_default, CompressOptions, TopLevelOptions}; use crate::option::PureGetterOption; -use fxhash::FxHashMap; +use rustc_hash::FxHashMap; use serde::{Deserialize, Serialize}; use serde_json::Value; use swc_atoms::JsWord; diff --git a/ecmascript/minifier/src/pass/global_defs.rs b/ecmascript/minifier/src/pass/global_defs.rs index 6908de740ef..4307a3e8c31 100644 --- a/ecmascript/minifier/src/pass/global_defs.rs +++ b/ecmascript/minifier/src/pass/global_defs.rs @@ -1,4 +1,4 @@ -use fxhash::FxHashSet; +use rustc_hash::FxHashSet; use std::borrow::Cow; use swc_common::{pass::CompilerPass, EqIgnoreSpan, Mark, SyntaxContext}; use swc_ecma_ast::*; diff --git a/ecmascript/minifier/src/pass/hygiene/vars.rs b/ecmascript/minifier/src/pass/hygiene/vars.rs index e902bb30d9f..b4355ce987d 100644 --- a/ecmascript/minifier/src/pass/hygiene/vars.rs +++ b/ecmascript/minifier/src/pass/hygiene/vars.rs @@ -100,7 +100,7 @@ impl Visit for VarAnalyzer<'_> { } fn visit_ident(&mut self, i: &Ident, _: &dyn Node) { - log::trace!("hygiene/vars: Found {}", i); + tracing::trace!("hygiene/vars: Found {}", i); self.cur.add(i); } diff --git a/ecmascript/minifier/src/pass/mangle_names/mod.rs b/ecmascript/minifier/src/pass/mangle_names/mod.rs index 7df6bcd183c..f86415829a5 100644 --- a/ecmascript/minifier/src/pass/mangle_names/mod.rs +++ b/ecmascript/minifier/src/pass/mangle_names/mod.rs @@ -6,7 +6,7 @@ use crate::{ option::MangleOptions, util::base54::incr_base54, }; -use fxhash::{FxHashMap, FxHashSet}; +use rustc_hash::{FxHashMap, FxHashSet}; use swc_atoms::{js_word, JsWord}; use swc_common::SyntaxContext; use swc_ecma_ast::*; diff --git a/ecmascript/minifier/src/pass/mangle_names/preserver.rs b/ecmascript/minifier/src/pass/mangle_names/preserver.rs index 8cc14e44570..907ac7096ef 100644 --- a/ecmascript/minifier/src/pass/mangle_names/preserver.rs +++ b/ecmascript/minifier/src/pass/mangle_names/preserver.rs @@ -1,5 +1,5 @@ use crate::option::MangleOptions; -use fxhash::FxHashSet; +use rustc_hash::FxHashSet; use swc_common::DUMMY_SP; use swc_ecma_ast::*; use swc_ecma_utils::{find_ids, ident::IdentLike, Id}; diff --git a/ecmascript/minifier/src/pass/postcompress.rs b/ecmascript/minifier/src/pass/postcompress.rs index 6ef25dc2f2b..3a5170e5c3b 100644 --- a/ecmascript/minifier/src/pass/postcompress.rs +++ b/ecmascript/minifier/src/pass/postcompress.rs @@ -44,7 +44,7 @@ impl PostcompressOptimizer<'_> { op!("&&") }; - log::debug!( + tracing::debug!( "bools: `(a {} !b)` => `(a {} b)` (in bool context)", *op, new_op diff --git a/ecmascript/minifier/src/pass/precompress.rs b/ecmascript/minifier/src/pass/precompress.rs index 4aaa68eb201..67c76ec3e6c 100644 --- a/ecmascript/minifier/src/pass/precompress.rs +++ b/ecmascript/minifier/src/pass/precompress.rs @@ -4,7 +4,7 @@ use crate::{ option::CompressOptions, util::MoudleItemExt, }; -use fxhash::FxHashMap; +use rustc_hash::FxHashMap; use swc_atoms::js_word; use swc_common::util::take::Take; use swc_ecma_ast::*; diff --git a/ecmascript/minifier/src/util/mod.rs b/ecmascript/minifier/src/util/mod.rs index 2201aec5569..670204be67f 100644 --- a/ecmascript/minifier/src/util/mod.rs +++ b/ecmascript/minifier/src/util/mod.rs @@ -1,4 +1,4 @@ -use fxhash::FxHashSet; +use rustc_hash::FxHashSet; use std::time::Instant; use swc_common::{ pass::{CompilerPass, Repeated}, diff --git a/ecmascript/minifier/tests/compress.rs b/ecmascript/minifier/tests/compress.rs index a5182edaaec..143fae2a4f7 100644 --- a/ecmascript/minifier/tests/compress.rs +++ b/ecmascript/minifier/tests/compress.rs @@ -194,7 +194,7 @@ fn run( &ExtraOptions { top_level_mark }, ); let end = Instant::now(); - log::info!( + tracing::info!( "optimize({}) took {:?}", input.display(), end - optimization_start @@ -207,7 +207,7 @@ fn run( .fold_with(&mut fixer(None)); let end = Instant::now(); - log::info!( + tracing::info!( "process({}) took {:?}", input.display(), end - minification_start diff --git a/ecmascript/parser/Cargo.toml b/ecmascript/parser/Cargo.toml index 3b19da45ac5..eacd3562e2a 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.71.0" +version = "0.72.0" [package.metadata.docs.rs] all-features = true @@ -21,24 +21,24 @@ typescript = [] [dependencies] either = {version = "1.4"} enum_kind = {version = "0.2.1", path = "../../macros/enum_kind"} -fxhash = "0.2.1" lexical = {version = "5.2.2", features = ["radix"]} -log = "0.4" num-bigint = "0.2" +rustc-hash = "1.1.0" serde = {version = "1", features = ["derive"]} smallvec = "1" swc_atoms = {version = "0.2.3", path = "../../atoms"} -swc_common = {version = "0.12.0", path = "../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../ast"} -swc_ecma_visit = {version = "0.38.1", path = "../visit"} +swc_common = {version = "0.13.0", path = "../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../ast"} +swc_ecma_visit = {version = "0.39.0", path = "../visit"} +tracing = "0.1.28" unicode-xid = "0.2" [dev-dependencies] env_logger = "0.7" pretty_assertions = "0.6" serde_json = "1" -swc_node_base = {version = "0.3.0", path = "../../node/base"} -testing = {version = "0.13.0", path = "../../testing"} +swc_node_base = {version = "0.4.0", path = "../../node/base"} +testing = {version = "0.14.0", path = "../../testing"} walkdir = "2" [[example]] diff --git a/ecmascript/parser/src/lexer/number.rs b/ecmascript/parser/src/lexer/number.rs index fe733e46c9e..5a4820dc23a 100644 --- a/ecmascript/parser/src/lexer/number.rs +++ b/ecmascript/parser/src/lexer/number.rs @@ -5,10 +5,10 @@ use super::*; use crate::error::SyntaxError; use either::Either; -use log::trace; use num_bigint::BigInt as BigIntValue; use std::fmt::Write; use swc_common::SyntaxContext; +use tracing::trace; impl<'a, I: Input> Lexer<'a, I> { /// Reads an integer, octal integer, or floating-point number @@ -337,7 +337,9 @@ impl<'a, I: Input> Lexer<'a, I> { "radix for read_int should be one of 2, 8, 10, 16, but got {}", radix ); - trace!("read_digits(radix = {}), cur = {:?}", radix, self.cur()); + if cfg!(feature = "debug") { + trace!("read_digits(radix = {}), cur = {:?}", radix, self.cur()); + } let start = self.cur_pos(); diff --git a/ecmascript/parser/src/lexer/state.rs b/ecmascript/parser/src/lexer/state.rs index 1239c218e53..f48b68518e7 100644 --- a/ecmascript/parser/src/lexer/state.rs +++ b/ecmascript/parser/src/lexer/state.rs @@ -1,9 +1,9 @@ use super::{Context, Input, Lexer}; use crate::{error::Error, input::Tokens, lexer::util::CharExt, token::*, JscTarget, Syntax}; use enum_kind::Kind; -use log::trace; use std::{mem, mem::take}; use swc_common::BytePos; +use tracing::trace; /// State of lexer. /// @@ -366,11 +366,14 @@ impl State { } fn update(&mut self, start: BytePos, next: &Token) { - trace!( - "updating state: next={:?}, had_line_break={} ", - next, - self.had_line_break - ); + if cfg!(feature = "debug") { + trace!( + "updating state: next={:?}, had_line_break={} ", + next, + self.had_line_break + ); + } + let prev = self.token_type.take(); self.token_type = Some(TokenType::from(next)); diff --git a/ecmascript/parser/src/parser/expr/ops.rs b/ecmascript/parser/src/parser/expr/ops.rs index 43bdac4f5cb..9d31ca845ff 100644 --- a/ecmascript/parser/src/parser/expr/ops.rs +++ b/ecmascript/parser/src/parser/expr/ops.rs @@ -1,7 +1,7 @@ //! Parser for unary operations and binary operations. use super::*; -use log::trace; use swc_common::Spanned; +use tracing::trace; impl<'a, I: Tokens> Parser { /// Name from spec: 'LogicalORExpression' @@ -136,24 +136,27 @@ impl<'a, I: Tokens> Parser { } if op.precedence() <= min_prec { - trace!( - "returning {:?} without parsing {:?} because min_prec={}, prec={}", - left, - op, - min_prec, - op.precedence() - ); + if cfg!(feature = "debug") { + trace!( + "returning {:?} without parsing {:?} because min_prec={}, prec={}", + left, + op, + min_prec, + op.precedence() + ); + } return Ok((left, None)); } bump!(self); - trace!( - "parsing binary op {:?} min_prec={}, prec={}", - op, - min_prec, - op.precedence() - ); - + if cfg!(feature = "debug") { + trace!( + "parsing binary op {:?} min_prec={}, prec={}", + op, + min_prec, + op.precedence() + ); + } match *left { // This is invalid syntax. Expr::Unary { .. } if op == op!("**") => { diff --git a/ecmascript/parser/src/parser/macros.rs b/ecmascript/parser/src/parser/macros.rs index 83c41e4bc7e..cb094159a97 100644 --- a/ecmascript/parser/src/parser/macros.rs +++ b/ecmascript/parser/src/parser/macros.rs @@ -146,7 +146,9 @@ macro_rules! assert_and_bump { /// if token has data like string. macro_rules! eat { ($p:expr, ';') => {{ - log::trace!("eat(';'): cur={:?}", cur!($p, false)); + if cfg!(feature = "debug") { + tracing::trace!("eat(';'): cur={:?}", cur!($p, false)); + } match $p.input.cur() { Some(&Token::Semi) => { $p.input.bump(); @@ -317,7 +319,7 @@ macro_rules! return_if_arrow { macro_rules! trace_cur { ($p:expr, $name:ident) => {{ if cfg!(feature = "debug") { - log::debug!("{}: {:?}", stringify!($name), $p.input.cur()); + tracing::debug!("{}: {:?}", stringify!($name), $p.input.cur()); } }}; } diff --git a/ecmascript/preset-env/Cargo.toml b/ecmascript/preset-env/Cargo.toml index c623cb9962d..1a50128ad78 100644 --- a/ecmascript/preset-env/Cargo.toml +++ b/ecmascript/preset-env/Cargo.toml @@ -5,30 +5,30 @@ documentation = "https://rustdoc.swc.rs/swc_ecma_preset_env/" edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_preset_env" -version = "0.44.0" +version = "0.45.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] dashmap = "4.0.2" -fxhash = "0.2.1" indexmap = "1.6.2" once_cell = "1.2.0" +rustc-hash = "1.1.0" semver = {version = "0.9.0", features = ["serde"]} serde = {version = "1", features = ["derive"]} serde_json = "1" 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.12.0", path = "../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../ast"} -swc_ecma_transforms = {version = "0.73.0", path = "../transforms", features = ["compat", "proposal"]} -swc_ecma_utils = {version = "0.44.2", path = "../utils"} -swc_ecma_visit = {version = "0.38.1", path = "../visit"} +swc_common = {version = "0.13.0", path = "../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../ast"} +swc_ecma_transforms = {version = "0.74.0", path = "../transforms", features = ["compat", "proposal"]} +swc_ecma_utils = {version = "0.45.0", path = "../utils"} +swc_ecma_visit = {version = "0.39.0", path = "../visit"} walkdir = "2" [dev-dependencies] pretty_assertions = "0.6" -swc_ecma_codegen = {version = "0.71.0", path = "../codegen"} -swc_ecma_parser = {version = "0.71.0", path = "../parser"} -testing = {version = "0.13.0", path = "../../testing"} +swc_ecma_codegen = {version = "0.72.0", path = "../codegen"} +swc_ecma_parser = {version = "0.72.0", path = "../parser"} +testing = {version = "0.14.0", path = "../../testing"} diff --git a/ecmascript/preset-env/src/corejs2/entry.rs b/ecmascript/preset-env/src/corejs2/entry.rs index d2c2a6af3a7..25393e9e077 100644 --- a/ecmascript/preset-env/src/corejs2/entry.rs +++ b/ecmascript/preset-env/src/corejs2/entry.rs @@ -1,7 +1,8 @@ use super::builtin::BUILTINS; use crate::{version::should_enable, Versions}; -use fxhash::FxBuildHasher; use indexmap::IndexSet; +use rustc_hash::FxHasher; +use std::hash::BuildHasherDefault; use swc_atoms::js_word; use swc_common::{util::move_map::MoveMap, DUMMY_SP}; use swc_ecma_ast::*; @@ -11,7 +12,7 @@ use swc_ecma_visit::{Fold, FoldWith}; pub struct Entry { is_any_target: bool, target: Versions, - pub imports: IndexSet<&'static str, FxBuildHasher>, + pub imports: IndexSet<&'static str, BuildHasherDefault>, } impl Entry { diff --git a/ecmascript/preset-env/src/corejs2/mod.rs b/ecmascript/preset-env/src/corejs2/mod.rs index 1ef3c01dfcd..119ccaeb6bf 100644 --- a/ecmascript/preset-env/src/corejs2/mod.rs +++ b/ecmascript/preset-env/src/corejs2/mod.rs @@ -4,8 +4,9 @@ use self::{ data::{BUILTIN_TYPES, INSTANCE_PROPERTIES, STATIC_PROPERTIES}, }; use crate::{util::DataMapExt, version::should_enable, Versions}; -use fxhash::FxBuildHasher; use indexmap::IndexSet; +use rustc_hash::FxHasher; +use std::hash::BuildHasherDefault; use swc_atoms::{js_word, JsWord}; use swc_common::DUMMY_SP; use swc_ecma_ast::*; @@ -18,7 +19,7 @@ mod entry; pub(crate) struct UsageVisitor { is_any_target: bool, target: Versions, - pub required: IndexSet<&'static str, FxBuildHasher>, + pub required: IndexSet<&'static str, BuildHasherDefault>, } impl UsageVisitor { diff --git a/ecmascript/preset-env/src/corejs3/compat.rs b/ecmascript/preset-env/src/corejs3/compat.rs index 4026f00d8be..d0c7bbcd5fd 100644 --- a/ecmascript/preset-env/src/corejs3/compat.rs +++ b/ecmascript/preset-env/src/corejs3/compat.rs @@ -1,8 +1,8 @@ //! Ported from https://github.com/zloirock/core-js/tree/master/packages/core-js-compat use crate::Versions; -use fxhash::FxHashMap; use once_cell::sync::Lazy; +use rustc_hash::FxHashMap; pub static DATA: Lazy> = Lazy::new(|| { serde_json::from_str(include_str!("compat.json")) diff --git a/ecmascript/preset-env/src/corejs3/entry.rs b/ecmascript/preset-env/src/corejs3/entry.rs index 521e4451cef..edb7a2d0624 100644 --- a/ecmascript/preset-env/src/corejs3/entry.rs +++ b/ecmascript/preset-env/src/corejs3/entry.rs @@ -1,8 +1,10 @@ +use std::hash::BuildHasherDefault; + use super::compat::DATA as CORE_JS_COMPAT_DATA; use crate::{version::should_enable, Version, Versions}; -use fxhash::{FxBuildHasher, FxHashMap}; use indexmap::IndexSet; use once_cell::sync::Lazy; +use rustc_hash::{FxHashMap, FxHasher}; use swc_atoms::js_word; use swc_common::DUMMY_SP; use swc_ecma_ast::*; @@ -43,7 +45,7 @@ pub struct Entry { is_any_target: bool, target: Versions, corejs_version: Version, - pub imports: IndexSet<&'static str, FxBuildHasher>, + pub imports: IndexSet<&'static str, BuildHasherDefault>, remove_regenerator: bool, } diff --git a/ecmascript/preset-env/src/corejs3/usage.rs b/ecmascript/preset-env/src/corejs3/usage.rs index b98889b7334..c50379b7157 100644 --- a/ecmascript/preset-env/src/corejs3/usage.rs +++ b/ecmascript/preset-env/src/corejs3/usage.rs @@ -11,8 +11,9 @@ use crate::{ version::should_enable, Versions, }; -use fxhash::FxBuildHasher; use indexmap::IndexSet; +use rustc_hash::FxHasher; +use std::hash::BuildHasherDefault; use swc_atoms::{js_word, JsWord}; use swc_common::DUMMY_SP; use swc_ecma_ast::*; @@ -22,7 +23,7 @@ pub(crate) struct UsageVisitor { shipped_proposals: bool, is_any_target: bool, target: Versions, - pub required: IndexSet<&'static str, FxBuildHasher>, + pub required: IndexSet<&'static str, BuildHasherDefault>, } impl UsageVisitor { diff --git a/ecmascript/preset-env/src/lib.rs b/ecmascript/preset-env/src/lib.rs index 8043755bc00..410ef8e34be 100644 --- a/ecmascript/preset-env/src/lib.rs +++ b/ecmascript/preset-env/src/lib.rs @@ -2,8 +2,8 @@ pub use self::{transform_data::Feature, version::Version}; use dashmap::DashMap; -use fxhash::{FxHashMap, FxHashSet}; use once_cell::sync::Lazy; +use rustc_hash::{FxHashMap, FxHashSet}; use serde::{Deserialize, Serialize}; use st_map::StaticMap; use std::{ diff --git a/ecmascript/transforms/Cargo.toml b/ecmascript/transforms/Cargo.toml index 8a1d72961a2..0743238547d 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.73.0" +version = "0.74.0" [package.metadata.docs.rs] all-features = true @@ -22,25 +22,25 @@ typescript = ["swc_ecma_transforms_typescript"] [dependencies] swc_atoms = {version = "0.2.0", path = "../../atoms"} -swc_common = {version = "0.12.0", path = "../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../ast"} -swc_ecma_parser = {version = "0.71.0", path = "../parser"} -swc_ecma_transforms_base = {version = "0.32.0", path = "./base"} -swc_ecma_transforms_compat = {version = "0.36.0", path = "./compat", optional = true} -swc_ecma_transforms_module = {version = "0.40.0", path = "./module", optional = true} -swc_ecma_transforms_optimization = {version = "0.43.0", path = "./optimization", optional = true} -swc_ecma_transforms_proposal = {version = "0.40.0", path = "./proposal", optional = true} -swc_ecma_transforms_react = {version = "0.41.0", path = "./react", optional = true} -swc_ecma_transforms_typescript = {version = "0.42.0", path = "./typescript", optional = true} -swc_ecma_utils = {version = "0.44.2", path = "../utils"} -swc_ecma_visit = {version = "0.38.1", path = "../visit"} +swc_common = {version = "0.13.0", path = "../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../ast"} +swc_ecma_parser = {version = "0.72.0", path = "../parser"} +swc_ecma_transforms_base = {version = "0.33.0", path = "./base"} +swc_ecma_transforms_compat = {version = "0.37.0", path = "./compat", optional = true} +swc_ecma_transforms_module = {version = "0.41.0", path = "./module", optional = true} +swc_ecma_transforms_optimization = {version = "0.44.0", path = "./optimization", optional = true} +swc_ecma_transforms_proposal = {version = "0.41.0", path = "./proposal", optional = true} +swc_ecma_transforms_react = {version = "0.42.0", path = "./react", optional = true} +swc_ecma_transforms_typescript = {version = "0.43.0", path = "./typescript", optional = true} +swc_ecma_utils = {version = "0.45.0", path = "../utils"} +swc_ecma_visit = {version = "0.39.0", path = "../visit"} unicode-xid = "0.2" [dev-dependencies] pretty_assertions = "0.6" sourcemap = "6" -swc_ecma_codegen = {version = "0.71.0", path = "../codegen"} -swc_ecma_transforms_testing = {version = "0.33.0", path = "./testing"} +swc_ecma_codegen = {version = "0.72.0", path = "../codegen"} +swc_ecma_transforms_testing = {version = "0.34.0", path = "./testing"} tempfile = "3" -testing = {version = "0.13.0", path = "../../testing"} +testing = {version = "0.14.0", path = "../../testing"} walkdir = "2" diff --git a/ecmascript/transforms/base/Cargo.toml b/ecmascript/transforms/base/Cargo.toml index a449f34d3c9..c72630e5a58 100644 --- a/ecmascript/transforms/base/Cargo.toml +++ b/ecmascript/transforms/base/Cargo.toml @@ -6,21 +6,21 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_base" repository = "https://github.com/swc-project/swc.git" -version = "0.32.0" +version = "0.33.0" [dependencies] -fxhash = "0.2.1" once_cell = "1.5.2" phf = {version = "0.8.0", features = ["macros"]} +rustc-hash = "1.1.0" scoped-tls = "1.0.0" smallvec = "1.6.0" swc_atoms = {version = "0.2", path = "../../../atoms"} -swc_common = {version = "0.12.0", path = "../../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../../ast"} -swc_ecma_parser = {version = "0.71.0", path = "../../parser"} -swc_ecma_utils = {version = "0.44.2", path = "../../utils"} -swc_ecma_visit = {version = "0.38.1", path = "../../visit"} +swc_common = {version = "0.13.0", path = "../../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../../ast"} +swc_ecma_parser = {version = "0.72.0", path = "../../parser"} +swc_ecma_utils = {version = "0.45.0", path = "../../utils"} +swc_ecma_visit = {version = "0.39.0", path = "../../visit"} [dev-dependencies] -swc_ecma_codegen = {version = "0.71.0", path = "../../codegen"} -testing = {version = "0.13.0", path = "../../../testing"} +swc_ecma_codegen = {version = "0.72.0", path = "../../codegen"} +testing = {version = "0.14.0", path = "../../../testing"} diff --git a/ecmascript/transforms/base/src/fixer.rs b/ecmascript/transforms/base/src/fixer.rs index d6101bbf2dd..b350e270fa7 100644 --- a/ecmascript/transforms/base/src/fixer.rs +++ b/ecmascript/transforms/base/src/fixer.rs @@ -1,5 +1,5 @@ use crate::ext::{AsOptExpr, PatOrExprExt}; -use fxhash::FxHashMap; +use rustc_hash::FxHashMap; use swc_common::{comments::Comments, util::take::Take, Span, Spanned}; use swc_ecma_ast::*; use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith}; diff --git a/ecmascript/transforms/base/src/hygiene/mod.rs b/ecmascript/transforms/base/src/hygiene/mod.rs index dd3368e0ea5..7927a93ee98 100644 --- a/ecmascript/transforms/base/src/hygiene/mod.rs +++ b/ecmascript/transforms/base/src/hygiene/mod.rs @@ -3,7 +3,7 @@ use crate::{ native::is_native_word, scope::{IdentType, ScopeKind}, }; -use fxhash::{FxHashMap, FxHashSet}; +use rustc_hash::{FxHashMap, FxHashSet}; use smallvec::{smallvec, SmallVec}; use std::{cell::RefCell, collections::HashMap}; use swc_atoms::{js_word, JsWord}; diff --git a/ecmascript/transforms/base/src/hygiene/ops.rs b/ecmascript/transforms/base/src/hygiene/ops.rs index bc7b5e3be13..08dff5e21d5 100644 --- a/ecmascript/transforms/base/src/hygiene/ops.rs +++ b/ecmascript/transforms/base/src/hygiene/ops.rs @@ -1,4 +1,4 @@ -use fxhash::FxHashMap; +use rustc_hash::FxHashMap; use swc_atoms::JsWord; use swc_common::{ util::{move_map::MoveMap, take::Take}, diff --git a/ecmascript/transforms/base/src/resolver/mod.rs b/ecmascript/transforms/base/src/resolver/mod.rs index 2a1f06911f8..71a39f87d6e 100644 --- a/ecmascript/transforms/base/src/resolver/mod.rs +++ b/ecmascript/transforms/base/src/resolver/mod.rs @@ -1,5 +1,5 @@ use crate::scope::{IdentType, ScopeKind}; -use fxhash::FxHashSet; +use rustc_hash::FxHashSet; use std::cell::RefCell; use swc_atoms::JsWord; use swc_common::{Mark, SyntaxContext}; diff --git a/ecmascript/transforms/classes/Cargo.toml b/ecmascript/transforms/classes/Cargo.toml index 002dc993c6f..020b6f60ba0 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.18.0" +version = "0.19.0" [dependencies] swc_atoms = {version = "0.2.6", path = "../../../atoms"} -swc_common = {version = "0.12.0", path = "../../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../../ast"} -swc_ecma_transforms_base = {version = "0.32.0", path = "../base"} -swc_ecma_utils = {version = "0.44.2", path = "../../utils"} -swc_ecma_visit = {version = "0.38.1", path = "../../visit"} +swc_common = {version = "0.13.0", path = "../../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../../ast"} +swc_ecma_transforms_base = {version = "0.33.0", path = "../base"} +swc_ecma_utils = {version = "0.45.0", path = "../../utils"} +swc_ecma_visit = {version = "0.39.0", path = "../../visit"} diff --git a/ecmascript/transforms/compat/Cargo.toml b/ecmascript/transforms/compat/Cargo.toml index f1d830d6551..3bbc9ab3fee 100644 --- a/ecmascript/transforms/compat/Cargo.toml +++ b/ecmascript/transforms/compat/Cargo.toml @@ -6,28 +6,28 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_compat" repository = "https://github.com/swc-project/swc.git" -version = "0.36.0" +version = "0.37.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] arrayvec = "0.5.2" -fxhash = "0.2.1" indexmap = "1.6.1" is-macro = "0.1.8" num-bigint = "0.2" ordered-float = "2.0.1" +rustc-hash = "1.1.0" serde = {version = "1.0.118", features = ["derive"]} smallvec = "1.6.0" swc_atoms = {version = "0.2.5", path = "../../../atoms"} -swc_common = {version = "0.12.0", path = "../../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../../ast"} -swc_ecma_transforms_base = {version = "0.32.0", path = "../base"} -swc_ecma_transforms_classes = {version = "0.18.0", path = "../classes"} +swc_common = {version = "0.13.0", path = "../../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../../ast"} +swc_ecma_transforms_base = {version = "0.33.0", path = "../base"} +swc_ecma_transforms_classes = {version = "0.19.0", path = "../classes"} swc_ecma_transforms_macros = {version = "0.2.1", path = "../macros"} -swc_ecma_utils = {version = "0.44.2", path = "../../utils"} -swc_ecma_visit = {version = "0.38.1", path = "../../visit"} +swc_ecma_utils = {version = "0.45.0", path = "../../utils"} +swc_ecma_visit = {version = "0.39.0", path = "../../visit"} [dev-dependencies] -swc_ecma_parser = {version = "0.71.0", path = "../../parser"} -swc_ecma_transforms_testing = {version = "0.33.0", path = "../testing"} -testing = {version = "0.13.0", path = "../../../testing"} +swc_ecma_parser = {version = "0.72.0", path = "../../parser"} +swc_ecma_transforms_testing = {version = "0.34.0", path = "../testing"} +testing = {version = "0.14.0", path = "../../../testing"} diff --git a/ecmascript/transforms/compat/src/es2015/classes/mod.rs b/ecmascript/transforms/compat/src/es2015/classes/mod.rs index cf7802af610..7e5ac89a6db 100644 --- a/ecmascript/transforms/compat/src/es2015/classes/mod.rs +++ b/ecmascript/transforms/compat/src/es2015/classes/mod.rs @@ -5,8 +5,8 @@ use self::{ }, prop_name::HashKey, }; -use fxhash::FxBuildHasher; -use std::iter; +use rustc_hash::FxHasher; +use std::{hash::BuildHasherDefault, iter}; use swc_common::{comments::Comments, Mark, Spanned, DUMMY_SP}; use swc_ecma_ast::*; use swc_ecma_transforms_base::{helper, native::is_native, perf::Check}; @@ -31,7 +31,7 @@ where } } -type IndexMap = indexmap::IndexMap; +type IndexMap = indexmap::IndexMap>; /// `@babel/plugin-transform-classes` /// diff --git a/ecmascript/transforms/compat/src/es2015/duplicate_keys.rs b/ecmascript/transforms/compat/src/es2015/duplicate_keys.rs index f24cb9e7f49..43f184c50d2 100644 --- a/ecmascript/transforms/compat/src/es2015/duplicate_keys.rs +++ b/ecmascript/transforms/compat/src/es2015/duplicate_keys.rs @@ -1,4 +1,4 @@ -use fxhash::FxHashSet; +use rustc_hash::FxHashSet; use swc_atoms::JsWord; use swc_common::Spanned; use swc_ecma_ast::*; diff --git a/ecmascript/transforms/compat/src/es2020/class_properties/private_field.rs b/ecmascript/transforms/compat/src/es2020/class_properties/private_field.rs index 215d3373401..263ae6a59ad 100644 --- a/ecmascript/transforms/compat/src/es2020/class_properties/private_field.rs +++ b/ecmascript/transforms/compat/src/es2020/class_properties/private_field.rs @@ -1,4 +1,4 @@ -use fxhash::FxHashSet; +use rustc_hash::FxHashSet; use std::{iter, mem}; use swc_atoms::JsWord; use swc_common::{util::take::Take, Mark, Spanned, SyntaxContext, DUMMY_SP}; diff --git a/ecmascript/transforms/module/Cargo.toml b/ecmascript/transforms/module/Cargo.toml index baa4e22a685..96b0777c37e 100644 --- a/ecmascript/transforms/module/Cargo.toml +++ b/ecmascript/transforms/module/Cargo.toml @@ -6,26 +6,26 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_module" repository = "https://github.com/swc-project/swc.git" -version = "0.40.0" +version = "0.41.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] Inflector = "0.11.4" anyhow = "1.0.41" -fxhash = "0.2.1" indexmap = "1.6.1" pathdiff = "0.2.0" +rustc-hash = "1.1.0" serde = {version = "1.0.118", features = ["derive"]} swc_atoms = {version = "0.2", path = "../../../atoms"} -swc_common = {version = "0.12.0", path = "../../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../../ast"} -swc_ecma_loader = {version = "0.18.1", path = "../../loader", features = ["node"]} -swc_ecma_parser = {version = "0.71.0", path = "../../parser"} -swc_ecma_transforms_base = {version = "0.32.0", path = "../base"} -swc_ecma_utils = {version = "0.44.2", path = "../../utils"} -swc_ecma_visit = {version = "0.38.1", path = "../../visit"} +swc_common = {version = "0.13.0", path = "../../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../../ast"} +swc_ecma_loader = {version = "0.19.0", path = "../../loader", features = ["node"]} +swc_ecma_parser = {version = "0.72.0", path = "../../parser"} +swc_ecma_transforms_base = {version = "0.33.0", path = "../base"} +swc_ecma_utils = {version = "0.45.0", path = "../../utils"} +swc_ecma_visit = {version = "0.39.0", path = "../../visit"} [dev-dependencies] -swc_ecma_transforms_compat = {version = "0.36.0", path = "../compat"} -swc_ecma_transforms_testing = {version = "0.33.0", path = "../testing/"} -testing = {version = "0.13.0", path = "../../../testing/"} +swc_ecma_transforms_compat = {version = "0.37.0", path = "../compat"} +swc_ecma_transforms_testing = {version = "0.34.0", path = "../testing/"} +testing = {version = "0.14.0", path = "../../../testing/"} diff --git a/ecmascript/transforms/module/src/amd.rs b/ecmascript/transforms/module/src/amd.rs index 2a023faa72b..ebed4efce76 100644 --- a/ecmascript/transforms/module/src/amd.rs +++ b/ecmascript/transforms/module/src/amd.rs @@ -4,7 +4,7 @@ use super::util::{ }; use crate::path::{ImportResolver, NoopImportResolver}; use anyhow::Context; -use fxhash::FxHashSet; +use rustc_hash::FxHashSet; use serde::{Deserialize, Serialize}; use std::{ cell::{Ref, RefCell, RefMut}, diff --git a/ecmascript/transforms/module/src/common_js.rs b/ecmascript/transforms/module/src/common_js.rs index c3aaa2795b1..893615d11a9 100644 --- a/ecmascript/transforms/module/src/common_js.rs +++ b/ecmascript/transforms/module/src/common_js.rs @@ -4,7 +4,7 @@ use super::util::{ make_require_call, use_strict, ModulePass, Scope, }; use crate::path::{ImportResolver, NoopImportResolver}; -use fxhash::FxHashSet; +use rustc_hash::FxHashSet; use std::{ cell::{Ref, RefCell, RefMut}, rc::Rc, diff --git a/ecmascript/transforms/module/src/umd.rs b/ecmascript/transforms/module/src/umd.rs index 741ea766a86..7231ba8ef7d 100644 --- a/ecmascript/transforms/module/src/umd.rs +++ b/ecmascript/transforms/module/src/umd.rs @@ -7,7 +7,7 @@ use super::util::{ local_name_for_src, make_descriptor, make_require_call, use_strict, Exports, ModulePass, Scope, }; use crate::path::{ImportResolver, NoopImportResolver}; -use fxhash::FxHashSet; +use rustc_hash::FxHashSet; use swc_atoms::js_word; use swc_common::{sync::Lrc, FileName, Mark, SourceMap, DUMMY_SP}; use swc_ecma_ast::*; diff --git a/ecmascript/transforms/module/src/util.rs b/ecmascript/transforms/module/src/util.rs index 99d02eba281..1a088198861 100644 --- a/ecmascript/transforms/module/src/util.rs +++ b/ecmascript/transforms/module/src/util.rs @@ -1,12 +1,13 @@ use crate::path::ImportResolver; use anyhow::Context; -use fxhash::{FxBuildHasher, FxHashMap, FxHashSet}; use indexmap::IndexMap; use inflector::Inflector; +use rustc_hash::{FxHashMap, FxHashSet, FxHasher}; use serde::{Deserialize, Serialize}; use std::{ cell::{Ref, RefMut}, collections::hash_map::Entry, + hash::BuildHasherDefault, iter, }; use swc_atoms::{js_word, JsWord}; @@ -95,7 +96,7 @@ pub struct Scope { /// /// - `import * as bar1 from 'bar';` /// -> `{'bar': Some(bar1)}` - pub(crate) imports: IndexMap, FxBuildHasher>, + pub(crate) imports: IndexMap, BuildHasherDefault>, /// /// - `true` is wildcard (`_interopRequireWildcard`) /// - `false` is default (`_interopRequireDefault`) diff --git a/ecmascript/transforms/optimization/Cargo.toml b/ecmascript/transforms/optimization/Cargo.toml index fddf81db274..9772dd6eb45 100644 --- a/ecmascript/transforms/optimization/Cargo.toml +++ b/ecmascript/transforms/optimization/Cargo.toml @@ -6,30 +6,30 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_optimization" repository = "https://github.com/swc-project/swc.git" -version = "0.43.0" +version = "0.44.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] dashmap = "4.0.2" -fxhash = "0.2.1" indexmap = "1.6.1" -log = "0.4.11" once_cell = "1.5.2" retain_mut = "0.1.2" +rustc-hash = "1.1.0" serde_json = "1.0.61" swc_atoms = {version = "0.2", path = "../../../atoms"} -swc_common = {version = "0.12.0", path = "../../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../../ast"} -swc_ecma_parser = {version = "0.71.0", path = "../../parser"} -swc_ecma_transforms_base = {version = "0.32.0", path = "../base"} -swc_ecma_utils = {version = "0.44.2", path = "../../utils"} -swc_ecma_visit = {version = "0.38.1", path = "../../visit"} +swc_common = {version = "0.13.0", path = "../../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../../ast"} +swc_ecma_parser = {version = "0.72.0", path = "../../parser"} +swc_ecma_transforms_base = {version = "0.33.0", path = "../base"} +swc_ecma_utils = {version = "0.45.0", path = "../../utils"} +swc_ecma_visit = {version = "0.39.0", path = "../../visit"} +tracing = "0.1.28" [dev-dependencies] -swc_ecma_transforms_compat = {version = "0.36.0", path = "../compat"} -swc_ecma_transforms_module = {version = "0.40.0", path = "../module"} -swc_ecma_transforms_proposal = {version = "0.40.0", path = "../proposal"} -swc_ecma_transforms_react = {version = "0.41.0", path = "../react"} -swc_ecma_transforms_testing = {version = "0.33.0", path = "../testing"} -swc_ecma_transforms_typescript = {version = "0.42.0", path = "../typescript"} -testing = {version = "0.13.0", path = "../../../testing"} +swc_ecma_transforms_compat = {version = "0.37.0", path = "../compat"} +swc_ecma_transforms_module = {version = "0.41.0", path = "../module"} +swc_ecma_transforms_proposal = {version = "0.41.0", path = "../proposal"} +swc_ecma_transforms_react = {version = "0.42.0", path = "../react"} +swc_ecma_transforms_testing = {version = "0.34.0", path = "../testing"} +swc_ecma_transforms_typescript = {version = "0.43.0", path = "../typescript"} +testing = {version = "0.14.0", path = "../../../testing"} diff --git a/ecmascript/transforms/optimization/src/simplify/const_propgation.rs b/ecmascript/transforms/optimization/src/simplify/const_propgation.rs index cb107e0f60e..a82af693dd9 100644 --- a/ecmascript/transforms/optimization/src/simplify/const_propgation.rs +++ b/ecmascript/transforms/optimization/src/simplify/const_propgation.rs @@ -1,4 +1,4 @@ -use fxhash::FxHashMap; +use rustc_hash::FxHashMap; use swc_common::util::take::Take; use swc_ecma_ast::*; use swc_ecma_utils::{ident::IdentLike, Id}; diff --git a/ecmascript/transforms/optimization/src/simplify/dce/mod.rs b/ecmascript/transforms/optimization/src/simplify/dce/mod.rs index 30ea7dce40b..9f953f74b95 100644 --- a/ecmascript/transforms/optimization/src/simplify/dce/mod.rs +++ b/ecmascript/transforms/optimization/src/simplify/dce/mod.rs @@ -1,6 +1,6 @@ use self::side_effect::{ImportDetector, SideEffectVisitor}; -use fxhash::FxHashSet; use retain_mut::RetainMut; +use rustc_hash::FxHashSet; use std::{any::type_name, borrow::Cow, fmt::Debug, mem::take}; use swc_atoms::{js_word, JsWord}; use swc_common::{ @@ -158,9 +158,9 @@ macro_rules! normal { [$($array_like_props:ident),*] ) => { fn $name(&mut self, node: &mut $T) { - log::trace!("Visit<{}>: marking = {}; {:?}", stringify!($T), self.marking_phase, node); + tracing::trace!("Visit<{}>: marking = {}; {:?}", stringify!($T), self.marking_phase, node); if self.is_marked(node.span()) { - log::trace!("Visit<{}>: Already marked", stringify!($T)); + tracing::trace!("Visit<{}>: Already marked", stringify!($T)); return; } @@ -180,7 +180,7 @@ macro_rules! normal { || self.has_marked_elem(&node.$array_like_props) )* { - log::trace!("Visit<{}>: Marking", stringify!($T)); + tracing::trace!("Visit<{}>: Marking", stringify!($T)); node.span = node.span.apply_mark(self.config.used_mark); $( @@ -364,13 +364,13 @@ impl VisitMut for Dce<'_> { } fn visit_mut_expr_stmt(&mut self, node: &mut ExprStmt) { - log::trace!("ExprStmt ->"); + tracing::trace!("ExprStmt ->"); if self.is_marked(node.span) { return; } if self.should_include(&node.expr) { - log::trace!("\tIncluded"); + tracing::trace!("\tIncluded"); node.span = node.span.apply_mark(self.config.used_mark); self.mark(&mut node.expr); return; @@ -476,7 +476,7 @@ impl VisitMut for Dce<'_> { } if self.included.insert(id) { - log::debug!("{} is used", i.sym); + tracing::debug!("{} is used", i.sym); self.changed = true; } } @@ -519,7 +519,7 @@ impl VisitMut for Dce<'_> { } // Drop unused imports. - log::trace!("Removing unused import specifiers"); + tracing::trace!("Removing unused import specifiers"); import.specifiers.retain(|s| self.should_include(s)); if !import.specifiers.is_empty() { @@ -834,7 +834,7 @@ impl Dce<'_> { preserved.reserve(items.len()); loop { - log::debug!("loop start"); + tracing::debug!("loop start"); self.changed = false; let mut idx = 0u32; @@ -878,7 +878,7 @@ impl Dce<'_> { }; if !preserved.contains(&idx) { - log::trace!("Dropping {}: {:?}", idx, item); + tracing::trace!("Dropping {}: {:?}", idx, item); self.dropped = true; idx += 1; return None; @@ -965,7 +965,7 @@ impl Dce<'_> { { let old = self.marking_phase; self.marking_phase = true; - log::debug!("Marking: {}", type_name::()); + tracing::debug!("Marking: {}", type_name::()); node.visit_mut_with(self); self.marking_phase = old; } diff --git a/ecmascript/transforms/optimization/src/simplify/dce/side_effect.rs b/ecmascript/transforms/optimization/src/simplify/dce/side_effect.rs index 57340e343e4..cca07cd411e 100644 --- a/ecmascript/transforms/optimization/src/simplify/dce/side_effect.rs +++ b/ecmascript/transforms/optimization/src/simplify/dce/side_effect.rs @@ -1,5 +1,5 @@ use super::Dce; -use fxhash::FxHashSet; +use rustc_hash::FxHashSet; use swc_atoms::JsWord; use swc_common::DUMMY_SP; use swc_ecma_ast::*; @@ -85,8 +85,6 @@ impl Visit for SideEffectVisitor<'_> { noop_visit_type!(); fn visit_expr(&mut self, node: &Expr, _: &dyn Node) { - log::trace!("Visit"); - if self.found || node.is_pure_callee() { return; } diff --git a/ecmascript/transforms/optimization/src/simplify/inlining/mod.rs b/ecmascript/transforms/optimization/src/simplify/inlining/mod.rs index 47878327d38..ff971ea235a 100644 --- a/ecmascript/transforms/optimization/src/simplify/inlining/mod.rs +++ b/ecmascript/transforms/optimization/src/simplify/inlining/mod.rs @@ -114,7 +114,7 @@ impl VisitMut for Inlining<'_> { } fn visit_mut_assign_expr(&mut self, e: &mut AssignExpr) { - log::trace!("{:?}; Fold", self.phase); + tracing::trace!("{:?}; Fold", self.phase); self.pat_mode = PatFoldingMode::Assign; e.left.map_with_mut(|n| n.normalize_expr()); @@ -124,7 +124,7 @@ impl VisitMut for Inlining<'_> { // match &**left { Expr::Member(ref left) => { - log::trace!("Assign to member expression!"); + tracing::trace!("Assign to member expression!"); let mut v = IdentListVisitor { scope: &mut self.scope, }; @@ -311,9 +311,9 @@ impl VisitMut for Inlining<'_> { self.scope.add_read(&id); } Phase::Inlining => { - log::trace!("Trying to inline: {:?}", id); + tracing::trace!("Trying to inline: {:?}", id); let expr = if let Some(var) = self.scope.find_binding(&id) { - log::trace!("VarInfo: {:?}", var); + tracing::trace!("VarInfo: {:?}", var); if !var.is_inline_prevented() { let expr = var.value.borrow(); @@ -328,12 +328,12 @@ impl VisitMut for Inlining<'_> { *node = *undefined(i.span); return; } else { - log::trace!("Not a cheap expression"); + tracing::trace!("Not a cheap expression"); None } } } else { - log::trace!("Inlining is prevented"); + tracing::trace!("Inlining is prevented"); None } } else { @@ -642,7 +642,7 @@ impl VisitMut for Inlining<'_> { if self.var_decl_kind != VarDeclKind::Const { let id = name.to_id(); - log::trace!("Trying to optimize variable declaration: {:?}", id); + tracing::trace!("Trying to optimize variable declaration: {:?}", id); if self .scope @@ -651,13 +651,13 @@ impl VisitMut for Inlining<'_> { .scope .has_same_this(&id, node.init.as_ref().map(|v| &**v)) { - log::trace!("Inline is prevented for {:?}", id); + tracing::trace!("Inline is prevented for {:?}", id); return; } let mut init = node.init.take(); init.visit_mut_with(self); - log::trace!("\tInit: {:?}", init); + tracing::trace!("\tInit: {:?}", init); if let Some(init) = &init { if let Expr::Ident(ri) = &**init { @@ -673,7 +673,7 @@ impl VisitMut for Inlining<'_> { match init { Some(ref e) => { if self.scope.is_inline_prevented(&e) { - log::trace!( + tracing::trace!( "Inlining is not possible as inline of the \ initialization was prevented" ); @@ -712,7 +712,7 @@ impl VisitMut for Inlining<'_> { } }; - // log::trace!("({}): Inserting {:?}", self.scope.depth(), + // tracing::trace!("({}): Inserting {:?}", self.scope.depth(), // name.to_id()); self.declare(name.to_id(), e.map(|e| Cow::Owned(*e)), false, kind); @@ -748,7 +748,7 @@ impl VisitMut for Inlining<'_> { self.phase = Phase::Analysis; items.visit_mut_children_with(self); - log::trace!("Switching to Inlining phase"); + tracing::trace!("Switching to Inlining phase"); // Inline self.phase = Phase::Inlining; diff --git a/ecmascript/transforms/optimization/src/simplify/inlining/scope.rs b/ecmascript/transforms/optimization/src/simplify/inlining/scope.rs index 44f8d936888..0334dbcb667 100644 --- a/ecmascript/transforms/optimization/src/simplify/inlining/scope.rs +++ b/ecmascript/transforms/optimization/src/simplify/inlining/scope.rs @@ -1,10 +1,11 @@ use super::{Inlining, Phase}; -use fxhash::{FxBuildHasher, FxHashMap, FxHashSet}; use indexmap::map::{Entry, IndexMap}; +use rustc_hash::{FxHashMap, FxHashSet, FxHasher}; use std::{ borrow::Cow, cell::{Cell, RefCell}, collections::VecDeque, + hash::BuildHasherDefault, }; use swc_atoms::js_word; use swc_ecma_ast::*; @@ -58,7 +59,7 @@ impl Inlining<'_> { (child.scope.unresolved_usages, child.scope.bindings) }; - log::trace!("propagating variables"); + tracing::trace!("propagating variables"); self.scope.unresolved_usages.extend(unresolved_usages); @@ -77,7 +78,7 @@ impl Inlining<'_> { }) { let v: VarInfo = v; - log::trace!("Hoisting a variable {:?}", id); + tracing::trace!("Hoisting a variable {:?}", id); if self.scope.unresolved_usages.contains(&id) { v.inline_prevented.set(true) @@ -101,7 +102,7 @@ impl Inlining<'_> { is_change: bool, kind: VarType, ) { - log::trace!( + tracing::trace!( "({}, {:?}) declare({})", self.scope.depth(), self.phase, @@ -142,10 +143,10 @@ impl Inlining<'_> { }; if is_inline_prevented { - log::trace!("\tdeclare: Inline prevented: {:?}", id) + tracing::trace!("\tdeclare: Inline prevented: {:?}", id) } if is_undefined { - log::trace!("\tdeclare: {:?} is undefined", id); + tracing::trace!("\tdeclare: {:?} is undefined", id); } let idx = match self.scope.bindings.entry(id.clone()) { @@ -191,7 +192,7 @@ impl Inlining<'_> { } if scope.kind == ScopeKind::Loop { - log::trace!("preventing inline as it's declared in a loop"); + tracing::trace!("preventing inline as it's declared in a loop"); self.scope.prevent_inline(&id); break; } @@ -209,7 +210,7 @@ impl Inlining<'_> { if barrier_works { if let Some((value_idx, vi)) = value_idx { - log::trace!("\tdeclare: {} -> {}", idx, value_idx); + tracing::trace!("\tdeclare: {} -> {}", idx, value_idx); let barrier_exists = (|| { for &blocker in self.scope.inline_barriers.borrow().iter() { @@ -224,12 +225,12 @@ impl Inlining<'_> { })(); if value_idx > idx || barrier_exists { - log::trace!("Variable use before declaration: {:?}", id); + tracing::trace!("Variable use before declaration: {:?}", id); self.scope.prevent_inline(&id); self.scope.prevent_inline(&vi) } } else { - log::trace!("\tdeclare: value idx is none"); + tracing::trace!("\tdeclare: value idx is none"); } } } @@ -241,7 +242,7 @@ pub(super) struct Scope<'a> { pub kind: ScopeKind, inline_barriers: RefCell>, - bindings: IndexMap, + bindings: IndexMap>, unresolved_usages: FxHashSet, /// Simple optimization. We don't need complex scope analysis. @@ -314,7 +315,7 @@ impl<'a> Scope<'a> { } fn read_prevents_inlining(&self, id: &Id) -> bool { - log::trace!("read_prevents_inlining({:?})", id); + tracing::trace!("read_prevents_inlining({:?})", id); if let Some(v) = self.find_binding(id) { match v.kind { @@ -338,14 +339,17 @@ impl<'a> Scope<'a> { let found = scope.find_binding_from_current(id).is_some(); if found { - log::trace!("found"); + tracing::trace!("found"); break; } - log::trace!("({}): {}: kind = {:?}", scope.depth(), id.0, scope.kind); + tracing::trace!("({}): {}: kind = {:?}", scope.depth(), id.0, scope.kind); match scope.kind { ScopeKind::Fn { .. } => { - log::trace!("{}: variable access from a nested function detected", id.0); + tracing::trace!( + "{}: variable access from a nested function detected", + id.0 + ); return true; } ScopeKind::Loop | ScopeKind::Cond => { @@ -362,7 +366,7 @@ impl<'a> Scope<'a> { pub fn add_read(&mut self, id: &Id) { if self.read_prevents_inlining(id) { - log::trace!("prevent inlining because of read: {}", id.0); + tracing::trace!("prevent inlining because of read: {}", id.0); self.prevent_inline(id) } @@ -377,7 +381,7 @@ impl<'a> Scope<'a> { var_info.inline_prevented.set(true); } } else { - log::trace!("({}): Unresolved usage.: {:?}", self.depth(), id); + tracing::trace!("({}): Unresolved usage.: {:?}", self.depth(), id); self.unresolved_usages.insert(id.clone()); } @@ -390,7 +394,7 @@ impl<'a> Scope<'a> { } fn write_prevents_inline(&self, id: &Id) -> bool { - log::trace!("write_prevents_inline({})", id.0); + tracing::trace!("write_prevents_inline({})", id.0); { let mut cur = Some(self); @@ -401,11 +405,14 @@ impl<'a> Scope<'a> { if found { break; } - log::trace!("({}): {}: kind = {:?}", scope.depth(), id.0, scope.kind); + tracing::trace!("({}): {}: kind = {:?}", scope.depth(), id.0, scope.kind); match scope.kind { ScopeKind::Fn { .. } => { - log::trace!("{}: variable access from a nested function detected", id.0); + tracing::trace!( + "{}: variable access from a nested function detected", + id.0 + ); return true; } ScopeKind::Loop | ScopeKind::Cond => { @@ -422,7 +429,7 @@ impl<'a> Scope<'a> { pub fn add_write(&mut self, id: &Id, force_no_inline: bool) { if self.write_prevents_inline(id) { - log::trace!("prevent inlining because of write: {}", id.0); + tracing::trace!("prevent inlining because of write: {}", id.0); self.prevent_inline(id) } @@ -442,7 +449,7 @@ impl<'a> Scope<'a> { } else if self.has_constant(id) { // noop } else { - log::trace!( + tracing::trace!( "({}): Unresolved. (scope = ({})): {:?}", self.depth(), scope.depth(), @@ -523,7 +530,7 @@ impl<'a> Scope<'a> { } pub fn store_inline_barrier(&self, phase: Phase) { - log::trace!("store_inline_barrier({:?})", phase); + tracing::trace!("store_inline_barrier({:?})", phase); match phase { Phase::Analysis => { @@ -568,7 +575,7 @@ impl<'a> Scope<'a> { } pub fn prevent_inline(&self, id: &Id) { - log::trace!("({}) Prevent inlining: {:?}", self.depth(), id); + tracing::trace!("({}) Prevent inlining: {:?}", self.depth(), id); if let Some(v) = self.find_binding_from_current(id) { v.inline_prevented.set(true); diff --git a/ecmascript/transforms/proposal/Cargo.toml b/ecmascript/transforms/proposal/Cargo.toml index c97d77e5441..e950be55ba7 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.40.0" +version = "0.41.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -16,23 +16,23 @@ multi-module = ["swc_ecma_loader"] [dependencies] either = "1.6.1" -fxhash = "0.2.1" +rustc-hash = "1.1.0" serde = {version = "1.0.118", features = ["derive"]} smallvec = "1.6.0" swc_atoms = {version = "0.2", path = "../../../atoms"} -swc_common = {version = "0.12.0", path = "../../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../../ast"} -swc_ecma_loader = {version = "0.18.1", path = "../../loader", optional = true} -swc_ecma_parser = {version = "0.71.0", path = "../../parser"} -swc_ecma_transforms_base = {version = "0.32.0", path = "../base"} -swc_ecma_transforms_classes = {version = "0.18.0", path = "../classes"} +swc_common = {version = "0.13.0", path = "../../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../../ast"} +swc_ecma_loader = {version = "0.19.0", path = "../../loader", optional = true} +swc_ecma_parser = {version = "0.72.0", path = "../../parser"} +swc_ecma_transforms_base = {version = "0.33.0", path = "../base"} +swc_ecma_transforms_classes = {version = "0.19.0", path = "../classes"} swc_ecma_transforms_macros = {version = "0.2.1", path = "../macros"} -swc_ecma_utils = {version = "0.44.2", path = "../../utils"} -swc_ecma_visit = {version = "0.38.1", path = "../../visit"} +swc_ecma_utils = {version = "0.45.0", path = "../../utils"} +swc_ecma_visit = {version = "0.39.0", path = "../../visit"} [dev-dependencies] serde_json = "1.0.66" -swc_ecma_transforms_compat = {version = "0.36.0", path = "../compat"} -swc_ecma_transforms_module = {version = "0.40.0", path = "../module"} -swc_ecma_transforms_testing = {version = "0.33.0", path = "../testing"} -testing = {version = "0.13.0", path = "../../../testing"} +swc_ecma_transforms_compat = {version = "0.37.0", path = "../compat"} +swc_ecma_transforms_module = {version = "0.41.0", path = "../module"} +swc_ecma_transforms_testing = {version = "0.34.0", path = "../testing"} +testing = {version = "0.14.0", path = "../../../testing"} diff --git a/ecmascript/transforms/proposal/src/decorators/legacy.rs b/ecmascript/transforms/proposal/src/decorators/legacy.rs index 35eee368eb4..d32f22300f4 100644 --- a/ecmascript/transforms/proposal/src/decorators/legacy.rs +++ b/ecmascript/transforms/proposal/src/decorators/legacy.rs @@ -1,6 +1,6 @@ use self::metadata::{Metadata, ParamMetadata}; use super::{contains_decorator, DecoratorFinder}; -use fxhash::FxHashMap; +use rustc_hash::FxHashMap; use smallvec::SmallVec; use std::mem::{replace, take}; use swc_common::{util::move_map::MoveMap, DUMMY_SP}; diff --git a/ecmascript/transforms/proposal/src/decorators/legacy/metadata.rs b/ecmascript/transforms/proposal/src/decorators/legacy/metadata.rs index d82757b7a42..3a8e468856c 100644 --- a/ecmascript/transforms/proposal/src/decorators/legacy/metadata.rs +++ b/ecmascript/transforms/proposal/src/decorators/legacy/metadata.rs @@ -1,5 +1,5 @@ use super::EnumKind; -use fxhash::FxHashMap; +use rustc_hash::FxHashMap; use swc_atoms::js_word; use swc_common::{util::move_map::MoveMap, Spanned, DUMMY_SP}; use swc_ecma_ast::*; diff --git a/ecmascript/transforms/proposal/src/private_in_object.rs b/ecmascript/transforms/proposal/src/private_in_object.rs index 3ca62e40b3f..6b06c1aef99 100644 --- a/ecmascript/transforms/proposal/src/private_in_object.rs +++ b/ecmascript/transforms/proposal/src/private_in_object.rs @@ -1,4 +1,4 @@ -use fxhash::FxHashSet; +use rustc_hash::FxHashSet; use std::{ borrow::Cow, mem::{replace, take}, diff --git a/ecmascript/transforms/react/Cargo.toml b/ecmascript/transforms/react/Cargo.toml index 631d528ed2a..ff56c2c07fc 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.41.0" +version = "0.42.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -20,16 +20,16 @@ serde = {version = "1.0.118", features = ["derive"]} 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.12.0", path = "../../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../../ast"} -swc_ecma_parser = {version = "0.71.0", path = "../../parser"} -swc_ecma_transforms_base = {version = "0.32.0", path = "../base"} -swc_ecma_utils = {version = "0.44.2", path = "../../utils"} -swc_ecma_visit = {version = "0.38.1", path = "../../visit"} +swc_common = {version = "0.13.0", path = "../../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../../ast"} +swc_ecma_parser = {version = "0.72.0", path = "../../parser"} +swc_ecma_transforms_base = {version = "0.33.0", path = "../base"} +swc_ecma_utils = {version = "0.45.0", path = "../../utils"} +swc_ecma_visit = {version = "0.39.0", path = "../../visit"} [dev-dependencies] -swc_ecma_codegen = {version = "0.71.0", path = "../../codegen/"} -swc_ecma_transforms_compat = {version = "0.36.0", path = "../compat/"} -swc_ecma_transforms_module = {version = "0.40.0", path = "../module"} -swc_ecma_transforms_testing = {version = "0.33.0", path = "../testing/"} -testing = {version = "0.13.0", path = "../../../testing"} +swc_ecma_codegen = {version = "0.72.0", path = "../../codegen/"} +swc_ecma_transforms_compat = {version = "0.37.0", path = "../compat/"} +swc_ecma_transforms_module = {version = "0.41.0", path = "../module"} +swc_ecma_transforms_testing = {version = "0.34.0", path = "../testing/"} +testing = {version = "0.14.0", path = "../../../testing"} diff --git a/ecmascript/transforms/testing/Cargo.toml b/ecmascript/transforms/testing/Cargo.toml index d2ebd500c14..229d07ee78a 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.33.0" +version = "0.34.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -15,12 +15,12 @@ ansi_term = "0.12.1" anyhow = "1" serde = "1" serde_json = "1" -swc_common = {version = "0.12.0", path = "../../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../../ast"} -swc_ecma_codegen = {version = "0.71.0", path = "../../codegen"} -swc_ecma_parser = {version = "0.71.0", path = "../../parser"} -swc_ecma_transforms_base = {version = "0.32.0", path = "../base"} -swc_ecma_utils = {version = "0.44.2", path = "../../utils"} -swc_ecma_visit = {version = "0.38.1", path = "../../visit"} +swc_common = {version = "0.13.0", path = "../../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../../ast"} +swc_ecma_codegen = {version = "0.72.0", path = "../../codegen"} +swc_ecma_parser = {version = "0.72.0", path = "../../parser"} +swc_ecma_transforms_base = {version = "0.33.0", path = "../base"} +swc_ecma_utils = {version = "0.45.0", path = "../../utils"} +swc_ecma_visit = {version = "0.39.0", path = "../../visit"} tempfile = "3.1.0" -testing = {version = "0.13.0", path = "../../../testing"} +testing = {version = "0.14.0", path = "../../../testing"} diff --git a/ecmascript/transforms/typescript/Cargo.toml b/ecmascript/transforms/typescript/Cargo.toml index a338656e504..8da4852726a 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.42.0" +version = "0.43.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -fxhash = "0.2.1" +rustc-hash = "1.1.0" serde = {version = "1.0.118", features = ["derive"]} swc_atoms = {version = "0.2", path = "../../../atoms"} -swc_common = {version = "0.12.0", path = "../../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../../ast"} -swc_ecma_parser = {version = "0.71.0", path = "../../parser"} -swc_ecma_transforms_base = {version = "0.32.0", path = "../base"} -swc_ecma_utils = {version = "0.44.2", path = "../../utils"} -swc_ecma_visit = {version = "0.38.1", path = "../../visit"} +swc_common = {version = "0.13.0", path = "../../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../../ast"} +swc_ecma_parser = {version = "0.72.0", path = "../../parser"} +swc_ecma_transforms_base = {version = "0.33.0", path = "../base"} +swc_ecma_utils = {version = "0.45.0", path = "../../utils"} +swc_ecma_visit = {version = "0.39.0", path = "../../visit"} [dev-dependencies] -swc_ecma_codegen = {version = "0.71.0", path = "../../codegen"} -swc_ecma_transforms_compat = {version = "0.36.0", path = "../compat"} -swc_ecma_transforms_module = {version = "0.40.0", path = "../module"} -swc_ecma_transforms_proposal = {version = "0.40.0", path = "../proposal/"} -swc_ecma_transforms_testing = {version = "0.33.0", path = "../testing"} -testing = {version = "0.13.0", path = "../../../testing"} +swc_ecma_codegen = {version = "0.72.0", path = "../../codegen"} +swc_ecma_transforms_compat = {version = "0.37.0", path = "../compat"} +swc_ecma_transforms_module = {version = "0.41.0", path = "../module"} +swc_ecma_transforms_proposal = {version = "0.41.0", path = "../proposal/"} +swc_ecma_transforms_testing = {version = "0.34.0", path = "../testing"} +testing = {version = "0.14.0", path = "../../../testing"} walkdir = "2.3.1" diff --git a/ecmascript/transforms/typescript/src/strip.rs b/ecmascript/transforms/typescript/src/strip.rs index e0dc2d6a0eb..2ec040b70d2 100644 --- a/ecmascript/transforms/typescript/src/strip.rs +++ b/ecmascript/transforms/typescript/src/strip.rs @@ -1,4 +1,4 @@ -use fxhash::{FxHashMap, FxHashSet}; +use rustc_hash::{FxHashMap, FxHashSet}; use serde::{Deserialize, Serialize}; use std::{borrow::Borrow, mem::take}; use swc_atoms::{js_word, JsWord}; diff --git a/ecmascript/utils/Cargo.toml b/ecmascript/utils/Cargo.toml index ab3c78d2bfc..a9a0049c6a4 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.44.2" +version = "0.45.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -14,10 +14,10 @@ version = "0.44.2" once_cell = "1" scoped-tls = "1" swc_atoms = {version = "0.2.0", path = "../../atoms"} -swc_common = {version = "0.12.0", path = "../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../ast"} -swc_ecma_visit = {version = "0.38.1", path = "../visit"} +swc_common = {version = "0.13.0", path = "../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../ast"} +swc_ecma_visit = {version = "0.39.0", path = "../visit"} unicode-xid = "0.2" [dev-dependencies] -testing = {version = "0.13.0", path = "../../testing"} +testing = {version = "0.14.0", path = "../../testing"} diff --git a/ecmascript/visit/Cargo.toml b/ecmascript/visit/Cargo.toml index 951c93c0906..9aae53343ea 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.38.1" +version = "0.39.0" [dependencies] num-bigint = {version = "0.2", features = ["serde"]} swc_atoms = {version = "0.2", path = "../../atoms"} -swc_common = {version = "0.12.0", path = "../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../ast"} +swc_common = {version = "0.13.0", path = "../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../ast"} swc_visit = {version = "0.2.3", path = "../../visit"} diff --git a/node/base/Cargo.toml b/node/base/Cargo.toml index 3e28e22b808..3910c42dce5 100644 --- a/node/base/Cargo.toml +++ b/node/base/Cargo.toml @@ -6,13 +6,13 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_node_base" repository = "https://github.com/swc-project/swc.git" -version = "0.3.0" +version = "0.4.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] dashmap = "4.0.2" -swc_common = {version = "0.12.0", path = "../../common"} +swc_common = {version = "0.13.0", path = "../../common"} [target.'cfg(all(target_arch = "x86_64", not(target_env = "musl")))'.dependencies] mimalloc-rust = "=0.1.1" diff --git a/node/binding/Cargo.toml b/node/binding/Cargo.toml index 25f7b117f7a..5f250c79e1c 100644 --- a/node/binding/Cargo.toml +++ b/node/binding/Cargo.toml @@ -17,11 +17,10 @@ napi-build = {version = "1"} [dependencies] anyhow = "1" backtrace = "0.3" -fxhash = "0.2" -log = {version = "0.4.14", features = ["release_max_level_off"]} napi = {version = "1", features = ["serde-json"]} napi-derive = {version = "1"} path-clean = "0.1" +rustc-hash = "1.1.0" serde = {version = "1", features = ["derive"]} serde_json = {version = "1", features = ["unbounded_depth"]} swc = {path = "../../", features = ["wrong-target"]} @@ -33,3 +32,4 @@ swc_ecma_loader = {path = "../../ecmascript/loader"} swc_ecma_parser = {path = "../../ecmascript/parser"} swc_node_base = {path = "../base"} swc_node_bundler = {path = "../bundler"} +tracing = {version = "0.1.28", features = ["release_max_level_off"]} diff --git a/node/binding/src/bundle.rs b/node/binding/src/bundle.rs index 9ba25f944a4..a6b10cf0487 100644 --- a/node/binding/src/bundle.rs +++ b/node/binding/src/bundle.rs @@ -3,8 +3,8 @@ use crate::{ util::{CtxtExt, MapErr}, }; use anyhow::{bail, Error}; -use fxhash::FxHashMap; use napi::{CallContext, Env, JsObject, Status, Task}; +use rustc_hash::FxHashMap; use serde::Deserialize; use std::{ panic::{catch_unwind, AssertUnwindSafe}, diff --git a/node/binding/src/minify.rs b/node/binding/src/minify.rs index c6efbb7ad70..6d28609a691 100644 --- a/node/binding/src/minify.rs +++ b/node/binding/src/minify.rs @@ -2,8 +2,8 @@ use crate::{ complete_output, get_compiler, util::{CtxtExt, MapErr}, }; -use fxhash::FxHashMap; use napi::{CallContext, JsObject, Task}; +use rustc_hash::FxHashMap; use serde::Deserialize; use std::sync::Arc; use swc::{try_with_handler, TransformOutput}; diff --git a/node/bundler/Cargo.toml b/node/bundler/Cargo.toml index c380923be45..9757e9975de 100644 --- a/node/bundler/Cargo.toml +++ b/node/bundler/Cargo.toml @@ -15,11 +15,10 @@ version = "0.0.0" [dependencies] anyhow = "1" dashmap = "4.0.2" -fxhash = "0.2.1" is-macro = "0.1.8" -log = "0.4.8" once_cell = "1" regex = "1" +rustc-hash = "1.1.0" serde = {version = "1", features = ["derive"]} serde_json = "1" string_enum = {version = "0.3", path = "../../macros/string_enum"} @@ -35,6 +34,7 @@ swc_ecma_transforms = {path = "../../ecmascript/transforms"} swc_ecma_utils = {path = "../../ecmascript/utils"} swc_ecma_visit = {path = "../../ecmascript/visit"} swc_node_base = {path = "../../node/base"} +tracing = "0.1.28" [dev-dependencies] pretty_assertions = "0.6.1" diff --git a/node/bundler/src/config/mod.rs b/node/bundler/src/config/mod.rs index 4b1cda9b788..cab3846496a 100644 --- a/node/bundler/src/config/mod.rs +++ b/node/bundler/src/config/mod.rs @@ -4,7 +4,7 @@ pub use self::{ output::OutputConfig, resolve::{AliasConfig, ResolveConfig}, }; -use fxhash::FxHashMap; +use rustc_hash::FxHashMap; use serde::Deserialize; use std::{collections::HashMap, fmt, marker::PhantomData, path::PathBuf}; use string_enum::StringEnum; diff --git a/node/bundler/src/loaders/swc.rs b/node/bundler/src/loaders/swc.rs index 79817f67278..1ec70c7cbf6 100644 --- a/node/bundler/src/loaders/swc.rs +++ b/node/bundler/src/loaders/swc.rs @@ -69,7 +69,7 @@ impl SwcLoader { } fn load_with_handler(&self, handler: &Handler, name: &FileName) -> Result { - log::debug!("JsLoader.load({})", name); + tracing::debug!("JsLoader.load({})", name); let helpers = Helpers::new(false); match name { @@ -142,7 +142,7 @@ impl SwcLoader { _ => {} } - log::trace!("JsLoader.load: loaded"); + tracing::trace!("JsLoader.load: loaded"); let program = if fm.name.to_string().contains("node_modules") { let program = self.compiler.parse_js( @@ -222,7 +222,7 @@ impl SwcLoader { &fm.name, )?; - log::trace!("JsLoader.load: loaded config"); + tracing::trace!("JsLoader.load: loaded config"); // We run transform at this phase to strip out unused dependencies. // @@ -241,7 +241,7 @@ impl SwcLoader { program.context("tried to parse as ecmascript as it's excluded by .swcrc")? }; - log::trace!("JsLoader.load: parsed"); + tracing::trace!("JsLoader.load: parsed"); // Fold module let program = if let Some(mut config) = config { @@ -261,7 +261,7 @@ impl SwcLoader { program }; - log::trace!("JsLoader.load: applied transforms"); + tracing::trace!("JsLoader.load: applied transforms"); program }; diff --git a/plugin/Cargo.toml b/plugin/Cargo.toml index 020acbe7f4a..9d97b43d51d 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.4.1" +version = "0.5.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -16,7 +16,7 @@ anyhow = "1.0.41" serde = "1.0.126" serde_json = "1.0.64" swc_atoms = {version = "0.2.7", path = "../atoms"} -swc_common = {version = "0.12.0", path = "../common"} -swc_ecma_ast = {version = "0.52.0", path = "../ecmascript/ast"} -swc_ecma_utils = {version = "0.44.2", path = "../ecmascript/utils"} -swc_ecma_visit = {version = "0.38.1", path = "../ecmascript/visit"} +swc_common = {version = "0.13.0", path = "../common"} +swc_ecma_ast = {version = "0.53.0", path = "../ecmascript/ast"} +swc_ecma_utils = {version = "0.45.0", path = "../ecmascript/utils"} +swc_ecma_visit = {version = "0.39.0", path = "../ecmascript/visit"} diff --git a/plugin/runner/Cargo.toml b/plugin/runner/Cargo.toml index 42d0bd0f3ad..925047eb0e1 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.5.0" +version = "0.6.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -16,11 +16,11 @@ libloading = "0.7.0" serde = {version = "1.0.126", features = ["derive"]} serde_json = "1.0.64" swc_atoms = "0.2.7" -swc_common = {version = "0.12.0", path = "../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../../ecmascript/ast"} -swc_ecma_parser = {version = "0.71.0", path = "../../ecmascript/parser"} -swc_plugin = {version = "0.4.1", path = "../"} +swc_common = {version = "0.13.0", path = "../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../../ecmascript/ast"} +swc_ecma_parser = {version = "0.72.0", path = "../../ecmascript/parser"} +swc_plugin = {version = "0.5.0", path = "../"} [dev-dependencies] -swc_ecma_codegen = {version = "0.71.0", path = "../../ecmascript/codegen"} -testing = {version = "0.13.0", path = "../../testing"} +swc_ecma_codegen = {version = "0.72.0", path = "../../ecmascript/codegen"} +testing = {version = "0.14.0", path = "../../testing"} diff --git a/plugin/testing/Cargo.toml b/plugin/testing/Cargo.toml index 4ccb67c926e..cbbab19cc54 100644 --- a/plugin/testing/Cargo.toml +++ b/plugin/testing/Cargo.toml @@ -6,16 +6,16 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_plugin_testing" repository = "https://github.com/swc-project/swc.git" -version = "0.5.0" +version = "0.6.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] anyhow = "1.0.41" swc_atoms = {version = "0.2.7", path = "../../atoms"} -swc_common = {version = "0.12.0", path = "../../common"} -swc_ecma_ast = {version = "0.52.0", path = "../../ecmascript/ast"} -swc_ecma_codegen = {version = "0.71.0", path = "../../ecmascript/codegen"} -swc_ecma_utils = {version = "0.44.2", path = "../../ecmascript/utils"} -swc_ecma_visit = {version = "0.38.1", path = "../../ecmascript/visit"} -swc_plugin = {version = "0.4.1", path = "../"} +swc_common = {version = "0.13.0", path = "../../common"} +swc_ecma_ast = {version = "0.53.0", path = "../../ecmascript/ast"} +swc_ecma_codegen = {version = "0.72.0", path = "../../ecmascript/codegen"} +swc_ecma_utils = {version = "0.45.0", path = "../../ecmascript/utils"} +swc_ecma_visit = {version = "0.39.0", path = "../../ecmascript/visit"} +swc_plugin = {version = "0.5.0", path = "../"} diff --git a/src/lib.rs b/src/lib.rs index 39a3b9c4787..c2808b9fbf2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,10 +52,9 @@ use swc_ecma_visit::{noop_visit_type, FoldWith, Visit, VisitWith}; mod builder; pub mod config; pub mod resolver { - use std::path::PathBuf; - use crate::config::CompiledPaths; - use fxhash::FxHashMap; + use rustc_hash::FxHashMap; + use std::path::PathBuf; use swc_ecma_ast::TargetEnv; use swc_ecma_loader::resolvers::{ lru::CachingResolver, node::NodeModulesResolver, tsc::TsConfigResolver, @@ -236,7 +235,7 @@ impl Compiler { )?)) } _ => { - log::error!("Failed to load source map for non-file input"); + tracing::error!("Failed to load source map for non-file input"); return Ok(None); } } diff --git a/testing/Cargo.toml b/testing/Cargo.toml index a3bfdedf143..a9403518bfe 100644 --- a/testing/Cargo.toml +++ b/testing/Cargo.toml @@ -6,15 +6,15 @@ edition = "2018" license = "Apache-2.0/MIT" name = "testing" repository = "https://github.com/swc-project/swc.git" -version = "0.13.1" +version = "0.14.0" [dependencies] ansi_term = "0.12.1" difference = "2" -env_logger = "0.7.1" -log = "0.4" once_cell = "1" pretty_assertions = "0.7.2" regex = "1" -swc_common = {version = "0.12.0", path = "../common", features = ["tty-emitter"]} +swc_common = {version = "0.13.0", path = "../common", features = ["tty-emitter"]} testing_macros = {version = "0.2.0", path = "./macros"} +tracing = "0.1.28" +tracing-subscriber = {version = "0.2.24", features = ["env-filter"]} diff --git a/testing/src/lib.rs b/testing/src/lib.rs index 1d07224d1e7..a5b6859831b 100644 --- a/testing/src/lib.rs +++ b/testing/src/lib.rs @@ -19,6 +19,7 @@ use swc_common::{ FilePathMapping, SourceMap, }; pub use testing_macros::fixture; +use tracing_subscriber::EnvFilter; #[macro_use] mod macros; @@ -28,38 +29,18 @@ mod paths; mod string_errors; /// Configures logger -pub fn init() { - use ansi_term::Color; +#[must_use] +pub fn init() -> tracing::subscriber::DefaultGuard { + let logger = tracing_subscriber::FmtSubscriber::builder() + .without_time() + .with_target(false) + .with_ansi(true) + .with_env_filter(EnvFilter::from_default_env()) + .with_test_writer() + .pretty() + .finish(); - struct Padded { - value: T, - width: usize, - } - - impl fmt::Display for Padded { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{: (level: log::Level) -> String { - match level { - log::Level::Trace => Color::Cyan.paint("TRACE").to_string(), - log::Level::Debug => Color::Blue.paint("DEBUG").to_string(), - log::Level::Info => Color::Green.paint("INFO ").to_string(), - log::Level::Warn => Color::Yellow.paint("WARN ").to_string(), - log::Level::Error => Color::Red.paint("ERROR").to_string(), - } - } - - let _ = env_logger::Builder::from_default_env() - .is_test(true) - .format(|f, record| { - let level = colored_level(record.level()); - - writeln!(f, " {} > {}", level, record.args(),) - }) - .try_init(); + tracing::subscriber::set_default(logger) } pub fn find_executable(name: &str) -> Option { @@ -98,7 +79,7 @@ pub fn run_test(treat_err_as_bug: bool, op: F) -> Result where F: FnOnce(Lrc, &Handler) -> Result, { - init(); + let _log = init(); let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let (handler, errors) = self::string_errors::new_handler(cm.clone(), treat_err_as_bug); @@ -115,7 +96,7 @@ pub fn run_test2(treat_err_as_bug: bool, op: F) -> Result where F: FnOnce(Lrc, Handler) -> Result, { - init(); + let _log = init(); let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); let (handler, errors) = self::string_errors::new_handler(cm.clone(), treat_err_as_bug); @@ -135,7 +116,7 @@ pub struct Tester { impl Tester { pub fn new() -> Self { - init(); + let _log = init(); Tester { cm: Lrc::new(SourceMap::new(FilePathMapping::empty())),