fix: Migrate dependencies (#2307)

*:
 - Migrate from `log` to `tracing`. (#2284)
 - Migrate from `fxhash` to `rustc-hash`.

swc_common:
 - Add a cargo feature named `debug`.
This commit is contained in:
Donny/강동윤 2021-09-27 18:19:15 +09:00 committed by GitHub
parent e46a842e99
commit 650e1494d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
150 changed files with 1076 additions and 965 deletions

248
Cargo.lock generated
View File

@ -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"

View File

@ -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]]

View File

@ -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"

View File

@ -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()));

View File

@ -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");
}
_ => {}
}

View File

@ -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<ModuleId>,
) -> IndexSet<ModuleId, FxBuildHasher> {
) -> IndexSet<ModuleId, BuildHasherDefault<FxHasher>> {
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
);

View File

@ -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::<Result<FxHashMap<_, _>, _>>()?;
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)
})

View File

@ -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<ModuleId>,
) {
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, ());

View File

@ -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<String, String>, cycle_entries: Vec<&str>) {

View File

@ -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;
}
};

View File

@ -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::*;

View File

@ -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::*;

View File

@ -66,11 +66,11 @@ where
file_name: &FileName,
) -> Result<Option<TransformedModule>, 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::<Vec<_>>();
@ -127,7 +127,7 @@ where
data: ModuleData,
) -> Result<(TransformedModule, Vec<(Source, Lrc<FileName>)>), 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<FileName>)>), 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<FileName>)>), Error> {
self.run(|| {
log::trace!("resolve_imports({})", base);
tracing::trace!("resolve_imports({})", base);
let mut files = vec![];
let mut merged = Imports::default();

View File

@ -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,

View File

@ -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,

View File

@ -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::*;

View File

@ -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::<Vec<_>>();
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);
}

View File

@ -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?

View File

@ -23,13 +23,13 @@ impl Modules {
cycles: &Vec<Vec<ModuleId>>,
cm: &Lrc<SourceMap>,
) {
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);
}
}

View File

@ -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::<Vec<_>>();
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::<Id, Vec<usize>>::default();

View File

@ -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<N, E> = FastGraphMap<N, E, Directed>;
/// Depends on crate feature `graphmap` (default).
#[derive(Clone)]
pub struct FastGraphMap<N, E, Ty> {
nodes: IndexMap<N, Vec<(N, CompactDirection)>, FxBuildHasher>,
edges: IndexMap<(N, N), E, FxBuildHasher>,
nodes: IndexMap<N, Vec<(N, CompactDirection)>, BuildHasherDefault<FxHasher>>,
edges: IndexMap<(N, N), E, BuildHasherDefault<FxHasher>>,
ty: PhantomData<Ty>,
}
@ -578,7 +578,7 @@ where
Ty: EdgeType,
{
from: N,
edges: &'a IndexMap<(N, N), E, FxBuildHasher>,
edges: &'a IndexMap<(N, N), E, BuildHasherDefault<FxHasher>>,
iter: Neighbors<'a, N, Ty>,
}

View File

@ -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"

View File

@ -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,

View File

@ -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.
if cfg!(feature = "debug") {
debug!("buffer: diagnostic={:?}", diagnostic);
}
buffered_diagnostics.push(*diagnostic);
}

View File

@ -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,6 +311,7 @@ impl SourceMap {
.sum();
col.0 - special_chars + non_narrow
};
if cfg!(feature = "debug") {
debug!(
"byte pos {:?} is on the line at byte pos {:?}",
pos, linebpos
@ -320,6 +321,7 @@ impl SourceMap {
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 {
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());
if cfg!(feature = "debug") {
debug!("span_to_lines: lo={:?}", lo);
}
let hi = self.lookup_char_pos(sp.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 {

View File

@ -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"}

View File

@ -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"}

View File

@ -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"}

View File

@ -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"}

View File

@ -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"}

View File

@ -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"}

View File

@ -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"}

View File

@ -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]

View File

@ -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"

View File

@ -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"}

View File

@ -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"}

View File

@ -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"}

View File

@ -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"

View File

@ -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}

View File

@ -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<FileName, Error> {
log::debug!(
debug!(
"Resolve {} from {:#?} for {:#?}",
target,
base,
self.target_env
target, base, self.target_env
);
let base = match base {

View File

@ -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"

View File

@ -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

View File

@ -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<VarDeclKind>,
) -> &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<Id>) {
// 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,

View File

@ -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};

View File

@ -134,7 +134,7 @@ where
where
N: Send + Sync + for<'aa> VisitMutWith<Compressor<'aa, M>>,
{
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<UsageAnalyzer> + for<'aa> VisitMutWith<Compressor<'aa, M>>,
{
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

View File

@ -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 &param.pat {
Pat::Ident(i) => {
log::debug!(
tracing::debug!(
"arguments: Replacing access to arguments to \
normal reference",
);

View File

@ -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 {

View File

@ -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");
}

View File

@ -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<IfStmt> = 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;
}
}

View File

@ -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"
);

View File

@ -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;

View File

@ -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![];

View File

@ -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()
}

View File

@ -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

View File

@ -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<Self>,
{
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(&param_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::<Vec<_>>();
if !self.can_inline_fn_like(&param_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(&param_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![];

View File

@ -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))
}
}
}

View File

@ -50,7 +50,7 @@ where
}
}
log::debug!("join_vars: Joining variables");
tracing::debug!("join_vars: Joining variables");
self.changed = true;
let mut cur: Option<VarDecl> = None;

View File

@ -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"
);
}

View File

@ -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;
}

View File

@ -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,

View File

@ -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::<Vec<_>>()
);
@ -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

View File

@ -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,

View File

@ -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();
}
}

View File

@ -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'"
);

View File

@ -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;
}

View File

@ -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 {

View File

@ -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;
}

View File

@ -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::<Vec<_>>();

View File

@ -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

View File

@ -70,7 +70,7 @@ impl<M> Pure<'_, M> {
};
self.changed = true;
log::debug!(
tracing::debug!(
"if_return: Negating `foo` in `if (foo) return; bar()` to make it `if (!foo) bar()`"
);

View File

@ -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);

View File

@ -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<Stmt>) {
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;

View File

@ -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;
}
_ => {}

View File

@ -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,

View File

@ -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;

View File

@ -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())`"
);

View File

@ -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"
);

View File

@ -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 {

View File

@ -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,

View File

@ -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))
}

View File

@ -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};

View File

@ -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);
}
}

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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::*;

View File

@ -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);
}

View File

@ -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::*;

View File

@ -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};

View File

@ -44,7 +44,7 @@ impl PostcompressOptimizer<'_> {
op!("&&")
};
log::debug!(
tracing::debug!(
"bools: `(a {} !b)` => `(a {} b)` (in bool context)",
*op,
new_op

View File

@ -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::*;

View File

@ -1,4 +1,4 @@
use fxhash::FxHashSet;
use rustc_hash::FxHashSet;
use std::time::Instant;
use swc_common::{
pass::{CompilerPass, Repeated},

View File

@ -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

View File

@ -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]]

View File

@ -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
);
if cfg!(feature = "debug") {
trace!("read_digits(radix = {}), cur = {:?}", radix, self.cur());
}
let start = self.cur_pos();

View File

@ -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) {
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));

View File

@ -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<I> {
/// Name from spec: 'LogicalORExpression'
@ -136,6 +136,7 @@ impl<'a, I: Tokens> Parser<I> {
}
if op.precedence() <= min_prec {
if cfg!(feature = "debug") {
trace!(
"returning {:?} without parsing {:?} because min_prec={}, prec={}",
left,
@ -143,17 +144,19 @@ impl<'a, I: Tokens> Parser<I> {
min_prec,
op.precedence()
);
}
return Ok((left, None));
}
bump!(self);
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!("**") => {

View File

@ -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());
}
}};
}

View File

@ -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"}

View File

@ -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<FxHasher>>,
}
impl Entry {

Some files were not shown because too many files have changed in this diff Show More