diff --git a/deps/swc/Cargo.lock b/deps/swc/Cargo.lock index ecd104830..799963b7c 100644 --- a/deps/swc/Cargo.lock +++ b/deps/swc/Cargo.lock @@ -391,13 +391,11 @@ dependencies = [ "swc_core", "swc_malloc", "tracing", - "tracing-chrome", - "tracing-subscriber", ] [[package]] name = "binding_core_wasm" -version = "1.15.41" +version = "1.15.43" dependencies = [ "anyhow", "getrandom 0.3.4", @@ -410,7 +408,7 @@ dependencies = [ [[package]] name = "binding_es_ast_viewer" -version = "1.15.41" +version = "1.15.43" dependencies = [ "anyhow", "swc_core", @@ -446,7 +444,7 @@ dependencies = [ [[package]] name = "binding_html_wasm" -version = "1.15.41" +version = "1.15.43" dependencies = [ "anyhow", "getrandom 0.3.4", @@ -472,7 +470,7 @@ dependencies = [ [[package]] name = "binding_macros" -version = "66.0.0" +version = "69.0.0" dependencies = [ "anyhow", "console_error_panic_hook", @@ -507,13 +505,11 @@ dependencies = [ "swc_malloc", "swc_nodejs_common", "tracing", - "tracing-chrome", - "tracing-subscriber", ] [[package]] name = "binding_minifier_wasm" -version = "1.15.41" +version = "1.15.43" dependencies = [ "getrandom 0.3.4", "serde", @@ -539,7 +535,7 @@ dependencies = [ [[package]] name = "binding_typescript_wasm" -version = "1.15.41" +version = "1.15.43" dependencies = [ "anyhow", "js-sys", @@ -1777,7 +1773,7 @@ dependencies = [ [[package]] name = "dbg-swc" -version = "56.0.0" +version = "57.0.0" dependencies = [ "anyhow", "clap 3.2.25", @@ -1798,7 +1794,6 @@ dependencies = [ "swc_ecma_transforms_typescript", "swc_ecma_visit", "swc_error_reporters", - "swc_timer", "tempfile", "tracing", "tracing-subscriber", @@ -2222,6 +2217,179 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" +[[package]] +name = "forked_react_compiler" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac2369cf719891033c9b17a8093c7cf83dbad40113d4a24513fe3d42e37050ea" +dependencies = [ + "forked_react_compiler_ast", + "forked_react_compiler_diagnostics", + "forked_react_compiler_hir", + "forked_react_compiler_inference", + "forked_react_compiler_lowering", + "forked_react_compiler_optimization", + "forked_react_compiler_reactive_scopes", + "forked_react_compiler_ssa", + "forked_react_compiler_typeinference", + "forked_react_compiler_utils", + "forked_react_compiler_validation", + "indexmap 2.12.0", + "rustc-hash 2.1.1", + "serde", + "serde_json", +] + +[[package]] +name = "forked_react_compiler_ast" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daccd93f89b1bc808a485767928b80456711e2141e54722e478795c84e0d5c7b" +dependencies = [ + "forked_react_compiler_diagnostics", + "forked_react_compiler_utils", + "indexmap 2.12.0", + "rustc-hash 2.1.1", + "serde", + "serde-transcode", + "serde_json", +] + +[[package]] +name = "forked_react_compiler_diagnostics" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3d5b1d76f01cd1cc64d016880380cada17c2e7e3fc2337ffd2db690cdb3b4e" +dependencies = [ + "rustc-hash 2.1.1", + "serde", +] + +[[package]] +name = "forked_react_compiler_hir" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4668644f0b802b21e0a547e74cbf01dccb8f854c894800f9f1115fa5d0816383" +dependencies = [ + "forked_react_compiler_ast", + "forked_react_compiler_diagnostics", + "forked_react_compiler_utils", + "indexmap 2.12.0", + "rustc-hash 2.1.1", + "serde", + "serde_json", +] + +[[package]] +name = "forked_react_compiler_inference" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b17f5d24f016fe5fab0b15e36fcaa54ef377a341dbcd747f1e4371e29acb3198" +dependencies = [ + "forked_react_compiler_diagnostics", + "forked_react_compiler_hir", + "forked_react_compiler_lowering", + "forked_react_compiler_optimization", + "forked_react_compiler_ssa", + "forked_react_compiler_utils", + "indexmap 2.12.0", + "rustc-hash 2.1.1", +] + +[[package]] +name = "forked_react_compiler_lowering" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dc9d291addca587d64bc90b7d6e58fcd4ebc255aa9a97751e0058ba2a4c1dab" +dependencies = [ + "forked_react_compiler_ast", + "forked_react_compiler_diagnostics", + "forked_react_compiler_hir", + "forked_react_compiler_utils", + "indexmap 2.12.0", + "rustc-hash 2.1.1", + "serde_json", +] + +[[package]] +name = "forked_react_compiler_optimization" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "717defb246a678ab851a46210d65e0c7604cc7944395d380338a3062924965c9" +dependencies = [ + "forked_react_compiler_diagnostics", + "forked_react_compiler_hir", + "forked_react_compiler_lowering", + "forked_react_compiler_ssa", + "forked_react_compiler_utils", + "indexmap 2.12.0", + "rustc-hash 2.1.1", +] + +[[package]] +name = "forked_react_compiler_reactive_scopes" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "928d6ae8021a1c8f5a32b20cf2ef4b20f76cf997ae753c4e958e896bcf64ae90" +dependencies = [ + "forked_react_compiler_ast", + "forked_react_compiler_diagnostics", + "forked_react_compiler_hir", + "forked_react_compiler_utils", + "hmac-sha256", + "indexmap 2.12.0", + "rustc-hash 2.1.1", + "serde_json", +] + +[[package]] +name = "forked_react_compiler_ssa" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd26c931f5a799188a2d7bb5960cfde048c91348a074876e49c9f7d6e8581d93" +dependencies = [ + "forked_react_compiler_diagnostics", + "forked_react_compiler_hir", + "forked_react_compiler_utils", + "indexmap 2.12.0", + "rustc-hash 2.1.1", +] + +[[package]] +name = "forked_react_compiler_typeinference" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f603c0f89520b55e9c34fc6264df6f29bba60d7e94269f433dd13ba76c4d686" +dependencies = [ + "forked_react_compiler_diagnostics", + "forked_react_compiler_hir", + "forked_react_compiler_ssa", + "rustc-hash 2.1.1", +] + +[[package]] +name = "forked_react_compiler_utils" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5390b90b48cf2aaab7e511009e10e6b8c2c5b750a8c873881b4014e4295cb128" +dependencies = [ + "indexmap 2.12.0", + "rustc-hash 2.1.1", +] + +[[package]] +name = "forked_react_compiler_validation" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7801bd3359181d53a99a06c43f76943f56736814f3dead0ce5fac9118391f18b" +dependencies = [ + "forked_react_compiler_diagnostics", + "forked_react_compiler_hir", + "forked_react_compiler_utils", + "indexmap 2.12.0", + "rustc-hash 2.1.1", +] + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -2628,6 +2796,12 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hmac-sha256" +version = "1.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec9d92d097f4749b64e8cc33d924d9f40a2d4eb91402b458014b781f5733d60f" + [[package]] name = "hstr" version = "3.0.6" @@ -4432,7 +4606,7 @@ dependencies = [ [[package]] name = "preset_env_base" -version = "8.0.0" +version = "8.0.1" dependencies = [ "anyhow", "browserslist-rs", @@ -5266,6 +5440,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde-transcode" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "590c0e25c2a5bb6e85bf5c1bce768ceb86b316e7a01bdf07d2cb4ec2271990e2" +dependencies = [ + "serde", +] + [[package]] name = "serde-wasm-bindgen" version = "0.6.5" @@ -5631,7 +5814,7 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "swc" -version = "66.0.1" +version = "69.0.0" dependencies = [ "ansi_term", "anyhow", @@ -5665,6 +5848,7 @@ dependencies = [ "swc_ecma_minifier", "swc_ecma_parser", "swc_ecma_preset_env", + "swc_ecma_react_compiler", "swc_ecma_testing", "swc_ecma_transforms", "swc_ecma_transforms_base", @@ -5680,7 +5864,6 @@ dependencies = [ "swc_plugin_proxy", "swc_plugin_runner", "swc_sourcemap", - "swc_timer", "swc_transform_common", "swc_typescript", "swc_visit", @@ -5758,7 +5941,7 @@ dependencies = [ [[package]] name = "swc_bundler" -version = "51.0.0" +version = "51.0.1" dependencies = [ "anyhow", "crc", @@ -5800,7 +5983,7 @@ dependencies = [ [[package]] name = "swc_cli" -version = "0.113.2" +version = "0.116.3" dependencies = [ "anyhow", "par-core", @@ -5809,7 +5992,7 @@ dependencies = [ [[package]] name = "swc_cli_impl" -version = "68.0.0" +version = "71.0.0" dependencies = [ "anyhow", "assert_cmd", @@ -5824,14 +6007,12 @@ dependencies = [ "serde_json", "swc_core", "tracing", - "tracing-chrome", - "tracing-subscriber", "walkdir", ] [[package]] name = "swc_common" -version = "23.0.1" +version = "23.0.2" dependencies = [ "anyhow", "arbitrary", @@ -5865,7 +6046,7 @@ dependencies = [ [[package]] name = "swc_compiler_base" -version = "58.0.0" +version = "59.0.0" dependencies = [ "anyhow", "base64 0.22.1", @@ -5886,7 +6067,6 @@ dependencies = [ "swc_ecma_parser", "swc_ecma_visit", "swc_sourcemap", - "swc_timer", ] [[package]] @@ -5920,7 +6100,7 @@ dependencies = [ [[package]] name = "swc_core" -version = "68.0.6" +version = "71.0.3" dependencies = [ "anyhow", "binding_macros", @@ -5966,7 +6146,6 @@ dependencies = [ "swc_plugin_macro", "swc_plugin_proxy", "swc_plugin_runner", - "swc_trace_macro", "swc_transform_common", "swc_typescript", "testing", @@ -6184,7 +6363,7 @@ dependencies = [ [[package]] name = "swc_ecma_codegen" -version = "28.0.1" +version = "28.0.2" dependencies = [ "ascii", "base64 0.22.1", @@ -6222,7 +6401,7 @@ dependencies = [ [[package]] name = "swc_ecma_compat_bugfixes" -version = "50.0.0" +version = "51.0.0" dependencies = [ "rustc-hash 2.1.1", "swc_atoms", @@ -6234,13 +6413,12 @@ dependencies = [ "swc_ecma_transforms_testing", "swc_ecma_utils", "swc_ecma_visit", - "swc_trace_macro", "tracing", ] [[package]] name = "swc_ecma_compat_common" -version = "40.0.0" +version = "40.0.1" dependencies = [ "swc_common", "swc_ecma_ast", @@ -6250,7 +6428,7 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2015" -version = "49.0.0" +version = "50.0.0" dependencies = [ "arrayvec", "indexmap 2.12.0", @@ -6272,7 +6450,6 @@ dependencies = [ "swc_ecma_transforms_testing", "swc_ecma_utils", "swc_ecma_visit", - "swc_trace_macro", "tracing", ] @@ -6330,7 +6507,7 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2020" -version = "47.0.0" +version = "48.0.0" dependencies = [ "serde", "swc_common", @@ -6356,7 +6533,7 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2022" -version = "47.0.0" +version = "48.0.0" dependencies = [ "rustc-hash 2.1.1", "swc_atoms", @@ -6368,7 +6545,6 @@ dependencies = [ "swc_ecma_transforms_macros", "swc_ecma_utils", "swc_ecma_visit", - "swc_trace_macro", "tracing", ] @@ -6415,7 +6591,7 @@ dependencies = [ [[package]] name = "swc_ecma_lexer" -version = "40.0.0" +version = "40.0.1" dependencies = [ "bitflags 2.10.0", "either", @@ -6461,7 +6637,7 @@ dependencies = [ [[package]] name = "swc_ecma_loader" -version = "24.0.0" +version = "24.0.1" dependencies = [ "anyhow", "dashmap 6.1.0", @@ -6482,7 +6658,7 @@ dependencies = [ [[package]] name = "swc_ecma_minifier" -version = "55.0.1" +version = "56.0.1" dependencies = [ "ansi_term", "anyhow", @@ -6518,7 +6694,6 @@ dependencies = [ "swc_ecma_utils", "swc_ecma_visit", "swc_malloc", - "swc_timer", "testing", "tracing", "walkdir", @@ -6526,7 +6701,7 @@ dependencies = [ [[package]] name = "swc_ecma_parser" -version = "41.0.1" +version = "41.1.2" dependencies = [ "bitflags 2.10.0", "cbor4ii", @@ -6554,7 +6729,7 @@ dependencies = [ [[package]] name = "swc_ecma_preset_env" -version = "56.0.0" +version = "57.0.0" dependencies = [ "anyhow", "codspeed-criterion-compat", @@ -6607,10 +6782,19 @@ dependencies = [ [[package]] name = "swc_ecma_react_compiler" -version = "19.0.0" +version = "20.0.2" dependencies = [ + "forked_react_compiler", + "forked_react_compiler_ast", + "forked_react_compiler_hir", + "indexmap 2.12.0", + "rustc-hash 2.1.1", + "serde", + "serde_json", + "swc_atoms", "swc_common", "swc_ecma_ast", + "swc_ecma_codegen", "swc_ecma_parser", "swc_ecma_visit", "testing", @@ -6661,7 +6845,7 @@ dependencies = [ [[package]] name = "swc_ecma_testing" -version = "24.0.0" +version = "24.0.1" dependencies = [ "anyhow", "hex", @@ -6672,7 +6856,7 @@ dependencies = [ [[package]] name = "swc_ecma_transformer" -version = "16.0.1" +version = "16.0.3" dependencies = [ "rustc-hash 2.1.1", "swc_atoms", @@ -6689,7 +6873,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms" -version = "55.0.1" +version = "56.0.0" dependencies = [ "par-core", "swc_common", @@ -6709,7 +6893,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_base" -version = "44.0.2" +version = "44.0.3" dependencies = [ "better_scoped_tls", "codspeed-criterion-compat", @@ -6746,7 +6930,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_compat" -version = "51.0.1" +version = "52.0.1" dependencies = [ "indexmap 2.12.0", "par-core", @@ -6787,7 +6971,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_module" -version = "49.0.0" +version = "49.0.1" dependencies = [ "Inflector", "anyhow", @@ -6819,7 +7003,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_optimization" -version = "47.0.0" +version = "47.0.1" dependencies = [ "bytes-str", "dashmap 6.1.0", @@ -6869,7 +7053,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_react" -version = "49.0.0" +version = "50.0.0" dependencies = [ "base64 0.22.1", "bytes-str", @@ -6920,7 +7104,7 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_typescript" -version = "49.0.0" +version = "50.0.0" dependencies = [ "bytes-str", "codspeed-criterion-compat", @@ -6944,7 +7128,7 @@ dependencies = [ [[package]] name = "swc_ecma_utils" -version = "31.0.0" +version = "31.0.1" dependencies = [ "dragonbox_ecma", "indexmap 2.12.0", @@ -6977,7 +7161,7 @@ dependencies = [ [[package]] name = "swc_ecmascript" -version = "63.0.0" +version = "64.0.0" dependencies = [ "par-core", "swc_ecma_ast", @@ -7048,7 +7232,7 @@ dependencies = [ [[package]] name = "swc_graph_analyzer" -version = "14.0.1" +version = "14.0.2" dependencies = [ "auto_impl", "petgraph", @@ -7108,7 +7292,7 @@ dependencies = [ [[package]] name = "swc_html_minifier" -version = "55.0.0" +version = "56.0.0" dependencies = [ "codspeed-criterion-compat", "once_cell", @@ -7195,7 +7379,7 @@ dependencies = [ [[package]] name = "swc_node_bundler" -version = "67.0.0" +version = "70.0.0" dependencies = [ "anyhow", "rustc-hash 2.1.1", @@ -7271,7 +7455,7 @@ dependencies = [ [[package]] name = "swc_plugin_backend_wasmer" -version = "12.0.0" +version = "13.0.0" dependencies = [ "anyhow", "enumset", @@ -7285,7 +7469,7 @@ dependencies = [ [[package]] name = "swc_plugin_backend_wasmtime" -version = "11.0.0" +version = "12.0.0" dependencies = [ "anyhow", "swc_common", @@ -7296,7 +7480,7 @@ dependencies = [ [[package]] name = "swc_plugin_macro" -version = "1.1.0" +version = "1.1.1" dependencies = [ "proc-macro2", "quote", @@ -7305,20 +7489,19 @@ dependencies = [ [[package]] name = "swc_plugin_proxy" -version = "25.0.0" +version = "26.0.0" dependencies = [ "better_scoped_tls", "cbor4ii", "rustc-hash 2.1.1", "swc_common", "swc_ecma_ast", - "swc_trace_macro", "tracing", ] [[package]] name = "swc_plugin_runner" -version = "29.0.0" +version = "30.0.0" dependencies = [ "anyhow", "blake3", @@ -7355,22 +7538,6 @@ dependencies = [ "url", ] -[[package]] -name = "swc_timer" -version = "1.0.0" -dependencies = [ - "testing", - "tracing", -] - -[[package]] -name = "swc_trace_macro" -version = "2.0.2" -dependencies = [ - "quote", - "syn 2.0.110", -] - [[package]] name = "swc_transform_common" version = "17.0.0" @@ -7383,7 +7550,7 @@ dependencies = [ [[package]] name = "swc_ts_fast_strip" -version = "52.0.0" +version = "53.0.0" dependencies = [ "anyhow", "bytes-str", @@ -7404,7 +7571,7 @@ dependencies = [ [[package]] name = "swc_ts_fast_strip_binding" -version = "0.17.0" +version = "0.18.0" dependencies = [ "anyhow", "miette", @@ -7421,7 +7588,7 @@ dependencies = [ [[package]] name = "swc_typescript" -version = "30.0.0" +version = "30.0.1" dependencies = [ "bitflags 2.10.0", "petgraph", @@ -7679,7 +7846,7 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "testing" -version = "24.0.0" +version = "24.0.1" dependencies = [ "cargo_metadata", "difference", @@ -8005,17 +8172,6 @@ dependencies = [ "syn 2.0.110", ] -[[package]] -name = "tracing-chrome" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf0a738ed5d6450a9fb96e86a23ad808de2b727fd1394585da5cdd6788ffe724" -dependencies = [ - "serde_json", - "tracing-core", - "tracing-subscriber", -] - [[package]] name = "tracing-core" version = "0.1.33" diff --git a/deps/swc/Cargo.toml b/deps/swc/Cargo.toml index 2f655dd3d..50a6d51b3 100644 --- a/deps/swc/Cargo.toml +++ b/deps/swc/Cargo.toml @@ -126,7 +126,6 @@ thiserror = "1.0.30" tokio = { version = "1", default-features = false } toml = "0.8.2" tracing = "0.1.41" -tracing-chrome = "0.7.2" tracing-subscriber = "0.3.20" triomphe = "0.1.13" unicode-id-start = "1.2.0" diff --git a/deps/swc/bindings/binding_core_node/Cargo.toml b/deps/swc/bindings/binding_core_node/Cargo.toml index 6385bfd20..39426f170 100644 --- a/deps/swc/bindings/binding_core_node/Cargo.toml +++ b/deps/swc/bindings/binding_core_node/Cargo.toml @@ -44,8 +44,6 @@ rustc-hash = { workspace = true } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true, features = ["unbounded_depth"] } tracing = { workspace = true, features = ["release_max_level_info"] } -tracing-chrome = { workspace = true } -tracing-subscriber = { workspace = true, features = ["env-filter"] } swc_core = { path = "../../crates/swc_core", features = [ "allocator_node", @@ -63,5 +61,6 @@ swc_core = { path = "../../crates/swc_core", features = [ "base_concurrent", "base_flow", "base_module", + "base_react_compiler", ] } swc_malloc = { path = "../../crates/swc_malloc" } diff --git a/deps/swc/bindings/binding_core_node/src/analyze.rs b/deps/swc/bindings/binding_core_node/src/analyze.rs index 46589bade..f608185eb 100644 --- a/deps/swc/bindings/binding_core_node/src/analyze.rs +++ b/deps/swc/bindings/binding_core_node/src/analyze.rs @@ -9,7 +9,6 @@ use swc_core::{ common::{comments::SingleThreadedComments, FileName}, node::MapErr, }; -use tracing::instrument; use crate::{get_fresh_compiler, util::try_with}; @@ -24,7 +23,7 @@ impl Task for AnalyzeTask { type JsValue = String; type Output = String; - #[instrument(level = "trace", skip_all)] + #[cfg_attr(debug_assertions, tracing::instrument(level = "trace", skip_all))] fn compute(&mut self) -> napi::Result { let options: WasmAnalysisOptions = serde_json::from_slice(self.options.as_ref())?; diff --git a/deps/swc/bindings/binding_core_node/src/lib.rs b/deps/swc/bindings/binding_core_node/src/lib.rs index 6450cb436..afa5a1089 100644 --- a/deps/swc/bindings/binding_core_node/src/lib.rs +++ b/deps/swc/bindings/binding_core_node/src/lib.rs @@ -59,7 +59,7 @@ pub struct JsCompiler { impl JsCompiler { #[napi(constructor)] #[allow(clippy::new_without_default)] - #[tracing::instrument(level = "info", skip_all)] + #[cfg_attr(debug_assertions, tracing::instrument(level = "info", skip_all))] pub fn new() -> Self { Self { _compiler: COMPILER.clone(), diff --git a/deps/swc/bindings/binding_core_node/src/transform.rs b/deps/swc/bindings/binding_core_node/src/transform.rs index 2bdd1dbe9..c0ac1367a 100644 --- a/deps/swc/bindings/binding_core_node/src/transform.rs +++ b/deps/swc/bindings/binding_core_node/src/transform.rs @@ -15,7 +15,6 @@ use swc_core::{ ecma::ast::noop_pass, node::{get_deserialized, MapErr}, }; -use tracing::instrument; use crate::{ ast_context::{deserialize_program_input, prepare_program_with_context, ProgramInput}, @@ -82,7 +81,7 @@ impl Task for TransformTask { type JsValue = TransformOutput; type Output = TransformOutput; - #[instrument(level = "trace", skip_all)] + #[cfg_attr(debug_assertions, tracing::instrument(level = "trace", skip_all))] fn compute(&mut self) -> napi::Result { let mut options: Options = serde_json::from_slice(self.options.as_ref())?; if !options.filename.is_empty() { @@ -143,7 +142,7 @@ impl Task for TransformTask { } #[napi] -#[instrument(level = "trace", skip_all)] +#[cfg_attr(debug_assertions, tracing::instrument(level = "trace", skip_all))] pub fn transform( src: String, is_module: bool, @@ -163,7 +162,7 @@ pub fn transform( } #[napi] -#[instrument(level = "trace", skip_all)] +#[cfg_attr(debug_assertions, tracing::instrument(level = "trace", skip_all))] pub fn transform_sync(s: String, is_module: bool, opts: Buffer) -> napi::Result { crate::util::init_default_trace_subscriber(); @@ -212,7 +211,7 @@ pub fn transform_sync(s: String, is_module: bool, opts: Buffer) -> napi::Result< } #[napi] -#[instrument(level = "trace", skip_all)] +#[cfg_attr(debug_assertions, tracing::instrument(level = "trace", skip_all))] pub fn transform_file( src: String, _is_module: bool, diff --git a/deps/swc/bindings/binding_core_node/src/util.rs b/deps/swc/bindings/binding_core_node/src/util.rs index acffdb166..9881d9ef9 100644 --- a/deps/swc/bindings/binding_core_node/src/util.rs +++ b/deps/swc/bindings/binding_core_node/src/util.rs @@ -6,20 +6,10 @@ use anyhow::{anyhow, Error}; use napi::Env; use swc_core::{ base::{config::ErrorFormat, try_with_handler}, - common::{ - errors::Handler, - sync::{Lrc, OnceCell}, - SourceMap, GLOBALS, - }, -}; -use tracing::instrument; -use tracing_chrome::ChromeLayerBuilder; -use tracing_subscriber::{ - filter, prelude::__tracing_subscriber_SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer, + common::{errors::Handler, sync::Lrc, SourceMap, GLOBALS}, }; static TARGET_TRIPLE: &str = include_str!(concat!(env!("OUT_DIR"), "/triple.txt")); -static CUSTOM_TRACE_SUBSCRIBER: OnceCell = OnceCell::new(); #[napi] pub fn get_target_triple() -> napi::Result { @@ -28,36 +18,13 @@ pub fn get_target_triple() -> napi::Result { #[napi] pub fn init_custom_trace_subscriber( - env: Env, - trace_out_file_path: Option, + _env: Env, + _trace_out_file_path: Option, ) -> napi::Result<()> { - CUSTOM_TRACE_SUBSCRIBER.get_or_init(|| { - let mut layer = ChromeLayerBuilder::new().include_args(true); - if let Some(trace_out_file) = trace_out_file_path { - layer = layer.file(trace_out_file); - } - - let (chrome_layer, guard) = layer.build(); - tracing_subscriber::registry() - .with(chrome_layer.with_filter(filter::filter_fn(|metadata| { - !metadata.target().contains("cranelift") && !metadata.name().contains("log ") - }))) - .try_init() - .expect("Failed to register tracing subscriber"); - - env.add_env_cleanup_hook(guard, |flush_guard| { - flush_guard.flush(); - drop(flush_guard); - }) - .expect("Should able to initialize cleanup for custom trace subscriber"); - - true - }); - Ok(()) } -#[instrument(level = "trace", skip_all)] +#[cfg_attr(debug_assertions, tracing::instrument(level = "trace", skip_all))] pub fn try_with( cm: Lrc, skip_filename: bool, @@ -101,16 +68,5 @@ where // interface for the custom binary - they should choose own trace initialization // instead. Will keep as hidden for now until there's proper usecase. -/// Trying to initialize default subscriber if global dispatch is not set. -/// This can be called multiple time, however subsequent calls will be ignored -/// as tracing_subscriber only allows single global dispatch. -pub fn init_default_trace_subscriber() { - let _unused = tracing_subscriber::FmtSubscriber::builder() - .without_time() - .with_target(false) - .with_writer(std::io::stderr) - .with_ansi(true) - .with_env_filter(EnvFilter::from_env("SWC_LOG")) - .pretty() - .try_init(); -} +/// Deprecated no-op kept for compatibility with existing binding entrypoints. +pub fn init_default_trace_subscriber() {} diff --git a/deps/swc/bindings/binding_core_wasm/Cargo.toml b/deps/swc/bindings/binding_core_wasm/Cargo.toml index 85d5f5672..b32d18c4d 100644 --- a/deps/swc/bindings/binding_core_wasm/Cargo.toml +++ b/deps/swc/bindings/binding_core_wasm/Cargo.toml @@ -6,7 +6,7 @@ license = { workspace = true } name = "binding_core_wasm" publish = false repository = { workspace = true } -version = "1.15.41" +version = "1.15.43" [lib] bench = false @@ -45,6 +45,7 @@ swc_core = { path = "../../crates/swc_core", features = [ "ecma_helpers_inline", "ecma_lints", "base_module", + "base_react_compiler", ] } tracing = { workspace = true, features = ["max_level_off"] } wasm-bindgen = { workspace = true, features = ["enable-interning"] } diff --git a/deps/swc/bindings/binding_core_wasm/src/types.rs b/deps/swc/bindings/binding_core_wasm/src/types.rs index 96cec31d3..4548cd57e 100644 --- a/deps/swc/bindings/binding_core_wasm/src/types.rs +++ b/deps/swc/bindings/binding_core_wasm/src/types.rs @@ -840,6 +840,8 @@ export interface TransformConfig { */ react?: ReactConfig; + reactCompiler?: boolean | ReactCompilerOptions; + constModules?: ConstModulesConfig; /** @@ -862,6 +864,108 @@ export interface TransformConfig { useDefineForClassFields?: boolean; } +export interface ReactCompilerOptions { + /** + * Which functions to compile. + * + * Defaults to `"infer"`. + */ + compilationMode?: "infer" | "syntax" | "annotation" | "all"; + + /** + * What to do when a function cannot be compiled. + * + * Defaults to `"none"`. + */ + panicThreshold?: "none" | "critical_errors" | "all_errors"; + + /** + * React runtime version target. + * + * Defaults to `"19"`. + */ + target?: "17" | "18" | "19"; + + /** + * Analyze and report diagnostics only; emit no transformed code. + * + * Defaults to `false`. + */ + noEmit?: boolean; + + /** + * Defaults to `"client"`. + */ + outputMode?: "client" | "ssr" | "lint"; + + /** + * Compile even functions marked with opt-out directives. + * + * Defaults to `false`. + */ + ignoreUseNoForget?: boolean; + + /** + * Treat Flow suppression comments as opt-outs. + * + * Defaults to `true`. + */ + flowSuppressions?: boolean; + + /** + * Enable react-native-reanimated support. + * + * Defaults to `false`. + */ + enableReanimated?: boolean; + + /** + * Development mode. + * + * Defaults to `false`. + */ + isDev?: boolean; + + /** + * ESLint rules whose suppressions opt a function out of compilation. + */ + eslintSuppressionRules?: string[]; + + /** + * Extra directives that opt a function out of compilation. + */ + customOptOutDirectives?: string[]; + + /** + * Emit a gated version of each compiled function. + */ + gating?: ReactCompilerGatingConfig; + + /** + * Dynamically-gated compilation. + */ + dynamicGating?: ReactCompilerDynamicGatingConfig; +} + +export interface ReactCompilerGatingConfig { + /** + * Module the gating import comes from. + */ + source: string; + + /** + * Imported specifier used as the gate. + */ + importSpecifierName: string; +} + +export interface ReactCompilerDynamicGatingConfig { + /** + * Module the gating import comes from. + */ + source: string; +} + export interface ReactConfig { /** * Replace the function used when compiling JSX expressions. diff --git a/deps/swc/bindings/binding_es_ast_viewer/Cargo.toml b/deps/swc/bindings/binding_es_ast_viewer/Cargo.toml index 93b4e991b..d3463ac53 100644 --- a/deps/swc/bindings/binding_es_ast_viewer/Cargo.toml +++ b/deps/swc/bindings/binding_es_ast_viewer/Cargo.toml @@ -5,7 +5,7 @@ license = { workspace = true } name = "binding_es_ast_viewer" publish = false repository = { workspace = true } -version = "1.15.41" +version = "1.15.43" [dependencies] anyhow = { workspace = true } diff --git a/deps/swc/bindings/binding_html_wasm/Cargo.toml b/deps/swc/bindings/binding_html_wasm/Cargo.toml index 1687ce5d6..0a1a99798 100644 --- a/deps/swc/bindings/binding_html_wasm/Cargo.toml +++ b/deps/swc/bindings/binding_html_wasm/Cargo.toml @@ -6,7 +6,7 @@ license = { workspace = true } name = "binding_html_wasm" publish = false repository = { workspace = true } -version = "1.15.41" +version = "1.15.43" [lib] bench = false diff --git a/deps/swc/bindings/binding_minifier_node/Cargo.toml b/deps/swc/bindings/binding_minifier_node/Cargo.toml index 20d0d1d4c..08c06dfef 100644 --- a/deps/swc/bindings/binding_minifier_node/Cargo.toml +++ b/deps/swc/bindings/binding_minifier_node/Cargo.toml @@ -23,8 +23,6 @@ napi-derive = { workspace = true, features = ["type-def"] } par-core = { workspace = true, features = ["chili"] } serde = { workspace = true, features = ["derive"] } tracing = { workspace = true, features = ["release_max_level_info"] } -tracing-chrome = { workspace = true } -tracing-subscriber = { workspace = true, features = ["env-filter"] } swc_compiler_base = { path = "../../crates/swc_compiler_base", features = [ diff --git a/deps/swc/bindings/binding_minifier_node/src/util.rs b/deps/swc/bindings/binding_minifier_node/src/util.rs index fe149304d..f0dfb7a1a 100644 --- a/deps/swc/bindings/binding_minifier_node/src/util.rs +++ b/deps/swc/bindings/binding_minifier_node/src/util.rs @@ -4,20 +4,10 @@ use std::panic::{catch_unwind, AssertUnwindSafe}; use anyhow::{anyhow, Error}; use napi::Env; -use swc_core::common::{ - errors::Handler, - sync::{Lrc, OnceCell}, - SourceMap, GLOBALS, -}; +use swc_core::common::{errors::Handler, sync::Lrc, SourceMap, GLOBALS}; use swc_error_reporters::handler::try_with_handler; -use tracing::instrument; -use tracing_chrome::ChromeLayerBuilder; -use tracing_subscriber::{ - filter, prelude::__tracing_subscriber_SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer, -}; static TARGET_TRIPLE: &str = include_str!(concat!(env!("OUT_DIR"), "/triple.txt")); -static CUSTOM_TRACE_SUBSCRIBER: OnceCell = OnceCell::new(); #[napi] pub fn get_target_triple() -> napi::Result { @@ -26,36 +16,13 @@ pub fn get_target_triple() -> napi::Result { #[napi] pub fn init_custom_trace_subscriber( - env: Env, - trace_out_file_path: Option, + _env: Env, + _trace_out_file_path: Option, ) -> napi::Result<()> { - CUSTOM_TRACE_SUBSCRIBER.get_or_init(|| { - let mut layer = ChromeLayerBuilder::new().include_args(true); - if let Some(trace_out_file) = trace_out_file_path { - layer = layer.file(trace_out_file); - } - - let (chrome_layer, guard) = layer.build(); - tracing_subscriber::registry() - .with(chrome_layer.with_filter(filter::filter_fn(|metadata| { - !metadata.target().contains("cranelift") && !metadata.name().contains("log ") - }))) - .try_init() - .expect("Failed to register tracing subscriber"); - - env.add_env_cleanup_hook(guard, |flush_guard| { - flush_guard.flush(); - drop(flush_guard); - }) - .expect("Should able to initialize cleanup for custom trace subscriber"); - - true - }); - Ok(()) } -#[instrument(level = "trace", skip_all)] +#[cfg_attr(debug_assertions, tracing::instrument(level = "trace", skip_all))] pub fn try_with(cm: Lrc, skip_filename: bool, op: F) -> Result where F: FnOnce(&Handler) -> Result, @@ -94,16 +61,5 @@ where // interface for the custom binary - they should choose own trace initialization // instead. Will keep as hidden for now until there's proper usecase. -/// Trying to initialize default subscriber if global dispatch is not set. -/// This can be called multiple time, however subsequent calls will be ignored -/// as tracing_subscriber only allows single global dispatch. -pub fn init_default_trace_subscriber() { - let _unused = tracing_subscriber::FmtSubscriber::builder() - .without_time() - .with_target(false) - .with_writer(std::io::stderr) - .with_ansi(true) - .with_env_filter(EnvFilter::from_env("SWC_LOG")) - .pretty() - .try_init(); -} +/// Deprecated no-op kept for compatibility with existing binding entrypoints. +pub fn init_default_trace_subscriber() {} diff --git a/deps/swc/bindings/binding_minifier_wasm/Cargo.toml b/deps/swc/bindings/binding_minifier_wasm/Cargo.toml index ebf9d5261..724f4f104 100644 --- a/deps/swc/bindings/binding_minifier_wasm/Cargo.toml +++ b/deps/swc/bindings/binding_minifier_wasm/Cargo.toml @@ -6,7 +6,7 @@ license = { workspace = true } name = "binding_minifier_wasm" publish = false repository = { workspace = true } -version = "1.15.41" +version = "1.15.43" [lib] bench = false diff --git a/deps/swc/bindings/binding_typescript_wasm/Cargo.toml b/deps/swc/bindings/binding_typescript_wasm/Cargo.toml index 81b00fc5d..922980b92 100644 --- a/deps/swc/bindings/binding_typescript_wasm/Cargo.toml +++ b/deps/swc/bindings/binding_typescript_wasm/Cargo.toml @@ -6,7 +6,7 @@ license = { workspace = true } name = "binding_typescript_wasm" publish = false repository = { workspace = true } -version = "1.15.41" +version = "1.15.43" [lib] bench = false diff --git a/deps/swc/bindings/swc_cli/Cargo.toml b/deps/swc/bindings/swc_cli/Cargo.toml index ca45fe572..0447ac4eb 100644 --- a/deps/swc/bindings/swc_cli/Cargo.toml +++ b/deps/swc/bindings/swc_cli/Cargo.toml @@ -6,7 +6,7 @@ include = ["Cargo.toml", "src/**/*.rs"] license = { workspace = true } name = "swc_cli" repository = { workspace = true } -version = "0.113.2" +version = "0.116.3" [[bin]] bench = false @@ -20,4 +20,4 @@ plugin = ["swc_cli_impl/plugin"] [dependencies] anyhow = { workspace = true } par-core = { workspace = true, features = ["chili"] } -swc_cli_impl = { version = "68.0.0", path = "../../crates/swc_cli_impl" } +swc_cli_impl = { version = "71.0.0", path = "../../crates/swc_cli_impl" } diff --git a/deps/swc/crates/binding_macros/Cargo.toml b/deps/swc/crates/binding_macros/Cargo.toml index 2e0418c08..bae521da1 100644 --- a/deps/swc/crates/binding_macros/Cargo.toml +++ b/deps/swc/crates/binding_macros/Cargo.toml @@ -5,7 +5,7 @@ edition = { workspace = true } license = { workspace = true } name = "binding_macros" repository = { workspace = true } -version = "66.0.0" +version = "69.0.0" [lib] bench = false @@ -33,10 +33,10 @@ binding_wasm = [ [dependencies] # Common deps for the SWC imports -swc = { optional = true, version = "66.0.1", path = "../swc", default-features = false } -swc_common = { optional = true, version = "23.0.1", path = "../swc_common", default-features = false } +swc = { optional = true, version = "69.0.0", path = "../swc", default-features = false } +swc_common = { optional = true, version = "23.0.2", path = "../swc_common", default-features = false } swc_ecma_ast = { optional = true, version = "25.0.0", path = "../swc_ecma_ast", default-features = false } -swc_ecma_transforms = { optional = true, version = "55.0.1", path = "../swc_ecma_transforms", default-features = false } +swc_ecma_transforms = { optional = true, version = "56.0.0", path = "../swc_ecma_transforms", default-features = false } swc_ecma_visit = { optional = true, version = "25.0.0", path = "../swc_ecma_visit", default-features = false } # Optional deps for the wasm binding macro diff --git a/deps/swc/crates/dbg-swc/Cargo.toml b/deps/swc/crates/dbg-swc/Cargo.toml index 700629390..98ed5e53e 100644 --- a/deps/swc/crates/dbg-swc/Cargo.toml +++ b/deps/swc/crates/dbg-swc/Cargo.toml @@ -5,7 +5,7 @@ edition = { workspace = true } license = { workspace = true } name = "dbg-swc" repository = { workspace = true } -version = "56.0.0" +version = "57.0.0" [[bin]] bench = false @@ -22,23 +22,22 @@ rayon = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } sha1 = { workspace = true } -swc_common = { version = "23.0.1", features = [ +swc_common = { version = "23.0.2", features = [ "concurrent", "tty-emitter", ], path = "../swc_common" } swc_ecma_ast = { version = "25.0.0", path = "../swc_ecma_ast" } -swc_ecma_codegen = { version = "28.0.1", path = "../swc_ecma_codegen" } -swc_ecma_minifier = { version = "55.0.1", path = "../swc_ecma_minifier", features = [ +swc_ecma_codegen = { version = "28.0.2", path = "../swc_ecma_codegen" } +swc_ecma_minifier = { version = "56.0.1", path = "../swc_ecma_minifier", features = [ "concurrent", ] } -swc_ecma_parser = { version = "41.0.1", path = "../swc_ecma_parser", features = [ +swc_ecma_parser = { version = "41.1.2", path = "../swc_ecma_parser", features = [ "flow", ] } -swc_ecma_transforms_base = { version = "44.0.2", path = "../swc_ecma_transforms_base" } -swc_ecma_transforms_typescript = { version = "49.0.0", path = "../swc_ecma_transforms_typescript" } +swc_ecma_transforms_base = { version = "44.0.3", path = "../swc_ecma_transforms_base" } +swc_ecma_transforms_typescript = { version = "50.0.0", path = "../swc_ecma_transforms_typescript" } swc_ecma_visit = { version = "25.0.0", path = "../swc_ecma_visit" } swc_error_reporters = { version = "25.0.0", path = "../swc_error_reporters" } -swc_timer = { version = "1.0.0", path = "../swc_timer" } tempfile = { workspace = true } tracing = { workspace = true } tracing-subscriber = { workspace = true, features = ["fmt", "env-filter"] } diff --git a/deps/swc/crates/dbg-swc/src/bundle.rs b/deps/swc/crates/dbg-swc/src/bundle.rs index 9edd65bf6..ba52ad84b 100644 --- a/deps/swc/crates/dbg-swc/src/bundle.rs +++ b/deps/swc/crates/dbg-swc/src/bundle.rs @@ -5,14 +5,11 @@ use std::{ use anyhow::{bail, Context, Result}; use swc_common::{FileName, SourceMap}; -use swc_timer::timer; use crate::util::{parse_js, wrap_task, ModuleRecord}; pub fn bundle(cm: Arc, entry_url: &str) -> Result { wrap_task(|| { - let _timer = timer!("bundle"); - let mut cmd = Command::new("deno"); cmd.arg("bundle"); cmd.arg(entry_url); diff --git a/deps/swc/crates/dbg-swc/src/es/minifier/ensure_size.rs b/deps/swc/crates/dbg-swc/src/es/minifier/ensure_size.rs index 65b4ed92d..a2a473567 100644 --- a/deps/swc/crates/dbg-swc/src/es/minifier/ensure_size.rs +++ b/deps/swc/crates/dbg-swc/src/es/minifier/ensure_size.rs @@ -38,6 +38,7 @@ impl EnsureSize { pub fn run(self, cm: Arc) -> Result<()> { let all_files = all_js_files(&self.path)?; + #[cfg(debug_assertions)] info!("Using {} files", all_files.len()); let mut results = GLOBALS.with(|globals| { @@ -148,6 +149,7 @@ impl EnsureSize { fn check_file(&self, cm: Arc, js_file: &Path) -> Result> { wrap_task(|| { + #[cfg(debug_assertions)] info!("Checking {}", js_file.display()); let fm = cm.load_file(js_file).context("failed to load file")?; diff --git a/deps/swc/crates/dbg-swc/src/es/minifier/next/check_size.rs b/deps/swc/crates/dbg-swc/src/es/minifier/next/check_size.rs index 78cb8dedb..f681f6f8a 100644 --- a/deps/swc/crates/dbg-swc/src/es/minifier/next/check_size.rs +++ b/deps/swc/crates/dbg-swc/src/es/minifier/next/check_size.rs @@ -45,6 +45,7 @@ impl CheckSizeCommand { let files = self.store_minifier_inputs(&app_dir)?; + #[cfg(debug_assertions)] info!("Running minifier"); let mut files = GLOBALS.with(|globals| { @@ -61,6 +62,7 @@ impl CheckSizeCommand { })?; if !self.show_all { + #[cfg(debug_assertions)] info!( "Skiping files which are smaller than terser output, as `--show-all` is not \ specified" @@ -148,6 +150,7 @@ impl CheckSizeCommand { .count() != 0 { + #[cfg(debug_assertions)] info!( "Skipping `npm run build` because the cache exists and `--ensure-fresh` is \ not set" @@ -177,6 +180,7 @@ impl CheckSizeCommand { /// Invokes `npm run build` and extacts the inputs for the swc minifier. fn build_app(&self, app_dir: &Path) -> Result> { wrap_task(|| { + #[cfg(debug_assertions)] info!("Running `npm run build`"); // Remove cache diff --git a/deps/swc/crates/dbg-swc/src/main.rs b/deps/swc/crates/dbg-swc/src/main.rs index 4cf34be06..1b1dd11bd 100644 --- a/deps/swc/crates/dbg-swc/src/main.rs +++ b/deps/swc/crates/dbg-swc/src/main.rs @@ -1,4 +1,6 @@ -use std::{env, path::PathBuf, str::FromStr, sync::Arc}; +#[cfg(debug_assertions)] +use std::str::FromStr; +use std::{env, path::PathBuf, sync::Arc}; use anyhow::{bail, Error, Result}; use clap::{StructOpt, Subcommand}; @@ -8,6 +10,7 @@ use swc_common::{ Globals, SourceMap, GLOBALS, }; use swc_error_reporters::handler::{try_with_handler, HandlerOpts}; +#[cfg(debug_assertions)] use tracing_subscriber::EnvFilter; use self::util::print_js; @@ -34,19 +37,21 @@ enum Cmd { } fn init() -> Result<()> { - let log_env = - env::var("RUST_LOG").unwrap_or_else(|_| "info,swc_ecma_minifier=warn,swc_timer=off".into()); - - let logger = tracing_subscriber::FmtSubscriber::builder() - .without_time() - .with_target(false) - .with_ansi(true) - .with_env_filter(EnvFilter::from_str(&log_env).unwrap()) - .with_writer(std::io::stderr) - .pretty() - .finish(); - - tracing::subscriber::set_global_default(logger)?; + #[cfg(debug_assertions)] + { + let log_env = env::var("RUST_LOG").unwrap_or_else(|_| "info,swc_ecma_minifier=warn".into()); + + let logger = tracing_subscriber::FmtSubscriber::builder() + .without_time() + .with_target(false) + .with_ansi(true) + .with_env_filter(EnvFilter::from_str(&log_env).unwrap()) + .with_writer(std::io::stderr) + .pretty() + .finish(); + + tracing::subscriber::set_global_default(logger)?; + } Ok(()) } diff --git a/deps/swc/crates/jsdoc/Cargo.toml b/deps/swc/crates/jsdoc/Cargo.toml index 7d6df7c96..6020feb31 100644 --- a/deps/swc/crates/jsdoc/Cargo.toml +++ b/deps/swc/crates/jsdoc/Cargo.toml @@ -31,9 +31,9 @@ nom = { workspace = true } serde = { workspace = true, features = ["derive"], optional = true } swc_atoms = { version = "9.0.3", path = "../swc_atoms" } -swc_common = { version = "23.0.1", path = "../swc_common" } +swc_common = { version = "23.0.2", path = "../swc_common" } [dev-dependencies] dashmap = { workspace = true } -swc_ecma_parser = { version = "41.0.1", path = "../swc_ecma_parser" } -testing = { version = "24.0.0", path = "../testing" } +swc_ecma_parser = { version = "41.1.2", path = "../swc_ecma_parser" } +testing = { version = "24.0.1", path = "../testing" } diff --git a/deps/swc/crates/preset_env_base/Cargo.toml b/deps/swc/crates/preset_env_base/Cargo.toml index 18ff4a367..9577fd8eb 100644 --- a/deps/swc/crates/preset_env_base/Cargo.toml +++ b/deps/swc/crates/preset_env_base/Cargo.toml @@ -6,7 +6,7 @@ edition = { workspace = true } license = { workspace = true } name = "preset_env_base" repository = { workspace = true } -version = "8.0.0" +version = "8.0.1" [lib] bench = false diff --git a/deps/swc/crates/preset_env_base/src/version.rs b/deps/swc/crates/preset_env_base/src/version.rs index 1521c94ea..f118c159a 100644 --- a/deps/swc/crates/preset_env_base/src/version.rs +++ b/deps/swc/crates/preset_env_base/src/version.rs @@ -3,6 +3,7 @@ use std::{cmp, cmp::Ordering, fmt, str::FromStr}; use serde::{de, de::Visitor, Deserialize, Deserializer, Serialize}; +#[cfg(debug_assertions)] use tracing::warn; use crate::Versions; @@ -28,7 +29,10 @@ impl FromStr for Version { if !v.contains('.') { return Ok(Version { major: v.parse().map_err(|err| { + #[cfg(debug_assertions)] warn!("failed to parse `{}` as a version: {}", v, err); + #[cfg(not(debug_assertions))] + let _ = err; })?, minor: 0, patch: 0, @@ -45,7 +49,10 @@ impl FromStr for Version { } let v = v.parse::().map_err(|err| { + #[cfg(debug_assertions)] warn!("failed to parse `{}` as a version: {}", v, err); + #[cfg(not(debug_assertions))] + let _ = err; })?; Ok(Version { diff --git a/deps/swc/crates/swc-ast-explorer/Cargo.toml b/deps/swc/crates/swc-ast-explorer/Cargo.toml index eddd8e489..35ca42b8c 100644 --- a/deps/swc/crates/swc-ast-explorer/Cargo.toml +++ b/deps/swc/crates/swc-ast-explorer/Cargo.toml @@ -18,9 +18,9 @@ anyhow = { workspace = true } clap = { version = "3", features = ["derive"] } owo-colors = { workspace = true } regex = { workspace = true } -swc_common = { version = "23.0.1", path = "../swc_common" } +swc_common = { version = "23.0.2", path = "../swc_common" } swc_ecma_ast = { version = "25.0.0", path = "../swc_ecma_ast" } -swc_ecma_parser = { version = "41.0.1", path = "../swc_ecma_parser" } +swc_ecma_parser = { version = "41.1.2", path = "../swc_ecma_parser" } swc_error_reporters = { version = "25.0.0", path = "../swc_error_reporters" } [dev-dependencies] diff --git a/deps/swc/crates/swc/Cargo.toml b/deps/swc/crates/swc/Cargo.toml index 4b2f23523..d3517a76a 100644 --- a/deps/swc/crates/swc/Cargo.toml +++ b/deps/swc/crates/swc/Cargo.toml @@ -9,7 +9,7 @@ include = ["Cargo.toml", "src/**/*.rs"] license = { workspace = true } name = "swc" repository = { workspace = true } -version = "66.0.1" +version = "69.0.0" [lib] bench = false @@ -24,15 +24,19 @@ concurrent = [ "swc_ecma_minifier/concurrent", ] -debug = ["swc_ecma_visit/debug", "swc_ecma_minifier/debug"] -default = ["lint", "isolated-dts", "module"] -es3 = ["swc_ecma_transforms_compat/es3", "swc_ecma_preset_env/es3"] -flow = ["swc_ecma_parser/flow"] +debug = ["swc_ecma_visit/debug", "swc_ecma_minifier/debug"] +default = ["lint", "isolated-dts", "module"] +es3 = ["swc_ecma_transforms_compat/es3", "swc_ecma_preset_env/es3"] +flow = ["swc_ecma_parser/flow"] isolated-dts = ["swc_typescript"] # Enable module transforms (CommonJS, AMD, UMD, SystemJS). # Bundlers typically don't need this as they handle module transforms themselves. module = ["swc_ecma_transforms/module", "swc_ecma_transforms_module"] node = ["napi", "napi-derive", "swc_compiler_base/node"] + +# Enable React Compiler APIs. +react-compiler = ["dep:swc_ecma_react_compiler"] + plugin = [ "swc_plugin_runner/ecma", "swc_plugin_runner/encoding-impl", @@ -84,47 +88,49 @@ url = { workspace = true } swc_atoms = { version = "9.0.3", path = "../swc_atoms" } -swc_common = { version = "23.0.1", path = "../swc_common", features = [ +swc_common = { version = "23.0.2", path = "../swc_common", features = [ "sourcemap", "parking_lot", ] } -swc_compiler_base = { version = "58.0.0", path = "../swc_compiler_base" } +swc_compiler_base = { version = "59.0.0", path = "../swc_compiler_base" } swc_config = { version = "5.0.0", path = "../swc_config" } swc_ecma_ast = { version = "25.0.0", path = "../swc_ecma_ast" } -swc_ecma_codegen = { version = "28.0.1", path = "../swc_ecma_codegen" } +swc_ecma_codegen = { version = "28.0.2", path = "../swc_ecma_codegen" } swc_ecma_ext_transforms = { version = "31.0.0", path = "../swc_ecma_ext_transforms" } swc_ecma_lints = { version = "33.0.0", path = "../swc_ecma_lints", optional = true } -swc_ecma_loader = { version = "24.0.0", path = "../swc_ecma_loader", features = [ +swc_ecma_loader = { version = "24.0.1", path = "../swc_ecma_loader", features = [ "cache", "node", "tsc", ] } -swc_ecma_minifier = { version = "55.0.1", path = "../swc_ecma_minifier" } -swc_ecma_parser = { version = "41.0.1", path = "../swc_ecma_parser", default-features = false, features = [ +swc_ecma_minifier = { version = "56.0.1", path = "../swc_ecma_minifier" } +swc_ecma_parser = { version = "41.1.2", path = "../swc_ecma_parser", default-features = false, features = [ "typescript", ] } -swc_ecma_preset_env = { version = "56.0.0", path = "../swc_ecma_preset_env", default-features = false, features = ["serde-impl"] } -swc_ecma_transforms = { version = "55.0.1", path = "../swc_ecma_transforms", features = [ +swc_ecma_preset_env = { version = "57.0.0", path = "../swc_ecma_preset_env", default-features = false, features = [ + "serde-impl", +] } +swc_ecma_react_compiler = { version = "20.0.2", path = "../swc_ecma_react_compiler", optional = true } +swc_ecma_transforms = { version = "56.0.0", path = "../swc_ecma_transforms", features = [ "compat", "optimization", "proposal", "react", "typescript", ] } -swc_ecma_transforms_module = { version = "49.0.0", path = "../swc_ecma_transforms_module", optional = true } -swc_ecma_transforms_base = { version = "44.0.2", path = "../swc_ecma_transforms_base" } -swc_ecma_transforms_compat = { version = "51.0.1", path = "../swc_ecma_transforms_compat", default-features = false } -swc_ecma_transforms_optimization = { version = "47.0.0", path = "../swc_ecma_transforms_optimization" } -swc_ecma_utils = { version = "31.0.0", path = "../swc_ecma_utils" } +swc_ecma_transforms_base = { version = "44.0.3", path = "../swc_ecma_transforms_base" } +swc_ecma_transforms_compat = { version = "52.0.1", path = "../swc_ecma_transforms_compat", default-features = false } +swc_ecma_transforms_module = { version = "49.0.1", path = "../swc_ecma_transforms_module", optional = true } +swc_ecma_transforms_optimization = { version = "47.0.1", path = "../swc_ecma_transforms_optimization" } +swc_ecma_utils = { version = "31.0.1", path = "../swc_ecma_utils" } swc_ecma_visit = { version = "25.0.0", path = "../swc_ecma_visit" } swc_error_reporters = { version = "25.0.0", path = "../swc_error_reporters" } swc_node_comments = { version = "24.0.0", path = "../swc_node_comments" } -swc_plugin_backend_wasmer = { version = "12.0.0", path = "../swc_plugin_backend_wasmer", optional = true, default-features = false } -swc_plugin_proxy = { version = "25.0.0", path = "../swc_plugin_proxy", optional = true } -swc_plugin_runner = { version = "29.0.0", path = "../swc_plugin_runner", optional = true, default-features = false } -swc_timer = { version = "1.0.0", path = "../swc_timer" } +swc_plugin_backend_wasmer = { version = "13.0.0", path = "../swc_plugin_backend_wasmer", optional = true, default-features = false } +swc_plugin_proxy = { version = "26.0.0", path = "../swc_plugin_proxy", optional = true } +swc_plugin_runner = { version = "30.0.0", path = "../swc_plugin_runner", optional = true, default-features = false } swc_transform_common = { version = "17.0.0", path = "../swc_transform_common" } -swc_typescript = { version = "30.0.0", path = "../swc_typescript", optional = true } +swc_typescript = { version = "30.0.1", path = "../swc_typescript", optional = true } swc_visit = { version = "2.0.1", path = "../swc_visit" } [dependencies.tokio] @@ -156,18 +162,18 @@ swc_ecma_ast = { version = "25.0.0", path = "../swc_ecma_ast", features = [ swc_ecma_lints = { version = "33.0.0", path = "../swc_ecma_lints", features = [ "non_critical_lints", ] } -swc_ecma_preset_env = { version = "56.0.0", path = "../swc_ecma_preset_env", features = [ +swc_ecma_preset_env = { version = "57.0.0", path = "../swc_ecma_preset_env", features = [ "es3", ] } -swc_ecma_testing = { version = "24.0.0", path = "../swc_ecma_testing" } -swc_ecma_transforms_base = { version = "44.0.2", path = "../swc_ecma_transforms_base", features = [ +swc_ecma_testing = { version = "24.0.1", path = "../swc_ecma_testing" } +swc_ecma_transforms_base = { version = "44.0.3", path = "../swc_ecma_transforms_base", features = [ "inline-helpers", ] } -swc_ecma_transforms_compat = { version = "51.0.1", path = "../swc_ecma_transforms_compat", features = [ +swc_ecma_transforms_compat = { version = "52.0.1", path = "../swc_ecma_transforms_compat", features = [ "es3", ] } swc_malloc = { version = "1.2.5", path = "../swc_malloc" } -testing = { version = "24.0.0", path = "../testing" } +testing = { version = "24.0.1", path = "../testing" } [[example]] name = "transform" diff --git a/deps/swc/crates/swc/examples/node_counter.rs b/deps/swc/crates/swc/examples/node_counter.rs new file mode 100644 index 000000000..4210b2709 --- /dev/null +++ b/deps/swc/crates/swc/examples/node_counter.rs @@ -0,0 +1,405 @@ +//! Count every generated ECMAScript AST node kind with a read-only pass. +//! +//! Usage: +//! +//! ```bash +//! cargo run -p swc --example node_counter -- path/to/input.tsx +//! ``` + +use std::{ + env, + ffi::OsStr, + path::{Path, PathBuf}, + process, +}; + +use swc_common::{sync::Lrc, SourceMap, GLOBALS}; +use swc_ecma_ast::{Pass, Program}; +use swc_ecma_parser::{parse_file_as_program, EsSyntax, Syntax, TsSyntax}; +use swc_ecma_visit::NodeRef; + +// Keep this list in sync with generated `swc_ecma_visit::NodeRef`. The +// `node_kind` match below is intentionally exhaustive, so adding or removing an +// AST node kind in `NodeRef` makes this example fail to compile until the list +// is updated. +macro_rules! node_ref_variants { + ($macro:ident) => { + $macro! { + Accessibility, + ArrayLit, + ArrayPat, + ArrowExpr, + AssignExpr, + AssignOp, + AssignPat, + AssignPatProp, + AssignProp, + AssignTarget, + AssignTargetPat, + AutoAccessor, + AwaitExpr, + BigInt, + BinExpr, + BinaryOp, + BindingIdent, + BlockStmt, + BlockStmtOrExpr, + Bool, + BreakStmt, + CallExpr, + Callee, + CatchClause, + Class, + ClassDecl, + ClassExpr, + ClassMember, + ClassMethod, + ClassProp, + ComputedPropName, + CondExpr, + Constructor, + ContinueStmt, + DebuggerStmt, + Decl, + Decorator, + DefaultDecl, + DoWhileStmt, + EmptyStmt, + ExportAll, + ExportDecl, + ExportDefaultDecl, + ExportDefaultExpr, + ExportDefaultSpecifier, + ExportNamedSpecifier, + ExportNamespaceSpecifier, + ExportSpecifier, + Expr, + ExprOrSpread, + ExprStmt, + FnDecl, + FnExpr, + ForHead, + ForInStmt, + ForOfStmt, + ForStmt, + Function, + GetterProp, + Ident, + IdentName, + IfStmt, + Import, + ImportDecl, + ImportDefaultSpecifier, + ImportNamedSpecifier, + ImportPhase, + ImportSpecifier, + ImportStarAsSpecifier, + ImportWith, + ImportWithItem, + Invalid, + JSXAttr, + JSXAttrName, + JSXAttrOrSpread, + JSXAttrValue, + JSXClosingElement, + JSXClosingFragment, + JSXElement, + JSXElementChild, + JSXElementName, + JSXEmptyExpr, + JSXExpr, + JSXExprContainer, + JSXFragment, + JSXMemberExpr, + JSXNamespacedName, + JSXObject, + JSXOpeningElement, + JSXOpeningFragment, + JSXSpreadChild, + JSXText, + Key, + KeyValuePatProp, + KeyValueProp, + LabeledStmt, + Lit, + MemberExpr, + MemberProp, + MetaPropExpr, + MetaPropKind, + MethodKind, + MethodProp, + Module, + ModuleDecl, + ModuleExportName, + ModuleItem, + NamedExport, + NewExpr, + Null, + Number, + ObjectLit, + ObjectPat, + ObjectPatProp, + OptCall, + OptChainBase, + OptChainExpr, + Param, + ParamOrTsParamProp, + ParenExpr, + Pat, + PrivateMethod, + PrivateName, + PrivateProp, + Program, + Prop, + PropName, + PropOrSpread, + Regex, + RestPat, + ReturnStmt, + Script, + SeqExpr, + SetterProp, + SimpleAssignTarget, + SpreadElement, + StaticBlock, + Stmt, + Str, + Super, + SuperProp, + SuperPropExpr, + SwitchCase, + SwitchStmt, + TaggedTpl, + ThisExpr, + ThrowStmt, + Tpl, + TplElement, + TruePlusMinus, + TryStmt, + TsArrayType, + TsAsExpr, + TsCallSignatureDecl, + TsConditionalType, + TsConstAssertion, + TsConstructSignatureDecl, + TsConstructorType, + TsEntityName, + TsEnumDecl, + TsEnumMember, + TsEnumMemberId, + TsExportAssignment, + TsExprWithTypeArgs, + TsExternalModuleRef, + TsFnOrConstructorType, + TsFnParam, + TsFnType, + TsGetterSignature, + TsImportCallOptions, + TsImportEqualsDecl, + TsImportType, + TsIndexSignature, + TsIndexedAccessType, + TsInferType, + TsInstantiation, + TsInterfaceBody, + TsInterfaceDecl, + TsIntersectionType, + TsKeywordType, + TsKeywordTypeKind, + TsLit, + TsLitType, + TsMappedType, + TsMethodSignature, + TsModuleBlock, + TsModuleDecl, + TsModuleName, + TsModuleRef, + TsNamespaceBody, + TsNamespaceDecl, + TsNamespaceExportDecl, + TsNonNullExpr, + TsOptionalType, + TsParamProp, + TsParamPropParam, + TsParenthesizedType, + TsPropertySignature, + TsQualifiedName, + TsRestType, + TsSatisfiesExpr, + TsSetterSignature, + TsThisType, + TsThisTypeOrIdent, + TsTplLitType, + TsTupleElement, + TsTupleType, + TsType, + TsTypeAliasDecl, + TsTypeAnn, + TsTypeAssertion, + TsTypeElement, + TsTypeLit, + TsTypeOperator, + TsTypeOperatorOp, + TsTypeParam, + TsTypeParamDecl, + TsTypeParamInstantiation, + TsTypePredicate, + TsTypeQuery, + TsTypeQueryExpr, + TsTypeRef, + TsUnionOrIntersectionType, + TsUnionType, + UnaryExpr, + UnaryOp, + UpdateExpr, + UpdateOp, + UsingDecl, + VarDecl, + VarDeclKind, + VarDeclOrExpr, + VarDeclarator, + WhileStmt, + WithStmt, + YieldExpr, + } + }; +} + +macro_rules! node_names { + ($($name:ident),+ $(,)?) => { + &[$(stringify!($name)),+] + }; +} + +const NODE_NAMES: &[&str] = node_ref_variants!(node_names); + +macro_rules! define_node_kind { + ($($name:ident),+ $(,)?) => { + fn node_kind(node: NodeRef<'_>) -> &'static str { + match node { + $(NodeRef::$name(_) => stringify!($name),)+ + } + } + }; +} + +node_ref_variants!(define_node_kind); + +struct NodeCounter { + counts: rustc_hash::FxHashMap<&'static str, usize>, +} + +impl Default for NodeCounter { + fn default() -> Self { + Self { + counts: NODE_NAMES.iter().map(|name| (*name, 0)).collect(), + } + } +} + +impl NodeCounter { + fn count(&mut self, name: &'static str) { + *self.counts.get_mut(name).expect("node kind is registered") += 1; + } + + fn print(&self) { + let width = NODE_NAMES + .iter() + .map(|name| name.len()) + .max() + .unwrap_or_default(); + + println!("AST node counts:"); + + for name in NODE_NAMES { + let count = self.counts.get(name).copied().unwrap_or_default(); + println!(" {name: Syntax { + let ext = path + .extension() + .and_then(OsStr::to_str) + .map(str::to_ascii_lowercase); + + let is_ts = ext + .as_deref() + .is_some_and(|ext| matches!(ext, "ts" | "tsx" | "mts" | "cts" | "mtsx" | "ctsx")); + let is_jsx = ext + .as_deref() + .is_some_and(|ext| matches!(ext, "jsx" | "tsx" | "mjsx" | "cjsx" | "mtsx" | "ctsx")); + let is_dts = is_ts + && path + .file_name() + .and_then(OsStr::to_str) + .is_some_and(|file_name| file_name.ends_with(".d.ts")); + + if is_ts { + Syntax::Typescript(TsSyntax { + tsx: is_jsx, + decorators: true, + dts: is_dts, + ..Default::default() + }) + } else { + Syntax::Es(EsSyntax { + jsx: is_jsx, + decorators: true, + import_attributes: true, + export_default_from: true, + auto_accessors: true, + explicit_resource_management: true, + ..Default::default() + }) + } +} + +fn input_path() -> PathBuf { + match env::args_os().nth(1) { + Some(path) => path.into(), + None => { + eprintln!("Usage: cargo run -p swc --example node_counter -- "); + process::exit(1); + } + } +} + +fn main() { + let file_path = input_path(); + let cm: Lrc = Default::default(); + let source_file = cm.load_file(&file_path).unwrap_or_else(|err| { + eprintln!("Failed to load '{}': {err}", file_path.display()); + process::exit(1); + }); + let syntax = syntax_for_path(&file_path); + + GLOBALS.set(&Default::default(), || { + let mut errors = Vec::new(); + let mut program = + parse_file_as_program(&source_file, syntax, Default::default(), None, &mut errors) + .unwrap_or_else(|err| { + eprintln!("Failed to parse '{}': {err:?}", file_path.display()); + process::exit(1); + }); + + if !errors.is_empty() { + eprintln!("Parsed with {} recoverable error(s).", errors.len()); + } + + let mut counter = NodeCounter::default(); + counter.process(&mut program); + counter.print(); + }); +} diff --git a/deps/swc/crates/swc/src/config/mod.rs b/deps/swc/crates/swc/src/config/mod.rs index c962894d8..7ad7a71ac 100644 --- a/deps/swc/crates/swc/src/config/mod.rs +++ b/deps/swc/crates/swc/src/config/mod.rs @@ -26,6 +26,8 @@ use swc_common::{ errors::Handler, FileName, Mark, SourceMap, }; +#[cfg(feature = "react-compiler")] +use swc_common::{BytePos, Span, Spanned}; pub use swc_compiler_base::SourceMapsConfig; pub use swc_config::is_module::IsModule; use swc_config::{ @@ -338,6 +340,48 @@ impl Options { let mut transform = transform.into_inner().unwrap_or_default(); + #[cfg(feature = "react-compiler")] + if let Some(options) = react_compiler_options(transform.react_compiler.clone(), base) { + let fm = if program.span().is_dummy() { + cm.get_source_file(base) + } else { + cm.try_lookup_byte_offset(program.span().lo) + .ok() + .map(|source| source.sf) + }; + + if let Some(fm) = fm { + let source_type = swc_ecma_react_compiler::SourceType::from_program(&program) + .with_typescript(syntax.typescript()); + let result = swc_ecma_react_compiler::transform( + &program, + source_type, + &fm.src, + comments, + options, + ); + emit_react_compiler_diagnostics(handler, &result.diagnostics); + + if let Some(compiled) = result.program { + program = compiled; + } + } else { + handler + .struct_warn("React Compiler is enabled, but the source text is unavailable") + .emit(); + } + } + + #[cfg(not(feature = "react-compiler"))] + if transform.react_compiler.is_true() || transform.react_compiler.is_obj() { + handler + .struct_warn( + "React Compiler is configured, but swc was built without the `react-compiler` \ + feature", + ) + .emit(); + } + // Do a resolver pass before everything. // // We do this before creating custom passes, so custom passses can use the @@ -1726,6 +1770,9 @@ pub struct TransformConfig { #[serde(default)] pub react: react::Options, + #[serde(default)] + pub react_compiler: BoolOrDataConfig, + #[serde(default)] pub const_modules: Option, @@ -1763,6 +1810,272 @@ pub struct TransformConfig { pub ts_enum_is_mutable: BoolConfig, } +/// Public `.swcrc` configuration for React Compiler. +/// +/// This intentionally mirrors only a curated subset of upstream +/// `PluginOptions`; the deep `environment` configuration is kept internal for +/// the first SWC integration. +#[derive(Debug, Default, Clone, Serialize, Deserialize, Merge)] +#[serde(deny_unknown_fields, rename_all = "camelCase")] +pub struct ReactCompilerConfig { + #[serde(default)] + pub compilation_mode: Option, + + #[serde(default)] + pub panic_threshold: Option, + + #[serde(default)] + pub target: Option, + + #[serde(default)] + pub no_emit: Option, + + #[serde(default)] + pub output_mode: Option, + + #[serde(default)] + pub ignore_use_no_forget: Option, + + #[serde(default)] + pub flow_suppressions: Option, + + #[serde(default)] + pub enable_reanimated: Option, + + #[serde(default)] + pub is_dev: Option, + + #[serde(default)] + pub eslint_suppression_rules: Option>, + + #[serde(default)] + pub custom_opt_out_directives: Option>, + + #[serde(default)] + pub gating: Option, + + #[serde(default)] + pub dynamic_gating: Option, +} + +#[cfg(feature = "react-compiler")] +impl ReactCompilerConfig { + fn into_plugin_options( + self, + filename: Option, + ) -> swc_ecma_react_compiler::PluginOptions { + let mut options = swc_ecma_react_compiler::default_plugin_options(); + options.filename = filename; + + if let Some(compilation_mode) = self.compilation_mode { + options.compilation_mode = compilation_mode.as_str().into(); + } + if let Some(panic_threshold) = self.panic_threshold { + options.panic_threshold = panic_threshold.as_str().into(); + } + if let Some(target) = self.target { + options.target = + swc_ecma_react_compiler::CompilerTarget::Version(target.as_str().into()); + } + if let Some(no_emit) = self.no_emit { + options.no_emit = no_emit; + } + if let Some(output_mode) = self.output_mode { + options.output_mode = Some(output_mode.as_str().into()); + } + if let Some(ignore_use_no_forget) = self.ignore_use_no_forget { + options.ignore_use_no_forget = ignore_use_no_forget; + } + if let Some(flow_suppressions) = self.flow_suppressions { + options.flow_suppressions = flow_suppressions; + } + if let Some(enable_reanimated) = self.enable_reanimated { + options.enable_reanimated = enable_reanimated; + } + if let Some(is_dev) = self.is_dev { + options.is_dev = is_dev; + } + if self.eslint_suppression_rules.is_some() { + options.eslint_suppression_rules = self.eslint_suppression_rules; + } + if self.custom_opt_out_directives.is_some() { + options.custom_opt_out_directives = self.custom_opt_out_directives; + } + if let Some(gating) = self.gating { + options.gating = Some(gating.into()); + } + if let Some(dynamic_gating) = self.dynamic_gating { + options.dynamic_gating = Some(dynamic_gating.into()); + } + + options + } +} + +#[derive(Debug, Clone, Copy, Serialize, Deserialize)] +pub enum ReactCompilerCompilationMode { + #[serde(rename = "infer")] + Infer, + #[serde(rename = "syntax")] + Syntax, + #[serde(rename = "annotation")] + Annotation, + #[serde(rename = "all")] + All, +} + +#[cfg(feature = "react-compiler")] +impl ReactCompilerCompilationMode { + fn as_str(self) -> &'static str { + match self { + Self::Infer => "infer", + Self::Syntax => "syntax", + Self::Annotation => "annotation", + Self::All => "all", + } + } +} + +#[derive(Debug, Clone, Copy, Serialize, Deserialize)] +pub enum ReactCompilerPanicThreshold { + #[serde(rename = "none")] + None, + #[serde(rename = "critical_errors")] + CriticalErrors, + #[serde(rename = "all_errors")] + AllErrors, +} + +#[cfg(feature = "react-compiler")] +impl ReactCompilerPanicThreshold { + fn as_str(self) -> &'static str { + match self { + Self::None => "none", + Self::CriticalErrors => "critical_errors", + Self::AllErrors => "all_errors", + } + } +} + +#[derive(Debug, Clone, Copy, Serialize, Deserialize)] +pub enum ReactCompilerTarget { + #[serde(rename = "17")] + React17, + #[serde(rename = "18")] + React18, + #[serde(rename = "19")] + React19, +} + +#[cfg(feature = "react-compiler")] +impl ReactCompilerTarget { + fn as_str(self) -> &'static str { + match self { + Self::React17 => "17", + Self::React18 => "18", + Self::React19 => "19", + } + } +} + +#[derive(Debug, Clone, Copy, Serialize, Deserialize)] +pub enum ReactCompilerOutputMode { + #[serde(rename = "client")] + Client, + #[serde(rename = "ssr")] + Ssr, + #[serde(rename = "lint")] + Lint, +} + +#[cfg(feature = "react-compiler")] +impl ReactCompilerOutputMode { + fn as_str(self) -> &'static str { + match self { + Self::Client => "client", + Self::Ssr => "ssr", + Self::Lint => "lint", + } + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(deny_unknown_fields, rename_all = "camelCase")] +pub struct ReactCompilerGatingConfig { + pub source: String, + pub import_specifier_name: String, +} + +#[cfg(feature = "react-compiler")] +impl From for swc_ecma_react_compiler::GatingConfig { + fn from(config: ReactCompilerGatingConfig) -> Self { + Self { + source: config.source, + import_specifier_name: config.import_specifier_name, + } + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(deny_unknown_fields, rename_all = "camelCase")] +pub struct ReactCompilerDynamicGatingConfig { + pub source: String, +} + +#[cfg(feature = "react-compiler")] +impl From for swc_ecma_react_compiler::DynamicGatingConfig { + fn from(config: ReactCompilerDynamicGatingConfig) -> Self { + Self { + source: config.source, + } + } +} + +#[cfg(feature = "react-compiler")] +fn react_compiler_options( + config: BoolOrDataConfig, + base: &FileName, +) -> Option { + let filename = Some(base.to_string()); + + match config.into_inner()? { + BoolOr::Bool(true) => { + let mut options = swc_ecma_react_compiler::default_plugin_options(); + options.filename = filename; + Some(options) + } + BoolOr::Data(config) => Some(config.into_plugin_options(filename)), + BoolOr::Bool(false) => None, + } +} + +#[cfg(feature = "react-compiler")] +fn emit_react_compiler_diagnostics( + handler: &Handler, + diagnostics: &[swc_ecma_react_compiler::diagnostics::DiagnosticMessage], +) { + for diagnostic in diagnostics { + let span = diagnostic + .span + .map(|(lo, hi)| Span::new(BytePos(lo), BytePos(hi))); + + match (&diagnostic.severity, span) { + (swc_ecma_react_compiler::diagnostics::Severity::Error, Some(span)) => { + handler.struct_span_err(span, &diagnostic.message).emit() + } + (swc_ecma_react_compiler::diagnostics::Severity::Error, None) => { + handler.struct_err(&diagnostic.message).emit() + } + (swc_ecma_react_compiler::diagnostics::Severity::Warning, Some(span)) => { + handler.struct_span_warn(span, &diagnostic.message).emit() + } + (swc_ecma_react_compiler::diagnostics::Severity::Warning, None) => { + handler.struct_warn(&diagnostic.message).emit() + } + } + } +} + #[derive(Debug, Default, Clone, Serialize, Deserialize, Merge)] #[serde(deny_unknown_fields, rename_all = "camelCase")] pub struct HiddenTransformConfig { diff --git a/deps/swc/crates/swc/src/lib.rs b/deps/swc/crates/swc/src/lib.rs index 8b5c9c0e4..90f1c3ff6 100644 --- a/deps/swc/crates/swc/src/lib.rs +++ b/deps/swc/crates/swc/src/lib.rs @@ -111,6 +111,10 @@ pub extern crate swc_atoms as atoms; extern crate swc_common as common; +/// React Compiler APIs. +#[cfg(feature = "react-compiler")] +#[cfg_attr(docsrs, doc(cfg(feature = "react-compiler")))] +pub extern crate swc_ecma_react_compiler as react_compiler; use std::{ fs::{read_to_string, File}, @@ -159,9 +163,9 @@ use swc_ecma_visit::{FoldWith, VisitMutWith, VisitWith}; pub use swc_error_reporters::handler::{try_with_handler, HandlerOpts}; pub use swc_node_comments::SwcComments; pub use swc_sourcemap as sourcemap; -use swc_timer::timer; #[cfg(feature = "isolated-dts")] use swc_typescript::fast_dts::FastDts; +#[cfg(debug_assertions)] use tracing::warn; use url::Url; @@ -525,6 +529,7 @@ impl Compiler { .as_ref() .is_err_and(|err| err.kind() == ErrorKind::NotFound) { + #[cfg(debug_assertions)] warn!( "source map is specified by sourceMappingURL but \ there's no source map at `{}`", @@ -577,7 +582,10 @@ impl Compiler { match result { Ok(r) => r, Err(err) => { + #[cfg(debug_assertions)] tracing::error!("failed to read input source map: {:?}", err); + #[cfg(not(debug_assertions))] + let _ = err; None } } @@ -707,7 +715,7 @@ impl Compiler { } } - #[tracing::instrument(skip_all)] + #[cfg_attr(debug_assertions, tracing::instrument(skip_all))] pub fn read_config(&self, opts: &Options, name: &FileName) -> Result, Error> { static CUR_DIR: Lazy = Lazy::new(|| { if cfg!(target_arch = "wasm32") { @@ -836,7 +844,7 @@ impl Compiler { /// This method handles merging of config. /// /// This method does **not** parse module. - #[tracing::instrument(skip_all)] + #[cfg_attr(debug_assertions, tracing::instrument(skip_all))] pub fn parse_js_as_input<'a, P>( &'a self, fm: Lrc, @@ -851,8 +859,6 @@ impl Compiler { P: 'a + Pass, { self.run(move || { - let _timer = timer!("Compiler.parse"); - if let FileName::Real(ref path) = name { if !opts.config.matches(path)? { return Ok(None); @@ -901,7 +907,7 @@ impl Compiler { }) } - #[tracing::instrument(skip_all)] + #[cfg_attr(debug_assertions, tracing::instrument(skip_all))] pub fn transform( &self, handler: &Handler, @@ -929,7 +935,7 @@ impl Compiler { /// /// This means, you can use `noop_visit_type`, `noop_fold_type` and /// `noop_visit_mut_type` in your visitor to reduce the binary size. - #[tracing::instrument(skip_all)] + #[cfg_attr(debug_assertions, tracing::instrument(skip_all))] pub fn process_js_with_custom_pass( &self, fm: Arc, @@ -986,7 +992,7 @@ impl Compiler { }) } - #[tracing::instrument(skip(self, handler, opts))] + #[cfg_attr(debug_assertions, tracing::instrument(skip(self, handler, opts)))] pub fn process_js_file( &self, fm: Arc, @@ -1004,7 +1010,7 @@ impl Compiler { ) } - #[tracing::instrument(skip_all)] + #[cfg_attr(debug_assertions, tracing::instrument(skip_all))] pub fn minify( &self, fm: Arc, @@ -1013,8 +1019,6 @@ impl Compiler { extras: JsMinifyExtras, ) -> Result { self.run(|| { - let _timer = timer!("Compiler::minify"); - let target = opts.ecma.clone().into(); let (source_map, orig, source_map_url) = opts @@ -1205,7 +1209,7 @@ impl Compiler { /// You can use custom pass with this method. /// /// Pass building logic has been inlined into the configuration system. - #[tracing::instrument(skip_all)] + #[cfg_attr(debug_assertions, tracing::instrument(skip_all))] pub fn process_js( &self, handler: &Handler, @@ -1226,7 +1230,10 @@ impl Compiler { ) } - #[tracing::instrument(name = "swc::Compiler::apply_transforms", skip_all)] + #[cfg_attr( + debug_assertions, + tracing::instrument(name = "swc::Compiler::apply_transforms", skip_all) + )] fn apply_transforms( &self, handler: &Handler, @@ -1401,7 +1408,7 @@ fn find_swcrc(path: &Path, root: &Path, root_mode: RootMode) -> Option None } -#[tracing::instrument(skip_all)] +#[cfg_attr(debug_assertions, tracing::instrument(skip_all))] fn load_swcrc(path: &Path) -> Result { let content = read_to_string(path).context("failed to read config (.swcrc) file")?; diff --git a/deps/swc/crates/swc/src/plugin.rs b/deps/swc/crates/swc/src/plugin.rs index 157b4a949..a3bed74eb 100644 --- a/deps/swc/crates/swc/src/plugin.rs +++ b/deps/swc/crates/swc/src/plugin.rs @@ -109,7 +109,10 @@ impl RustPlugins { ret } - #[tracing::instrument(level = "info", skip_all, name = "apply_plugins")] + #[cfg_attr( + debug_assertions, + tracing::instrument(level = "info", skip_all, name = "apply_plugins") + )] #[cfg(all(feature = "plugin", not(target_arch = "wasm32")))] fn apply_inner(&mut self, n: Program) -> Result { use anyhow::Context; @@ -124,9 +127,11 @@ impl RustPlugins { inner: self.comments.clone(), }, || { + #[cfg(debug_assertions)] let span = tracing::span!(tracing::Level::INFO, "serialize_program").entered(); let program = swc_common::plugin::serialized::VersionedSerializable::new(n); let mut serialized = PluginSerializedBytes::try_serialize(&program)?; + #[cfg(debug_assertions)] drop(span); // Run plugin transformation against current program. @@ -158,6 +163,7 @@ impl RustPlugins { self.plugin_runtime.clone(), ); + #[cfg(debug_assertions)] let span = tracing::span!( tracing::Level::INFO, "execute_plugin_runner", @@ -173,6 +179,7 @@ impl RustPlugins { &p.0, plugin_name ) })?; + #[cfg(debug_assertions)] drop(span); } } @@ -185,7 +192,7 @@ impl RustPlugins { } #[cfg(all(feature = "plugin", target_arch = "wasm32"))] - #[tracing::instrument(level = "info", skip_all)] + #[cfg_attr(debug_assertions, tracing::instrument(level = "info", skip_all))] fn apply_inner(&mut self, n: Program) -> Result { // [TODO]: unimplemented n @@ -260,6 +267,7 @@ pub(crate) fn compile_wasm_plugins( }; inner_cache.store_bytes_from_path(plugin_runtime, &path, plugin_name)?; + #[cfg(debug_assertions)] tracing::debug!("Initialized WASM plugin {plugin_name}"); } } diff --git a/deps/swc/crates/swc/src/wasm_analysis.rs b/deps/swc/crates/swc/src/wasm_analysis.rs index b5f7a8aa5..f5c7b40e2 100644 --- a/deps/swc/crates/swc/src/wasm_analysis.rs +++ b/deps/swc/crates/swc/src/wasm_analysis.rs @@ -82,6 +82,7 @@ impl Compiler { )); let serialized = { + #[cfg(debug_assertions)] let _span = tracing::span!(tracing::Level::INFO, "serialize_program").entered(); let program = swc_common::plugin::serialized::VersionedSerializable::new(program); @@ -153,6 +154,7 @@ impl Compiler { plugin_runtime, ); + #[cfg(debug_assertions)] let span = tracing::span!( tracing::Level::INFO, "execute_plugin_runner", @@ -171,6 +173,7 @@ impl Compiler { }) }); result?; + #[cfg(debug_assertions)] drop(span); Ok(output) diff --git a/deps/swc/crates/swc_bundler/Cargo.toml b/deps/swc/crates/swc_bundler/Cargo.toml index f5376974c..41be17431 100644 --- a/deps/swc/crates/swc_bundler/Cargo.toml +++ b/deps/swc/crates/swc_bundler/Cargo.toml @@ -9,7 +9,7 @@ include = ["Cargo.toml", "build.rs", "src/**/*.rs", "src/**/*.js"] license = { workspace = true } name = "swc_bundler" repository = { workspace = true } -version = "51.0.0" +version = "51.0.1" [package.metadata.docs.rs] all-features = true @@ -41,18 +41,18 @@ rustc-hash = { workspace = true } tracing = { workspace = true } swc_atoms = { version = "9.0.3", path = "../swc_atoms" } -swc_common = { version = "23.0.1", path = "../swc_common" } +swc_common = { version = "23.0.2", path = "../swc_common" } swc_ecma_ast = { version = "25.0.0", path = "../swc_ecma_ast" } -swc_ecma_codegen = { version = "28.0.1", path = "../swc_ecma_codegen" } -swc_ecma_loader = { version = "24.0.0", path = "../swc_ecma_loader" } -swc_ecma_parser = { version = "41.0.1", path = "../swc_ecma_parser", default-features = false, features = [ +swc_ecma_codegen = { version = "28.0.2", path = "../swc_ecma_codegen" } +swc_ecma_loader = { version = "24.0.1", path = "../swc_ecma_loader" } +swc_ecma_parser = { version = "41.1.2", path = "../swc_ecma_parser", default-features = false, features = [ "typescript", ] } -swc_ecma_transforms_base = { version = "44.0.2", path = "../swc_ecma_transforms_base" } -swc_ecma_transforms_optimization = { version = "47.0.0", path = "../swc_ecma_transforms_optimization" } -swc_ecma_utils = { version = "31.0.0", path = "../swc_ecma_utils" } +swc_ecma_transforms_base = { version = "44.0.3", path = "../swc_ecma_transforms_base" } +swc_ecma_transforms_optimization = { version = "47.0.1", path = "../swc_ecma_transforms_optimization" } +swc_ecma_utils = { version = "31.0.1", path = "../swc_ecma_utils" } swc_ecma_visit = { version = "25.0.0", path = "../swc_ecma_visit" } -swc_graph_analyzer = { version = "14.0.1", path = "../swc_graph_analyzer/" } +swc_graph_analyzer = { version = "14.0.2", path = "../swc_graph_analyzer/" } [dev-dependencies] hex = { workspace = true } @@ -63,18 +63,18 @@ reqwest = { workspace = true, features = ["blocking"] } sha1 = { workspace = true } tempfile = { workspace = true } -swc_ecma_loader = { version = "24.0.0", path = "../swc_ecma_loader", features = [ +swc_ecma_loader = { version = "24.0.1", path = "../swc_ecma_loader", features = [ "node", "cache", ] } -swc_ecma_minifier = { version = "55.0.1", path = "../swc_ecma_minifier", features = [ +swc_ecma_minifier = { version = "56.0.1", path = "../swc_ecma_minifier", features = [ "concurrent", ] } -swc_ecma_transforms_base = { version = "44.0.2", path = "../swc_ecma_transforms_base", features = [ +swc_ecma_transforms_base = { version = "44.0.3", path = "../swc_ecma_transforms_base", features = [ "inline-helpers", ] } swc_ecma_transforms_proposal = { version = "44.0.1", path = "../swc_ecma_transforms_proposal" } -swc_ecma_transforms_react = { version = "49.0.0", path = "../swc_ecma_transforms_react" } -swc_ecma_transforms_typescript = { version = "49.0.0", path = "../swc_ecma_transforms_typescript" } +swc_ecma_transforms_react = { version = "50.0.0", path = "../swc_ecma_transforms_react" } +swc_ecma_transforms_typescript = { version = "50.0.0", path = "../swc_ecma_transforms_typescript" } swc_malloc = { version = "1.2.5", path = "../swc_malloc" } -testing = { version = "24.0.0", path = "../testing" } +testing = { version = "24.0.1", path = "../testing" } diff --git a/deps/swc/crates/swc_bundler/src/bundler/chunk/cjs.rs b/deps/swc/crates/swc_bundler/src/bundler/chunk/cjs.rs index 428812e62..e91938ec8 100644 --- a/deps/swc/crates/swc_bundler/src/bundler/chunk/cjs.rs +++ b/deps/swc/crates/swc_bundler/src/bundler/chunk/cjs.rs @@ -58,6 +58,7 @@ where return Ok(module); } + #[cfg(debug_assertions)] tracing::debug!("Merging as a common js module: {}", info.fm.name); let load_var = self.make_cjs_load_var(info, DUMMY_SP); @@ -86,6 +87,7 @@ where self.injected_ctxt, ); + #[cfg(debug_assertions)] tracing::debug!("Injected a variable named `load` for a common js module"); Ok(wrapped) @@ -216,6 +218,7 @@ where self.replaced = true; *node = load; + #[cfg(debug_assertions)] tracing::trace!("Found, and replacing require"); } } diff --git a/deps/swc/crates/swc_bundler/src/bundler/chunk/merge.rs b/deps/swc/crates/swc_bundler/src/bundler/chunk/merge.rs index cc5769b34..730606b47 100644 --- a/deps/swc/crates/swc_bundler/src/bundler/chunk/merge.rs +++ b/deps/swc/crates/swc_bundler/src/bundler/chunk/merge.rs @@ -98,6 +98,7 @@ where let all_deps_of_entry = self.collect_all_deps(&ctx.graph, entry_id, &mut Default::default()); + #[cfg(debug_assertions)] tracing::debug!("Merging dependencies: {:?}", all_deps_of_entry); let deps = all_deps_of_entry.iter().map(|id| { @@ -438,13 +439,16 @@ where } fn finalize_merging_of_entry(&self, ctx: &Ctx, id: ModuleId, entry: &mut Modules) { + #[cfg(debug_assertions)] tracing::trace!("All modules are merged"); + #[cfg(debug_assertions)] tracing::debug!("Injecting reexports"); self.inject_reexports(ctx, id, entry); // entry.print(&self.cm, "before inline"); + #[cfg(debug_assertions)] tracing::debug!("Inlining injected variables"); inline(self.injected_ctxt, entry); @@ -495,6 +499,7 @@ where true }); + #[cfg(debug_assertions)] tracing::debug!("Renaming keywords"); entry.visit_mut_with(&mut KeywordRenamer::default()); @@ -511,9 +516,11 @@ where /// Remove exports with wrong syntax context fn remove_wrong_exports(&self, ctx: &Ctx, info: &TransformedModule, module: &mut Modules) { + #[cfg(debug_assertions)] tracing::debug!("Removing wrong exports"); let item_count = module.iter().count(); + #[cfg(debug_assertions)] tracing::trace!("Item count = {}", item_count); module.retain_mut(|_, item| { @@ -552,6 +559,7 @@ where true }); + #[cfg(debug_assertions)] tracing::debug!("Removed wrong exports"); } @@ -779,6 +787,7 @@ where } // Create `export { local_default as default }` + #[cfg(debug_assertions)] tracing::trace!( "Exporting `default` with `export default decl` ({})", local.sym @@ -851,6 +860,7 @@ where exported: Some(ModuleExportName::Ident(exported)), is_type_only: false, }); + #[cfg(debug_assertions)] tracing::trace!("Exporting `default` with `export default expr`"); extra.push( NamedExport { @@ -904,6 +914,7 @@ where info.export_ctxt(), ); + #[cfg(debug_assertions)] tracing::trace!( "Exporting `{}{:?}` with `export decl`", id.sym, @@ -952,6 +963,7 @@ where _ => panic!("unable to access unknown nodes"), }; + #[cfg(debug_assertions)] tracing::trace!( "Exporting `default` with `export default decl` ({})", local.sym diff --git a/deps/swc/crates/swc_bundler/src/bundler/chunk/mod.rs b/deps/swc/crates/swc_bundler/src/bundler/chunk/mod.rs index f77645487..2d0a6726c 100644 --- a/deps/swc/crates/swc_bundler/src/bundler/chunk/mod.rs +++ b/deps/swc/crates/swc_bundler/src/bundler/chunk/mod.rs @@ -35,6 +35,7 @@ where #[cfg(not(target_arch = "wasm32"))] let dur = Instant::now() - start; #[cfg(not(target_arch = "wasm32"))] + #[cfg(debug_assertions)] tracing::debug!("Dependency analysis took {:?}", dur); if cfg!(debug_assertions) { @@ -77,6 +78,7 @@ where #[cfg(not(target_arch = "wasm32"))] let dur = Instant::now() - start; #[cfg(not(target_arch = "wasm32"))] + #[cfg(debug_assertions)] tracing::debug!("Module preparation took {:?}", dur); let entries = all @@ -95,6 +97,7 @@ where .map(|(id, mut entry)| { self.merge_into_entry(&ctx, id, &mut entry, &mut all); + #[cfg(debug_assertions)] tracing::debug!("Merged `{}` and it's dep into an entry", id); (id, entry) @@ -121,6 +124,7 @@ where let mut a = all.clone(); self.merge_into_entry(&ctx, id, &mut entry, &mut a); + #[cfg(debug_assertions)] tracing::debug!("Merged `{}` and it's dep into an entry", id); (id, entry) diff --git a/deps/swc/crates/swc_bundler/src/bundler/finalize.rs b/deps/swc/crates/swc_bundler/src/bundler/finalize.rs index fd6ce8e3c..abe38dce8 100644 --- a/deps/swc/crates/swc_bundler/src/bundler/finalize.rs +++ b/deps/swc/crates/swc_bundler/src/bundler/finalize.rs @@ -123,6 +123,7 @@ where let path = match &*self.scope.get_module(bundle.id).unwrap().fm.name { FileName::Real(ref v) => v.clone(), _ => { + #[cfg(debug_assertions)] tracing::error!("Cannot rename: not a real file"); return bundle; } diff --git a/deps/swc/crates/swc_bundler/src/bundler/load.rs b/deps/swc/crates/swc_bundler/src/bundler/load.rs index 402902723..8bebcf07c 100644 --- a/deps/swc/crates/swc_bundler/src/bundler/load.rs +++ b/deps/swc/crates/swc_bundler/src/bundler/load.rs @@ -74,10 +74,12 @@ where file_name: &FileName, ) -> Result, Error> { self.run(|| { + #[cfg(debug_assertions)] tracing::trace!("load_transformed: ({})", file_name); // In case of common module if let Some(cached) = self.scope.get_module_by_path(file_name) { + #[cfg(debug_assertions)] tracing::debug!("Cached: {}", file_name); return Ok(Some(cached)); } @@ -88,6 +90,7 @@ where .context("failed to analyze module")?; files.dedup_by_key(|v| v.1.clone()); + #[cfg(debug_assertions)] tracing::debug!( "({:?}, {:?}, {:?}) Storing module: {}", v.id, @@ -101,6 +104,7 @@ where let results = files .into_par_iter() .map(|(_src, path)| { + #[cfg(debug_assertions)] tracing::trace!("loading dependency: {}", path); self.load_transformed(&path) }) @@ -135,6 +139,7 @@ where mut data: ModuleData, ) -> Result<(TransformedModule, Vec<(Source, Lrc)>), Error> { self.run(|| { + #[cfg(debug_assertions)] tracing::trace!("transform_module({})", data.fm.name); let (id, local_mark, export_mark) = self.scope.module_id_gen.gen(file_name); @@ -225,6 +230,7 @@ where raw: RawExports, ) -> Result<(Exports, Vec<(Source, Lrc)>), Error> { self.run(|| { + #[cfg(debug_assertions)] tracing::trace!("resolve_exports({})", base); let mut files = Vec::new(); @@ -282,6 +288,7 @@ where info: RawImports, ) -> Result<(Imports, Vec<(Source, Lrc)>), Error> { self.run(|| { + #[cfg(debug_assertions)] tracing::trace!("resolve_imports({})", base); let mut files = Vec::new(); diff --git a/deps/swc/crates/swc_bundler/src/bundler/mod.rs b/deps/swc/crates/swc_bundler/src/bundler/mod.rs index 5e7b09c9d..cdc718c66 100644 --- a/deps/swc/crates/swc_bundler/src/bundler/mod.rs +++ b/deps/swc/crates/swc_bundler/src/bundler/mod.rs @@ -117,10 +117,13 @@ where ) -> Self { GLOBALS.set(globals, || { let helper_ctxt = SyntaxContext::empty().apply_mark(Mark::fresh(Mark::root())); + #[cfg(debug_assertions)] tracing::debug!("Helper ctxt: {:?}", helper_ctxt); let synthesized_ctxt = SyntaxContext::empty().apply_mark(Mark::fresh(Mark::root())); + #[cfg(debug_assertions)] tracing::debug!("Synthesized ctxt: {:?}", synthesized_ctxt); let injected_ctxt = SyntaxContext::empty().apply_mark(Mark::fresh(Mark::root())); + #[cfg(debug_assertions)] tracing::debug!("Injected ctxt: {:?}", injected_ctxt); Bundler { diff --git a/deps/swc/crates/swc_bundler/src/inline.rs b/deps/swc/crates/swc_bundler/src/inline.rs index 1d8c64962..4d1a86a44 100644 --- a/deps/swc/crates/swc_bundler/src/inline.rs +++ b/deps/swc/crates/swc_bundler/src/inline.rs @@ -15,6 +15,7 @@ pub(crate) struct InlineData { /// Inline **injected** variables. pub(crate) fn inline(injected_ctxt: SyntaxContext, module: &mut Modules) { + #[cfg(debug_assertions)] tracing::debug!("Inlining injected variables"); let mut data = Default::default(); diff --git a/deps/swc/crates/swc_bundler/src/modules/sort/chunk.rs b/deps/swc/crates/swc_bundler/src/modules/sort/chunk.rs index d1ede6dd8..1da84997f 100644 --- a/deps/swc/crates/swc_bundler/src/modules/sort/chunk.rs +++ b/deps/swc/crates/swc_bundler/src/modules/sort/chunk.rs @@ -68,6 +68,7 @@ fn toposort_real_modules<'a>( let mut chunks = Vec::new(); + #[cfg(debug_assertions)] tracing::debug!( "Topologically sorting modules based on the dependency graph: ({} items)", modules.len() @@ -79,6 +80,7 @@ fn toposort_real_modules<'a>( #[cfg(not(target_arch = "wasm32"))] let end = Instant::now(); #[cfg(not(target_arch = "wasm32"))] + #[cfg(debug_assertions)] tracing::debug!("Toposort of module ids took {:?}", end - start); for ids in sorted_ids { if ids.is_empty() { @@ -226,6 +228,7 @@ fn toposort_real_module_ids<'a>( continue; } + #[cfg(debug_assertions)] tracing::info!("Using slow, fallback logic for topological sorting"); all_modules_in_circle.extend(deps_of_circle); } diff --git a/deps/swc/crates/swc_bundler/src/modules/sort/mod.rs b/deps/swc/crates/swc_bundler/src/modules/sort/mod.rs index 5efc9b9a0..5a8db8a34 100644 --- a/deps/swc/crates/swc_bundler/src/modules/sort/mod.rs +++ b/deps/swc/crates/swc_bundler/src/modules/sort/mod.rs @@ -26,6 +26,7 @@ impl Modules { cycles: &Vec>, cm: &Lrc, ) { + #[cfg(debug_assertions)] tracing::debug!("Sorting {:?}", entry_id); let injected_ctxt = self.injected_ctxt; @@ -36,6 +37,7 @@ impl Modules { #[cfg(not(target_arch = "wasm32"))] let dur = Instant::now() - start; #[cfg(not(target_arch = "wasm32"))] + #[cfg(debug_assertions)] tracing::debug!("Sorting took {:?}", dur); let buf = chunks @@ -52,6 +54,7 @@ impl Modules { // print_hygiene("after sort", cm, &module); *self = Modules::from(entry_id, module, injected_ctxt); + #[cfg(debug_assertions)] tracing::debug!("Sorted {:?}", entry_id); } } diff --git a/deps/swc/crates/swc_bundler/src/modules/sort/stmt.rs b/deps/swc/crates/swc_bundler/src/modules/sort/stmt.rs index f3b7366ab..705b99d76 100644 --- a/deps/swc/crates/swc_bundler/src/modules/sort/stmt.rs +++ b/deps/swc/crates/swc_bundler/src/modules/sort/stmt.rs @@ -55,6 +55,7 @@ pub(super) fn sort_stmts( let mut id_graph = calc_deps(&stmts); + #[cfg(debug_assertions)] tracing::debug!("Analyzed dependencies between statements"); let orders = iter( @@ -66,6 +67,7 @@ pub(super) fn sort_stmts( ) .collect::>(); + #[cfg(debug_assertions)] tracing::debug!("Sorted statements"); debug_assert_eq!(total_len, orders.len()); @@ -656,6 +658,7 @@ impl Visit for RequirementCalculator { } fn calc_deps(new: &[ModuleItem]) -> StmtDepGraph { + #[cfg(debug_assertions)] tracing::debug!("Analyzing dependencies between statements"); let mut graph = StmtDepGraph::default(); diff --git a/deps/swc/crates/swc_cli_impl/Cargo.toml b/deps/swc/crates/swc_cli_impl/Cargo.toml index 255cb9f1b..944554b72 100644 --- a/deps/swc/crates/swc_cli_impl/Cargo.toml +++ b/deps/swc/crates/swc_cli_impl/Cargo.toml @@ -6,7 +6,7 @@ include = ["Cargo.toml", "src/**/*.rs"] license = { workspace = true } name = "swc_cli_impl" repository = { workspace = true } -version = "68.0.0" +version = "71.0.0" [[bin]] name = "swc" @@ -35,16 +35,14 @@ path-absolutize = { workspace = true, features = ["once_cell_cache"] } pathdiff = { workspace = true } serde_json = { workspace = true, features = ["unbounded_depth"] } tracing = { workspace = true } -tracing-chrome = { workspace = true } -tracing-subscriber = { workspace = true, features = ["env-filter"] } walkdir = { workspace = true } -swc_core = { version = "68.0.6", features = [ - "trace_macro", +swc_core = { version = "71.0.3", features = [ "common_concurrent", "base_concurrent", "base_flow", "base_module", + "base_react_compiler", "ecma_helpers_inline", ], path = "../swc_core" } diff --git a/deps/swc/crates/swc_cli_impl/src/commands/bundle.rs b/deps/swc/crates/swc_cli_impl/src/commands/bundle.rs index e0efb4bc1..6b55bd910 100644 --- a/deps/swc/crates/swc_cli_impl/src/commands/bundle.rs +++ b/deps/swc/crates/swc_cli_impl/src/commands/bundle.rs @@ -1,10 +1,8 @@ use clap::Parser; -use swc_core::trace_macro::swc_trace; #[derive(Parser)] pub struct BundleOptions {} -#[swc_trace] impl super::CommandRunner for BundleOptions { fn execute(&self) -> anyhow::Result<()> { unimplemented!("Bundle command is not yet implemented") diff --git a/deps/swc/crates/swc_cli_impl/src/commands/compile.rs b/deps/swc/crates/swc_cli_impl/src/commands/compile.rs index 466b46977..a6fe2ec31 100644 --- a/deps/swc/crates/swc_cli_impl/src/commands/compile.rs +++ b/deps/swc/crates/swc_cli_impl/src/commands/compile.rs @@ -24,7 +24,6 @@ use swc_core::{ try_with_handler, Compiler, HandlerOpts, TransformOutput, }, common::{errors::ColorConfig, FileName, FilePathMapping, SourceFile, SourceMap, GLOBALS}, - trace_macro::swc_trace, }; use walkdir::WalkDir; use watch::FileWatcher; @@ -112,13 +111,11 @@ pub struct CompileOptions { #[clap(long, default_value_t = String::from("js"))] out_file_extension: String, - /// Enable experimental trace profiling - /// generates trace compatible with trace event format. + /// Deprecated no-op. Trace profiling is disabled in production builds. #[clap(group = "experimental_trace", long)] experimental_trace: bool, - /// Set file name for the trace output. If not specified, - /// `trace-{unix epoch time}.json` will be used by default. + /// Deprecated no-op. No trace output file will be generated. #[clap(group = "experimental_trace", long)] trace_out_file: Option, } @@ -278,7 +275,7 @@ fn collect_absolute_paths(paths: &[PathBuf]) -> BTreeSet { } /// Infer list of files from cli arguments. -#[tracing::instrument(level = "info", skip_all)] +#[cfg_attr(debug_assertions, tracing::instrument(level = "info", skip_all))] fn collect_input_files( raw_files_input: &[PathBuf], ignore_pattern: Option<&Pattern>, @@ -445,7 +442,6 @@ fn emit_stdout_output(file_path: &Path, output: TransformOutput) { println!("{}\n{}", output.code, source_map); } -#[swc_trace] impl CompileOptions { fn build_transform_options(&self, file_path: &Option<&Path>) -> anyhow::Result { let config_file = self.config_file.as_ref().map(|config_file_path| { @@ -968,6 +964,7 @@ impl CompileOptions { let cwd = match std::env::current_dir() { Ok(cwd) => cwd, Err(error) => { + #[cfg(debug_assertions)] tracing::warn!(error = %error, "failed to read current directory for watch batch"); return; } @@ -975,6 +972,7 @@ impl CompileOptions { let output_dir = match absolutize_path(out_dir) { Ok(output_dir) => output_dir, Err(error) => { + #[cfg(debug_assertions)] tracing::warn!(error = %error, "failed to resolve output directory for watch batch"); return; } @@ -1142,6 +1140,7 @@ impl CompileOptions { let cwd = match std::env::current_dir() { Ok(cwd) => cwd, Err(error) => { + #[cfg(debug_assertions)] tracing::warn!(error = %error, "failed to read current directory for watch batch"); continue; } @@ -1191,16 +1190,13 @@ impl CompileOptions { } } -#[swc_trace] impl super::CommandRunner for CompileOptions { fn execute(&self) -> anyhow::Result<()> { self.validate()?; - let guard = if self.experimental_trace { - init_trace(&self.trace_out_file) - } else { - None - }; + if self.experimental_trace { + init_trace(&self.trace_out_file); + } let result = if self.watch { if let Some(out_dir) = self.out_dir.as_ref() { @@ -1214,11 +1210,6 @@ impl super::CommandRunner for CompileOptions { self.execute_once() }; - if let Some(guard) = guard { - guard.flush(); - drop(guard); - } - result } } diff --git a/deps/swc/crates/swc_cli_impl/src/commands/compile/watch.rs b/deps/swc/crates/swc_cli_impl/src/commands/compile/watch.rs index a765b2815..1384d4699 100644 --- a/deps/swc/crates/swc_cli_impl/src/commands/compile/watch.rs +++ b/deps/swc/crates/swc_cli_impl/src/commands/compile/watch.rs @@ -53,7 +53,10 @@ impl FileWatcher { { Ok(event) => event, Err(error) => { + #[cfg(debug_assertions)] tracing::warn!(error = %error, "file watcher emitted a recoverable error"); + #[cfg(not(debug_assertions))] + let _ = error; continue; } }; diff --git a/deps/swc/crates/swc_cli_impl/src/commands/lint.rs b/deps/swc/crates/swc_cli_impl/src/commands/lint.rs index 737c3e356..ae2bb7da6 100644 --- a/deps/swc/crates/swc_cli_impl/src/commands/lint.rs +++ b/deps/swc/crates/swc_cli_impl/src/commands/lint.rs @@ -1,10 +1,8 @@ use clap::Parser; -use swc_core::trace_macro::swc_trace; #[derive(Parser)] pub struct LintOptions {} -#[swc_trace] impl super::CommandRunner for LintOptions { fn execute(&self) -> anyhow::Result<()> { unimplemented!("Lint command is not yet implemented") diff --git a/deps/swc/crates/swc_cli_impl/src/commands/minify.rs b/deps/swc/crates/swc_cli_impl/src/commands/minify.rs index 84ed603ae..1587af9ef 100644 --- a/deps/swc/crates/swc_cli_impl/src/commands/minify.rs +++ b/deps/swc/crates/swc_cli_impl/src/commands/minify.rs @@ -1,10 +1,8 @@ use clap::Parser; -use swc_core::trace_macro::swc_trace; #[derive(Parser)] pub struct MinifyOptions {} -#[swc_trace] impl super::CommandRunner for MinifyOptions { fn execute(&self) -> anyhow::Result<()> { unimplemented!("Minify command is not yet implemented") diff --git a/deps/swc/crates/swc_cli_impl/src/util/trace.rs b/deps/swc/crates/swc_cli_impl/src/util/trace.rs index b9748681d..1a6c4acf1 100644 --- a/deps/swc/crates/swc_cli_impl/src/util/trace.rs +++ b/deps/swc/crates/swc_cli_impl/src/util/trace.rs @@ -1,23 +1,2 @@ -use tracing_chrome::{ChromeLayerBuilder, FlushGuard}; -use tracing_subscriber::{ - filter, prelude::__tracing_subscriber_SubscriberExt, util::SubscriberInitExt, Layer, -}; - -/// Register a tracing subscriber generated event trace format output. -pub(crate) fn init_trace(out_file: &Option) -> Option { - let mut layer = ChromeLayerBuilder::new().include_args(true); - - if let Some(trace_out_file) = out_file { - layer = layer.file(trace_out_file.clone()); - } - - let (chrome_layer, guard) = layer.build(); - tracing_subscriber::registry() - .with(chrome_layer.with_filter(filter::filter_fn(|metadata| { - !metadata.target().contains("cranelift") && !metadata.name().contains("log ") - }))) - .try_init() - .expect("Should able to register trace"); - - Some(guard) -} +/// Deprecated no-op kept for CLI flag compatibility. +pub(crate) fn init_trace(_out_file: &Option) {} diff --git a/deps/swc/crates/swc_common/Cargo.toml b/deps/swc/crates/swc_common/Cargo.toml index 0ba029737..467031a6c 100644 --- a/deps/swc/crates/swc_common/Cargo.toml +++ b/deps/swc/crates/swc_common/Cargo.toml @@ -6,7 +6,7 @@ edition = { workspace = true } license = { workspace = true } name = "swc_common" repository = { workspace = true } -version = "23.0.1" +version = "23.0.2" [package.metadata.docs.rs] all-features = true diff --git a/deps/swc/crates/swc_common/src/errors/diagnostic_builder.rs b/deps/swc/crates/swc_common/src/errors/diagnostic_builder.rs index 81190ee1e..3a921cb39 100644 --- a/deps/swc/crates/swc_common/src/errors/diagnostic_builder.rs +++ b/deps/swc/crates/swc_common/src/errors/diagnostic_builder.rs @@ -182,6 +182,7 @@ impl<'a> DiagnosticBuilder<'a> { // Logging here is useful to help track down where in logs an error was // actually emitted. if cfg!(feature = "debug") { + #[cfg(debug_assertions)] debug!("buffer: diagnostic={:?}", diagnostic); } buffered_diagnostics.push(*diagnostic); diff --git a/deps/swc/crates/swc_common/src/plugin/serialized.rs b/deps/swc/crates/swc_common/src/plugin/serialized.rs index f0d73b1c3..dac996dea 100644 --- a/deps/swc/crates/swc_common/src/plugin/serialized.rs +++ b/deps/swc/crates/swc_common/src/plugin/serialized.rs @@ -47,7 +47,7 @@ impl PluginSerializedBytes { * Constructs an instance from already serialized byte * slices. */ - #[tracing::instrument(level = "info", skip_all)] + #[cfg_attr(debug_assertions, tracing::instrument(level = "info", skip_all))] pub fn from_bytes(field: Vec) -> PluginSerializedBytes { PluginSerializedBytes { field } } @@ -59,7 +59,7 @@ impl PluginSerializedBytes { * to implement TryFrom trait */ /* - #[tracing::instrument(level = "info", skip_all)] + #[cfg_attr(debug_assertions, tracing::instrument(level = "info", skip_all))] pub fn try_serialize(t: &VersionedSerializable) -> Result where W: rkyv::Serialize>, @@ -78,7 +78,7 @@ impl PluginSerializedBytes { } */ - #[tracing::instrument(level = "info", skip_all)] + #[cfg_attr(debug_assertions, tracing::instrument(level = "info", skip_all))] pub fn try_serialize(t: &VersionedSerializable) -> Result where W: cbor4ii::core::enc::Encode, @@ -93,7 +93,7 @@ impl PluginSerializedBytes { /* * Internal fn to constructs an instance from raw bytes ptr. */ - #[tracing::instrument(level = "info", skip_all)] + #[cfg_attr(debug_assertions, tracing::instrument(level = "info", skip_all))] #[allow(clippy::not_unsafe_ptr_arg_deref)] pub fn from_raw_ptr( raw_allocated_ptr: *const u8, @@ -113,7 +113,7 @@ impl PluginSerializedBytes { (self.field.as_ptr(), self.field.len()) } - #[tracing::instrument(level = "info", skip_all)] + #[cfg_attr(debug_assertions, tracing::instrument(level = "info", skip_all))] pub fn deserialize(&self) -> Result, Error> where W: for<'de> cbor4ii::core::dec::Decode<'de>, @@ -127,7 +127,7 @@ impl PluginSerializedBytes { } /* - #[tracing::instrument(level = "info", skip_all)] + #[cfg_attr(debug_assertions, tracing::instrument(level = "info", skip_all))] pub fn deserialize(&self) -> Result, Error> where W: rkyv::Archive, diff --git a/deps/swc/crates/swc_common/src/source_map.rs b/deps/swc/crates/swc_common/src/source_map.rs index 4d11482a9..bce1ccbd2 100644 --- a/deps/swc/crates/swc_common/src/source_map.rs +++ b/deps/swc/crates/swc_common/src/source_map.rs @@ -357,14 +357,17 @@ impl SourceMap { col.0 - special_chars + non_narrow }; if cfg!(feature = "debug") { + #[cfg(debug_assertions)] debug!( "byte pos {:?} is on the line at byte pos {:?}", pos, linebpos ); + #[cfg(debug_assertions)] debug!( "char pos {:?} is on the line at char pos {:?}", chpos, linechpos ); + #[cfg(debug_assertions)] debug!("byte is on line: {}", line); } // assert!(chpos >= linechpos); @@ -501,6 +504,7 @@ impl SourceMap { pub fn span_to_lines(&self, sp: Span) -> FileLinesResult { if cfg!(feature = "debug") { + #[cfg(debug_assertions)] debug!("span_to_lines(sp={:?})", sp); } @@ -510,10 +514,12 @@ impl SourceMap { let lo = self.lookup_char_pos(sp.lo()); if cfg!(feature = "debug") { + #[cfg(debug_assertions)] debug!("span_to_lines: lo={:?}", lo); } let hi = self.lookup_char_pos(sp.hi()); if cfg!(feature = "debug") { + #[cfg(debug_assertions)] debug!("span_to_lines: hi={:?}", hi); } @@ -885,12 +891,14 @@ impl SourceMap { fn find_width_of_character_at_span(&self, sp: Span, forwards: bool) -> u32 { // Disregard malformed spans and assume a one-byte wide character. if sp.lo() >= sp.hi() { + #[cfg(debug_assertions)] debug!("find_width_of_character_at_span: early return malformed span"); return 1; } let local_begin = self.lookup_byte_offset(sp.lo()); let local_end = self.lookup_byte_offset(sp.hi()); + #[cfg(debug_assertions)] debug!( "find_width_of_character_at_span: local_begin=`{:?}`, local_end=`{:?}`", local_begin, local_end @@ -898,6 +906,7 @@ impl SourceMap { let start_index = local_begin.pos.to_usize(); let end_index = local_end.pos.to_usize(); + #[cfg(debug_assertions)] debug!( "find_width_of_character_at_span: start_index=`{:?}`, end_index=`{:?}`", start_index, end_index @@ -906,17 +915,20 @@ impl SourceMap { // Disregard indexes that are at the start or end of their spans, they can't fit // bigger characters. if (!forwards && end_index == usize::MIN) || (forwards && start_index == usize::MAX) { + #[cfg(debug_assertions)] debug!("find_width_of_character_at_span: start or end of span, cannot be multibyte"); return 1; } let source_len = (local_begin.sf.end_pos - local_begin.sf.start_pos).to_usize(); + #[cfg(debug_assertions)] debug!( "find_width_of_character_at_span: source_len=`{:?}`", source_len ); // Ensure indexes are also not malformed. if start_index > end_index || end_index > source_len { + #[cfg(debug_assertions)] debug!("find_width_of_character_at_span: source indexes are malformed"); return 1; } @@ -929,6 +941,7 @@ impl SourceMap { let len = src.len(); &src[start_index..len] }; + #[cfg(debug_assertions)] debug!("find_width_of_character_at_span: snippet=`{:?}`", snippet); let mut target = if forwards { @@ -936,6 +949,7 @@ impl SourceMap { } else { end_index - 1 }; + #[cfg(debug_assertions)] debug!( "find_width_of_character_at_span: initial target=`{:?}`", target @@ -952,8 +966,10 @@ impl SourceMap { } } }; + #[cfg(debug_assertions)] debug!("find_width_of_character_at_span: target=`{:?}`", target); } + #[cfg(debug_assertions)] debug!( "find_width_of_character_at_span: final target=`{:?}`", target @@ -1200,6 +1216,7 @@ fn calc_utf16_offset(file: &SourceFile, bpos: BytePos, state: &mut ByteToCharPos let range = index..analysis.multibyte_chars.len(); for i in range { let mbc = &analysis.multibyte_chars[i]; + #[cfg(debug_assertions)] debug!("{}-byte char at {:?}", mbc.bytes, mbc.pos); if mbc.pos >= bpos { break; @@ -1220,6 +1237,7 @@ fn calc_utf16_offset(file: &SourceFile, bpos: BytePos, state: &mut ByteToCharPos let range = 0..index; for i in range.rev() { let mbc = &analysis.multibyte_chars[i]; + #[cfg(debug_assertions)] debug!("{}-byte char at {:?}", mbc.bytes, mbc.pos); if mbc.pos < bpos { break; diff --git a/deps/swc/crates/swc_compiler_base/Cargo.toml b/deps/swc/crates/swc_compiler_base/Cargo.toml index 63c034529..e68be15ad 100644 --- a/deps/swc/crates/swc_compiler_base/Cargo.toml +++ b/deps/swc/crates/swc_compiler_base/Cargo.toml @@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs"] license = { workspace = true } name = "swc_compiler_base" repository = { workspace = true } -version = "58.0.0" +version = "59.0.0" [features] node = ["napi", "napi-derive"] @@ -24,18 +24,17 @@ serde_json = { workspace = true } swc_sourcemap = { workspace = true } swc_atoms = { version = "9.0.3", path = "../swc_atoms" } -swc_common = { version = "23.0.1", path = "../swc_common", features = [ +swc_common = { version = "23.0.2", path = "../swc_common", features = [ "sourcemap", ] } swc_config = { version = "5.0.0", path = "../swc_config" } swc_ecma_ast = { version = "25.0.0", path = "../swc_ecma_ast" } -swc_ecma_codegen = { version = "28.0.1", path = "../swc_ecma_codegen" } -swc_ecma_minifier = { version = "55.0.1", path = "../swc_ecma_minifier" } -swc_ecma_parser = { version = "41.0.1", path = "../swc_ecma_parser", default-features = false, features = [ +swc_ecma_codegen = { version = "28.0.2", path = "../swc_ecma_codegen" } +swc_ecma_minifier = { version = "56.0.1", path = "../swc_ecma_minifier" } +swc_ecma_parser = { version = "41.1.2", path = "../swc_ecma_parser", default-features = false, features = [ "typescript", ] } swc_ecma_visit = { version = "25.0.0", path = "../swc_ecma_visit" } -swc_timer = { version = "1.0.0", path = "../swc_timer" } [dependencies.napi-derive] default-features = false diff --git a/deps/swc/crates/swc_compiler_base/src/lib.rs b/deps/swc/crates/swc_compiler_base/src/lib.rs index ea9570568..632385b50 100644 --- a/deps/swc/crates/swc_compiler_base/src/lib.rs +++ b/deps/swc/crates/swc_compiler_base/src/lib.rs @@ -30,7 +30,6 @@ use swc_ecma_parser::{ Syntax, }; use swc_ecma_visit::{noop_visit_type, Visit, VisitWith}; -use swc_timer::timer; mod source_map_scopes; @@ -200,8 +199,6 @@ pub fn print( where T: Node + VisitWith, { - let _timer = timer!("Compiler::print"); - let mut src_map_buf = Vec::new(); let should_emit_scope_map = source_map.enabled() && emit_source_map_scopes && orig.is_none(); let mut scope_buf = should_emit_scope_map.then(Vec::::new); diff --git a/deps/swc/crates/swc_core/Cargo.toml b/deps/swc/crates/swc_core/Cargo.toml index 60f223e4d..522e119c2 100644 --- a/deps/swc/crates/swc_core/Cargo.toml +++ b/deps/swc/crates/swc_core/Cargo.toml @@ -6,7 +6,7 @@ edition = { workspace = true } license = { workspace = true } name = "swc_core" repository = { workspace = true } -version = "68.0.6" +version = "71.0.3" [package.metadata.docs.rs] features = [ "allocator_node", @@ -20,7 +20,6 @@ features = [ "bundler", "ecma_loader", "ecma_ast", - "trace_macro", "transform_common", "plugin_transform", ] @@ -66,6 +65,8 @@ base_flow = ["__base", "swc/flow"] # Enable module transforms (CommonJS, AMD, UMD, SystemJS). # Bundlers typically don't need this as they handle module transforms themselves. base_module = ["__base", "swc/module"] +# Enable React Compiler APIs exposed via `base`. +base_react_compiler = ["__base", "swc/react-compiler"] # Enables n-api related features. base_node = [ "__base", @@ -178,11 +179,6 @@ css_visit_path = ["__css", "swc_css_visit/path"] # Utilities for testing. testing = ["dep:testing"] -# Enable trace macro support. -# TODO: Once all top-level package (node, wasm, cli..) imports swc_core, -# we may encapsulate `tracing` package into swc_core. -trace_macro = ["swc_trace_macro"] - binding_macro_native = ["__binding_macros", "binding_macros/binding_native"] binding_macro_wasm = ["__binding_macros", "binding_macros/binding_wasm"] @@ -336,12 +332,12 @@ __visit = ["__ecma", "swc_ecma_visit"] par-core = { workspace = true, optional = true } # swc_* dependencies -binding_macros = { optional = true, version = "66.0.0", path = "../binding_macros" } -swc = { optional = true, version = "66.0.1", path = "../swc", default-features = false } +binding_macros = { optional = true, version = "69.0.0", path = "../binding_macros" } +swc = { optional = true, version = "69.0.0", path = "../swc", default-features = false } swc_allocator = { version = "4.0.1", path = "../swc_allocator", default-features = false } swc_atoms = { optional = true, version = "9.0.3", path = "../swc_atoms" } -swc_bundler = { optional = true, version = "51.0.0", path = "../swc_bundler" } -swc_common = { optional = true, version = "23.0.1", path = "../swc_common" } +swc_bundler = { optional = true, version = "51.0.1", path = "../swc_bundler" } +swc_common = { optional = true, version = "23.0.2", path = "../swc_common" } swc_config = { optional = true, version = "5.0.0", path = "../swc_config" } swc_css_ast = { optional = true, version = "23.0.0", path = "../swc_css_ast" } swc_css_codegen = { optional = true, version = "23.0.0", path = "../swc_css_codegen" } @@ -353,39 +349,38 @@ swc_css_prefixer = { optional = true, version = "28.0.0", path = swc_css_utils = { optional = true, version = "23.0.0", path = "../swc_css_utils/" } swc_css_visit = { optional = true, version = "23.0.0", path = "../swc_css_visit" } swc_ecma_ast = { optional = true, version = "25.0.0", path = "../swc_ecma_ast" } -swc_ecma_codegen = { optional = true, version = "28.0.1", path = "../swc_ecma_codegen" } +swc_ecma_codegen = { optional = true, version = "28.0.2", path = "../swc_ecma_codegen" } swc_ecma_lints = { optional = true, version = "33.0.0", path = "../swc_ecma_lints" } -swc_ecma_loader = { optional = true, version = "24.0.0", path = "../swc_ecma_loader" } -swc_ecma_minifier = { optional = true, version = "55.0.1", path = "../swc_ecma_minifier" } -swc_ecma_parser = { optional = true, version = "41.0.1", path = "../swc_ecma_parser", default-features = false } -swc_ecma_preset_env = { optional = true, version = "56.0.0", path = "../swc_ecma_preset_env" } +swc_ecma_loader = { optional = true, version = "24.0.1", path = "../swc_ecma_loader" } +swc_ecma_minifier = { optional = true, version = "56.0.1", path = "../swc_ecma_minifier" } +swc_ecma_parser = { optional = true, version = "41.1.2", path = "../swc_ecma_parser", default-features = false } +swc_ecma_preset_env = { optional = true, version = "57.0.0", path = "../swc_ecma_preset_env" } swc_ecma_quote_macros = { optional = true, version = "41.0.0", path = "../swc_ecma_quote_macros" } -swc_ecma_react_compiler = { optional = true, version = "19.0.0", path = "../swc_ecma_react_compiler" } -swc_ecma_transforms_base = { optional = true, version = "44.0.2", path = "../swc_ecma_transforms_base" } -swc_ecma_transforms_compat = { optional = true, version = "51.0.1", path = "../swc_ecma_transforms_compat" } -swc_ecma_transforms_module = { optional = true, version = "49.0.0", path = "../swc_ecma_transforms_module" } -swc_ecma_transforms_optimization = { optional = true, version = "47.0.0", path = "../swc_ecma_transforms_optimization" } +swc_ecma_react_compiler = { optional = true, version = "20.0.2", path = "../swc_ecma_react_compiler" } +swc_ecma_transforms_base = { optional = true, version = "44.0.3", path = "../swc_ecma_transforms_base" } +swc_ecma_transforms_compat = { optional = true, version = "52.0.1", path = "../swc_ecma_transforms_compat" } +swc_ecma_transforms_module = { optional = true, version = "49.0.1", path = "../swc_ecma_transforms_module" } +swc_ecma_transforms_optimization = { optional = true, version = "47.0.1", path = "../swc_ecma_transforms_optimization" } swc_ecma_transforms_proposal = { optional = true, version = "44.0.1", path = "../swc_ecma_transforms_proposal" } -swc_ecma_transforms_react = { optional = true, version = "49.0.0", path = "../swc_ecma_transforms_react" } +swc_ecma_transforms_react = { optional = true, version = "50.0.0", path = "../swc_ecma_transforms_react" } swc_ecma_transforms_testing = { optional = true, version = "48.0.0", path = "../swc_ecma_transforms_testing" } -swc_ecma_transforms_typescript = { optional = true, version = "49.0.0", path = "../swc_ecma_transforms_typescript" } -swc_ecma_utils = { optional = true, version = "31.0.0", path = "../swc_ecma_utils" } +swc_ecma_transforms_typescript = { optional = true, version = "50.0.0", path = "../swc_ecma_transforms_typescript" } +swc_ecma_utils = { optional = true, version = "31.0.1", path = "../swc_ecma_utils" } swc_ecma_visit = { optional = true, version = "25.0.0", path = "../swc_ecma_visit" } swc_malloc = { optional = true, version = "1.2.5", path = "../swc_malloc" } -swc_node_bundler = { optional = true, version = "67.0.0", path = "../swc_node_bundler" } +swc_node_bundler = { optional = true, version = "70.0.0", path = "../swc_node_bundler" } swc_nodejs_common = { optional = true, version = "1.0.3", path = "../swc_nodejs_common" } swc_plugin = { optional = true, version = "1.0.1", path = "../swc_plugin" } -swc_plugin_macro = { optional = true, version = "1.1.0", path = "../swc_plugin_macro" } -swc_plugin_proxy = { optional = true, version = "25.0.0", path = "../swc_plugin_proxy" } -swc_plugin_runner = { optional = true, version = "29.0.0", path = "../swc_plugin_runner", default-features = false } -swc_trace_macro = { optional = true, version = "2.0.2", path = "../swc_trace_macro" } +swc_plugin_macro = { optional = true, version = "1.1.1", path = "../swc_plugin_macro" } +swc_plugin_proxy = { optional = true, version = "26.0.0", path = "../swc_plugin_proxy" } +swc_plugin_runner = { optional = true, version = "30.0.0", path = "../swc_plugin_runner", default-features = false } swc_transform_common = { optional = true, version = "17.0.0", path = "../swc_transform_common" } -swc_typescript = { optional = true, version = "30.0.0", path = "../swc_typescript" } -testing = { optional = true, version = "24.0.0", path = "../testing" } +swc_typescript = { optional = true, version = "30.0.1", path = "../swc_typescript" } +testing = { optional = true, version = "24.0.1", path = "../testing" } [build-dependencies] vergen = { workspace = true, features = ["cargo"] } [dev-dependencies] anyhow = { workspace = true } -testing = { version = "24.0.0", path = "../testing" } +testing = { version = "24.0.1", path = "../testing" } diff --git a/deps/swc/crates/swc_core/src/lib.rs b/deps/swc/crates/swc_core/src/lib.rs index 3e0d6ef38..c16fcd63f 100644 --- a/deps/swc/crates/swc_core/src/lib.rs +++ b/deps/swc/crates/swc_core/src/lib.rs @@ -175,13 +175,6 @@ pub mod plugin_runner { pub use swc_plugin_runner::*; } -// swc_trace_macro -#[cfg(feature = "trace_macro")] -#[cfg_attr(docsrs, doc(cfg(feature = "trace_macro")))] -pub mod trace_macro { - pub use swc_trace_macro::*; -} - #[cfg(feature = "transform_common")] #[cfg_attr(docsrs, doc(cfg(feature = "transform_common")))] pub extern crate swc_transform_common as transform_common; diff --git a/deps/swc/crates/swc_css_ast/Cargo.toml b/deps/swc/crates/swc_css_ast/Cargo.toml index 1fa07df96..805857230 100644 --- a/deps/swc/crates/swc_css_ast/Cargo.toml +++ b/deps/swc/crates/swc_css_ast/Cargo.toml @@ -35,7 +35,7 @@ serde = { workspace = true, features = ["derive"], optional = true } string_enum = { version = "1.0.2", path = "../string_enum/" } swc_atoms = { version = "9.0.3", path = "../swc_atoms" } -swc_common = { version = "23.0.1", path = "../swc_common" } +swc_common = { version = "23.0.2", path = "../swc_common" } cbor4ii = { workspace = true, features = ["use_std"], optional = true } rkyv = { workspace = true, optional = true } diff --git a/deps/swc/crates/swc_css_codegen/Cargo.toml b/deps/swc/crates/swc_css_codegen/Cargo.toml index b39299639..d6816218c 100644 --- a/deps/swc/crates/swc_css_codegen/Cargo.toml +++ b/deps/swc/crates/swc_css_codegen/Cargo.toml @@ -19,15 +19,15 @@ rustc-hash = { workspace = true } serde = { workspace = true } swc_atoms = { version = "9.0.3", path = "../swc_atoms" } -swc_common = { version = "23.0.1", path = "../swc_common" } +swc_common = { version = "23.0.2", path = "../swc_common" } swc_css_ast = { version = "23.0.0", path = "../swc_css_ast" } swc_css_codegen_macros = { version = "1.0.2", path = "../swc_css_codegen_macros" } swc_css_utils = { version = "23.0.0", path = "../swc_css_utils" } [dev-dependencies] -swc_common = { version = "23.0.1", path = "../swc_common", features = [ +swc_common = { version = "23.0.2", path = "../swc_common", features = [ "sourcemap", ] } swc_css_parser = { version = "23.0.0", path = "../swc_css_parser" } swc_css_visit = { version = "23.0.0", path = "../swc_css_visit" } -testing = { version = "24.0.0", path = "../testing" } +testing = { version = "24.0.1", path = "../testing" } diff --git a/deps/swc/crates/swc_css_compat/Cargo.toml b/deps/swc/crates/swc_css_compat/Cargo.toml index 4a1df9bc6..9202ed4c3 100644 --- a/deps/swc/crates/swc_css_compat/Cargo.toml +++ b/deps/swc/crates/swc_css_compat/Cargo.toml @@ -17,7 +17,7 @@ bitflags = { workspace = true } serde = { workspace = true, features = ["derive"] } swc_atoms = { version = "9.0.3", path = "../swc_atoms" } -swc_common = { version = "23.0.1", path = "../swc_common" } +swc_common = { version = "23.0.2", path = "../swc_common" } swc_css_ast = { version = "23.0.0", path = "../swc_css_ast" } swc_css_utils = { version = "23.0.0", path = "../swc_css_utils/" } swc_css_visit = { version = "23.0.0", path = "../swc_css_visit" } @@ -25,4 +25,4 @@ swc_css_visit = { version = "23.0.0", path = "../swc_css_visit" } [dev-dependencies] swc_css_codegen = { version = "23.0.0", path = "../swc_css_codegen" } swc_css_parser = { version = "23.0.0", path = "../swc_css_parser" } -testing = { version = "24.0.0", path = "../testing" } +testing = { version = "24.0.1", path = "../testing" } diff --git a/deps/swc/crates/swc_css_lints/Cargo.toml b/deps/swc/crates/swc_css_lints/Cargo.toml index 82b09a10f..f1c10eb6c 100644 --- a/deps/swc/crates/swc_css_lints/Cargo.toml +++ b/deps/swc/crates/swc_css_lints/Cargo.toml @@ -22,7 +22,7 @@ serde = { workspace = true, features = ["derive"] } thiserror = { workspace = true } swc_atoms = { version = "9.0.3", path = "../swc_atoms" } -swc_common = { version = "23.0.1", path = "../swc_common" } +swc_common = { version = "23.0.2", path = "../swc_common" } swc_config = { version = "5.0.0", path = "../swc_config", features = ["regex"] } swc_css_ast = { version = "23.0.0", path = "../swc_css_ast" } swc_css_visit = { version = "23.0.0", path = "../swc_css_visit" } @@ -31,4 +31,4 @@ swc_css_visit = { version = "23.0.0", path = "../swc_css_visit" } serde_json = { workspace = true } swc_css_parser = { version = "23.0.0", path = "../swc_css_parser" } -testing = { version = "24.0.0", path = "../testing" } +testing = { version = "24.0.1", path = "../testing" } diff --git a/deps/swc/crates/swc_css_minifier/Cargo.toml b/deps/swc/crates/swc_css_minifier/Cargo.toml index c64cec417..c9c969450 100644 --- a/deps/swc/crates/swc_css_minifier/Cargo.toml +++ b/deps/swc/crates/swc_css_minifier/Cargo.toml @@ -17,7 +17,7 @@ rustc-hash = { workspace = true } serde = { workspace = true } swc_atoms = { version = "9.0.3", path = "../swc_atoms" } -swc_common = { version = "23.0.1", path = "../swc_common" } +swc_common = { version = "23.0.2", path = "../swc_common" } swc_css_ast = { version = "23.0.0", path = "../swc_css_ast" } swc_css_utils = { version = "23.0.0", path = "../swc_css_utils/" } swc_css_visit = { version = "23.0.0", path = "../swc_css_visit" } @@ -26,4 +26,4 @@ swc_css_visit = { version = "23.0.0", path = "../swc_css_visit" } swc_css_codegen = { version = "23.0.0", path = "../swc_css_codegen" } swc_css_parser = { version = "23.0.0", path = "../swc_css_parser" } -testing = { version = "24.0.0", path = "../testing" } +testing = { version = "24.0.1", path = "../testing" } diff --git a/deps/swc/crates/swc_css_modules/Cargo.toml b/deps/swc/crates/swc_css_modules/Cargo.toml index 017a1ce09..d41f853ad 100644 --- a/deps/swc/crates/swc_css_modules/Cargo.toml +++ b/deps/swc/crates/swc_css_modules/Cargo.toml @@ -19,7 +19,7 @@ rustc-hash = { workspace = true } serde = { workspace = true, features = ["derive"] } swc_atoms = { version = "9.0.3", path = "../swc_atoms" } -swc_common = { version = "23.0.1", path = "../swc_common" } +swc_common = { version = "23.0.2", path = "../swc_common" } swc_css_ast = { version = "23.0.0", path = "../swc_css_ast" } swc_css_codegen = { version = "23.0.0", path = "../swc_css_codegen" } swc_css_parser = { version = "23.0.0", path = "../swc_css_parser" } @@ -29,4 +29,4 @@ swc_css_visit = { version = "23.0.0", path = "../swc_css_visit" } indexmap = { workspace = true, features = ["serde"] } swc_css_compat = { version = "23.0.0", path = "../swc_css_compat" } -testing = { version = "24.0.0", path = "../testing" } +testing = { version = "24.0.1", path = "../testing" } diff --git a/deps/swc/crates/swc_css_parser/Cargo.toml b/deps/swc/crates/swc_css_parser/Cargo.toml index 4fe59a1f2..118705309 100644 --- a/deps/swc/crates/swc_css_parser/Cargo.toml +++ b/deps/swc/crates/swc_css_parser/Cargo.toml @@ -20,7 +20,7 @@ lexical = { workspace = true } serde = { workspace = true } swc_atoms = { version = "9.0.3", path = "../swc_atoms" } -swc_common = { version = "23.0.1", path = "../swc_common" } +swc_common = { version = "23.0.2", path = "../swc_common" } swc_css_ast = { version = "23.0.0", path = "../swc_css_ast" } [dev-dependencies] @@ -32,7 +32,7 @@ swc_css_ast = { version = "23.0.0", path = "../swc_css_ast", features = [ ] } swc_css_visit = { version = "23.0.0", path = "../swc_css_visit" } swc_malloc = { version = "1.2.5", path = "../swc_malloc" } -testing = { version = "24.0.0", path = "../testing" } +testing = { version = "24.0.1", path = "../testing" } [[bench]] harness = false diff --git a/deps/swc/crates/swc_css_prefixer/Cargo.toml b/deps/swc/crates/swc_css_prefixer/Cargo.toml index a9eb80d6b..f0c704557 100644 --- a/deps/swc/crates/swc_css_prefixer/Cargo.toml +++ b/deps/swc/crates/swc_css_prefixer/Cargo.toml @@ -18,9 +18,9 @@ rustc-hash = { workspace = true } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } -preset_env_base = { version = "8.0.0", path = "../preset_env_base" } +preset_env_base = { version = "8.0.1", path = "../preset_env_base" } swc_atoms = { version = "9.0.3", path = "../swc_atoms" } -swc_common = { version = "23.0.1", path = "../swc_common" } +swc_common = { version = "23.0.2", path = "../swc_common" } swc_css_ast = { version = "23.0.0", path = "../swc_css_ast" } swc_css_utils = { version = "23.0.0", path = "../swc_css_utils/" } swc_css_visit = { version = "23.0.0", path = "../swc_css_visit" } @@ -28,4 +28,4 @@ swc_css_visit = { version = "23.0.0", path = "../swc_css_visit" } [dev-dependencies] swc_css_codegen = { version = "23.0.0", path = "../swc_css_codegen" } swc_css_parser = { version = "23.0.0", path = "../swc_css_parser" } -testing = { version = "24.0.0", path = "../testing" } +testing = { version = "24.0.1", path = "../testing" } diff --git a/deps/swc/crates/swc_css_visit/Cargo.toml b/deps/swc/crates/swc_css_visit/Cargo.toml index 483e3da90..3e61eba9f 100644 --- a/deps/swc/crates/swc_css_visit/Cargo.toml +++ b/deps/swc/crates/swc_css_visit/Cargo.toml @@ -24,6 +24,6 @@ serde-impl = ["serde"] serde = { workspace = true, optional = true, features = ["derive"] } swc_atoms = { version = "9.0.3", path = "../swc_atoms" } -swc_common = { version = "23.0.1", path = "../swc_common" } +swc_common = { version = "23.0.2", path = "../swc_common" } swc_css_ast = { version = "23.0.0", path = "../swc_css_ast" } swc_visit = { version = "2.0.1", path = "../swc_visit" } diff --git a/deps/swc/crates/swc_ecma_ast/Cargo.toml b/deps/swc/crates/swc_ecma_ast/Cargo.toml index 812b0f59c..1815d32e8 100644 --- a/deps/swc/crates/swc_ecma_ast/Cargo.toml +++ b/deps/swc/crates/swc_ecma_ast/Cargo.toml @@ -59,7 +59,7 @@ unicode-id-start = { workspace = true } string_enum = { version = "1.0.2", path = "../string_enum" } swc_atoms = { version = "9.0.3", path = "../swc_atoms" } -swc_common = { version = "23.0.1", path = "../swc_common" } +swc_common = { version = "23.0.2", path = "../swc_common" } swc_visit = { version = "2.0.1", path = "../swc_visit" } cbor4ii = { workspace = true, features = ["use_std"], optional = true } diff --git a/deps/swc/crates/swc_ecma_codegen/Cargo.toml b/deps/swc/crates/swc_ecma_codegen/Cargo.toml index 55066c30e..b8f9e87f7 100644 --- a/deps/swc/crates/swc_ecma_codegen/Cargo.toml +++ b/deps/swc/crates/swc_ecma_codegen/Cargo.toml @@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs"] license = { workspace = true } name = "swc_ecma_codegen" repository = { workspace = true } -version = "28.0.1" +version = "28.0.2" [features] # This does not enable serde for ast nodes. @@ -35,7 +35,7 @@ swc_allocator = { version = "4.0.1", path = "../swc_allocator", default-features "hashbrown", ] } swc_atoms = { version = "9.0.3", path = "../swc_atoms" } -swc_common = { version = "23.0.1", path = "../swc_common" } +swc_common = { version = "23.0.2", path = "../swc_common" } swc_ecma_ast = { version = "25.0.0", path = "../swc_ecma_ast" } swc_ecma_codegen_macros = { version = "2.0.2", path = "../swc_ecma_codegen_macros" } @@ -45,13 +45,13 @@ codspeed-criterion-compat = { workspace = true } serde_json = { workspace = true } swc_allocator = { version = "4.0.1", path = "../swc_allocator" } -swc_common = { version = "23.0.1", path = "../swc_common", features = [ +swc_common = { version = "23.0.2", path = "../swc_common", features = [ "sourcemap", ] } -swc_ecma_parser = { version = "41.0.1", path = "../swc_ecma_parser" } -swc_ecma_testing = { version = "24.0.0", path = "../swc_ecma_testing" } +swc_ecma_parser = { version = "41.1.2", path = "../swc_ecma_parser" } +swc_ecma_testing = { version = "24.0.1", path = "../swc_ecma_testing" } swc_malloc = { version = "1.2.5", path = "../swc_malloc" } -testing = { version = "24.0.0", path = "../testing" } +testing = { version = "24.0.1", path = "../testing" } swc_sourcemap = { workspace = true } [[bench]] diff --git a/deps/swc/crates/swc_ecma_codegen/src/lib.rs b/deps/swc/crates/swc_ecma_codegen/src/lib.rs index 0c28d057c..db788f1de 100644 --- a/deps/swc/crates/swc_ecma_codegen/src/lib.rs +++ b/deps/swc/crates/swc_ecma_codegen/src/lib.rs @@ -1482,7 +1482,7 @@ impl MacroNode for Program { #[node_impl] impl MacroNode for Module { - #[tracing::instrument(level = "debug", skip_all)] + #[cfg_attr(debug_assertions, tracing::instrument(level = "debug", skip_all))] fn emit(&mut self, emitter: &mut Macro) -> Result { let should_skip_leading_comments = self.body.iter().any(|s| s.span().lo == self.span.lo); @@ -1517,7 +1517,7 @@ impl MacroNode for Module { #[node_impl] impl MacroNode for Script { - #[tracing::instrument(level = "debug", skip_all)] + #[cfg_attr(debug_assertions, tracing::instrument(level = "debug", skip_all))] fn emit(&mut self, emitter: &mut Macro) -> Result { let should_skip_leading_comments = self.body.iter().any(|s| s.span().lo == self.span.lo); diff --git a/deps/swc/crates/swc_ecma_compat_bugfixes/Cargo.toml b/deps/swc/crates/swc_ecma_compat_bugfixes/Cargo.toml index 7d1f673b9..f5491ebff 100644 --- a/deps/swc/crates/swc_ecma_compat_bugfixes/Cargo.toml +++ b/deps/swc/crates/swc_ecma_compat_bugfixes/Cargo.toml @@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs"] license = { workspace = true } name = "swc_ecma_compat_bugfixes" repository = { workspace = true } -version = "50.0.0" +version = "51.0.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -15,14 +15,13 @@ rustc-hash = { workspace = true } tracing = { workspace = true } swc_atoms = { version = "9.0.3", path = "../swc_atoms" } -swc_common = { version = "23.0.1", path = "../swc_common" } +swc_common = { version = "23.0.2", path = "../swc_common" } swc_ecma_ast = { version = "25.0.0", path = "../swc_ecma_ast" } -swc_ecma_compat_es2015 = { version = "49.0.0", path = "../swc_ecma_compat_es2015" } -swc_ecma_transforms_base = { version = "44.0.2", path = "../swc_ecma_transforms_base" } -swc_ecma_utils = { version = "31.0.0", path = "../swc_ecma_utils" } +swc_ecma_compat_es2015 = { version = "50.0.0", path = "../swc_ecma_compat_es2015" } +swc_ecma_transforms_base = { version = "44.0.3", path = "../swc_ecma_transforms_base" } +swc_ecma_utils = { version = "31.0.1", path = "../swc_ecma_utils" } swc_ecma_visit = { version = "25.0.0", path = "../swc_ecma_visit" } -swc_trace_macro = { version = "2.0.2", path = "../swc_trace_macro" } [dev-dependencies] -swc_ecma_parser = { version = "41.0.1", path = "../swc_ecma_parser" } +swc_ecma_parser = { version = "41.1.2", path = "../swc_ecma_parser" } swc_ecma_transforms_testing = { version = "48.0.0", path = "../swc_ecma_transforms_testing" } diff --git a/deps/swc/crates/swc_ecma_compat_bugfixes/src/async_arrows_in_class.rs b/deps/swc/crates/swc_ecma_compat_bugfixes/src/async_arrows_in_class.rs index 278a44022..58124eb52 100644 --- a/deps/swc/crates/swc_ecma_compat_bugfixes/src/async_arrows_in_class.rs +++ b/deps/swc/crates/swc_ecma_compat_bugfixes/src/async_arrows_in_class.rs @@ -3,7 +3,6 @@ use swc_ecma_ast::*; use swc_ecma_compat_es2015::arrow; use swc_ecma_utils::prepend_stmt; use swc_ecma_visit::{fold_pass, standard_only_fold, Fold, FoldWith, InjectVars, VisitMutWith}; -use swc_trace_macro::swc_trace; /// A bugfix pass for Safari 10.3. /// @@ -26,7 +25,6 @@ struct AsyncArrowsInClass { } /// TODO: VisitMut -#[swc_trace] impl Fold for AsyncArrowsInClass { standard_only_fold!(); diff --git a/deps/swc/crates/swc_ecma_compat_bugfixes/src/edge_default_param.rs b/deps/swc/crates/swc_ecma_compat_bugfixes/src/edge_default_param.rs index 73ff3be97..1bb6e5a00 100644 --- a/deps/swc/crates/swc_ecma_compat_bugfixes/src/edge_default_param.rs +++ b/deps/swc/crates/swc_ecma_compat_bugfixes/src/edge_default_param.rs @@ -1,6 +1,5 @@ use swc_ecma_ast::*; use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, VisitMut, VisitMutWith}; -use swc_trace_macro::swc_trace; /// A bugfix pass for Edge. /// @@ -16,7 +15,6 @@ struct EdgeDefaultParam { in_arrow: bool, } -#[swc_trace] impl VisitMut for EdgeDefaultParam { noop_visit_mut_type!(fail); diff --git a/deps/swc/crates/swc_ecma_compat_bugfixes/src/safari_id_destructuring_collision_in_function_expression.rs b/deps/swc/crates/swc_ecma_compat_bugfixes/src/safari_id_destructuring_collision_in_function_expression.rs index 728022227..ca4d98860 100644 --- a/deps/swc/crates/swc_ecma_compat_bugfixes/src/safari_id_destructuring_collision_in_function_expression.rs +++ b/deps/swc/crates/swc_ecma_compat_bugfixes/src/safari_id_destructuring_collision_in_function_expression.rs @@ -6,7 +6,6 @@ use swc_common::SyntaxContext; use swc_ecma_ast::*; use swc_ecma_transforms_base::hygiene::rename; use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, VisitMut, VisitMutWith}; -use swc_trace_macro::swc_trace; pub fn safari_id_destructuring_collision_in_function_expression() -> impl Pass { visit_mut_pass(SafariIdDestructuringCollisionInFunctionExpression::default()) @@ -30,7 +29,6 @@ impl SafariIdDestructuringCollisionInFunctionExpression { } } -#[swc_trace] impl VisitMut for SafariIdDestructuringCollisionInFunctionExpression { noop_visit_mut_type!(fail); diff --git a/deps/swc/crates/swc_ecma_compat_bugfixes/src/template_literal_caching.rs b/deps/swc/crates/swc_ecma_compat_bugfixes/src/template_literal_caching.rs index 1f5cb6a00..874daffcd 100644 --- a/deps/swc/crates/swc_ecma_compat_bugfixes/src/template_literal_caching.rs +++ b/deps/swc/crates/swc_ecma_compat_bugfixes/src/template_literal_caching.rs @@ -2,7 +2,6 @@ use swc_common::DUMMY_SP; use swc_ecma_ast::*; use swc_ecma_utils::{prepend_stmt, private_ident, ExprFactory}; use swc_ecma_visit::{fold_pass, standard_only_fold, Fold, FoldWith}; -use swc_trace_macro::swc_trace; // Converts destructured parameters with default values to non-shorthand syntax. // This fixes the only Tagged Templates-related bug in ES Modules-supporting @@ -57,7 +56,6 @@ impl TemplateLiteralCaching { } /// TODO: VisitMut -#[swc_trace] impl Fold for TemplateLiteralCaching { standard_only_fold!(); diff --git a/deps/swc/crates/swc_ecma_compat_common/Cargo.toml b/deps/swc/crates/swc_ecma_compat_common/Cargo.toml index b4a72a8e5..e4b675a86 100644 --- a/deps/swc/crates/swc_ecma_compat_common/Cargo.toml +++ b/deps/swc/crates/swc_ecma_compat_common/Cargo.toml @@ -7,12 +7,12 @@ include = ["Cargo.toml", "src/**/*.rs"] license = { workspace = true } name = "swc_ecma_compat_common" repository = { workspace = true } -version = "40.0.0" +version = "40.0.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -swc_common = { version = "23.0.1", path = "../swc_common" } +swc_common = { version = "23.0.2", path = "../swc_common" } swc_ecma_ast = { version = "25.0.0", path = "../swc_ecma_ast" } -swc_ecma_transformer = { version = "16.0.1", path = "../swc_ecma_transformer" } -swc_ecma_utils = { version = "31.0.0", path = "../swc_ecma_utils" } +swc_ecma_transformer = { version = "16.0.3", path = "../swc_ecma_transformer" } +swc_ecma_utils = { version = "31.0.1", path = "../swc_ecma_utils" } diff --git a/deps/swc/crates/swc_ecma_compat_common/src/macros.rs b/deps/swc/crates/swc_ecma_compat_common/src/macros.rs index 749968c62..0ac0b5891 100644 --- a/deps/swc/crates/swc_ecma_compat_common/src/macros.rs +++ b/deps/swc/crates/swc_ecma_compat_common/src/macros.rs @@ -137,6 +137,7 @@ macro_rules! impl_visit_mut_fn { return; } + #[cfg(debug_assertions)] tracing::trace!("visit_mut_constructor(parmas.len() = {})", f.params.len()); f.visit_mut_children_with(self); @@ -155,6 +156,7 @@ macro_rules! impl_visit_mut_fn { let (params, body) = self.visit_mut_fn_like(&mut params, &mut f.body.take().unwrap()); + #[cfg(debug_assertions)] tracing::trace!( "visit_mut_constructor(parmas.len() = {}, after)", params.len() diff --git a/deps/swc/crates/swc_ecma_compat_es2015/Cargo.toml b/deps/swc/crates/swc_ecma_compat_es2015/Cargo.toml index 9780100e1..19bde72f0 100644 --- a/deps/swc/crates/swc_ecma_compat_es2015/Cargo.toml +++ b/deps/swc/crates/swc_ecma_compat_es2015/Cargo.toml @@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs"] license = { workspace = true } name = "swc_ecma_compat_es2015" repository = { workspace = true } -version = "49.0.0" +version = "50.0.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -26,19 +26,18 @@ smallvec = { workspace = true } swc_atoms = { version = "9.0.3", path = "../swc_atoms" } -swc_common = { version = "23.0.1", path = "../swc_common" } +swc_common = { version = "23.0.2", path = "../swc_common" } swc_config = { version = "5.0.0", path = "../swc_config" } swc_ecma_ast = { version = "25.0.0", path = "../swc_ecma_ast" } -swc_ecma_compat_common = { version = "40.0.0", path = "../swc_ecma_compat_common" } -swc_ecma_transformer = { version = "16.0.1", path = "../swc_ecma_transformer" } -swc_ecma_transforms_base = { version = "44.0.2", path = "../swc_ecma_transforms_base" } +swc_ecma_compat_common = { version = "40.0.1", path = "../swc_ecma_compat_common" } +swc_ecma_transformer = { version = "16.0.3", path = "../swc_ecma_transformer" } +swc_ecma_transforms_base = { version = "44.0.3", path = "../swc_ecma_transforms_base" } swc_ecma_transforms_classes = { version = "44.0.0", path = "../swc_ecma_transforms_classes" } swc_ecma_transforms_macros = { version = "1.0.1", path = "../swc_ecma_transforms_macros" } -swc_ecma_utils = { version = "31.0.0", path = "../swc_ecma_utils" } +swc_ecma_utils = { version = "31.0.1", path = "../swc_ecma_utils" } swc_ecma_visit = { version = "25.0.0", path = "../swc_ecma_visit" } -swc_trace_macro = { version = "2.0.2", path = "../swc_trace_macro" } tracing = { workspace = true } [dev-dependencies] -swc_ecma_parser = { version = "41.0.1", path = "../swc_ecma_parser" } +swc_ecma_parser = { version = "41.1.2", path = "../swc_ecma_parser" } swc_ecma_transforms_testing = { version = "48.0.0", path = "../swc_ecma_transforms_testing" } diff --git a/deps/swc/crates/swc_ecma_compat_es2015/src/arrow.rs b/deps/swc/crates/swc_ecma_compat_es2015/src/arrow.rs index a2552e9a3..64072c98e 100644 --- a/deps/swc/crates/swc_ecma_compat_es2015/src/arrow.rs +++ b/deps/swc/crates/swc_ecma_compat_es2015/src/arrow.rs @@ -7,7 +7,6 @@ use swc_ecma_utils::{ prepend_stmt, }; use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, InjectVars, VisitMut, VisitMutWith}; -use swc_trace_macro::swc_trace; /// Compile ES2015 arrow functions to ES5 /// @@ -70,7 +69,6 @@ struct Arrow { hoister: FnEnvHoister, } -#[swc_trace] impl VisitMut for Arrow { noop_visit_mut_type!(fail); diff --git a/deps/swc/crates/swc_ecma_compat_es2015/src/block_scoped_fn.rs b/deps/swc/crates/swc_ecma_compat_es2015/src/block_scoped_fn.rs index c8eaf2b2d..0900a0a0d 100644 --- a/deps/swc/crates/swc_ecma_compat_es2015/src/block_scoped_fn.rs +++ b/deps/swc/crates/swc_ecma_compat_es2015/src/block_scoped_fn.rs @@ -2,7 +2,6 @@ use swc_common::{util::take::Take, DUMMY_SP}; use swc_ecma_ast::*; use swc_ecma_utils::IdentUsageFinder; use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, VisitMut, VisitMutWith}; -use swc_trace_macro::swc_trace; pub fn block_scoped_functions() -> impl Pass { visit_mut_pass(BlockScopedFns) @@ -11,7 +10,6 @@ pub fn block_scoped_functions() -> impl Pass { #[derive(Clone, Copy)] struct BlockScopedFns; -#[swc_trace] impl VisitMut for BlockScopedFns { noop_visit_mut_type!(fail); diff --git a/deps/swc/crates/swc_ecma_compat_es2015/src/block_scoping/mod.rs b/deps/swc/crates/swc_ecma_compat_es2015/src/block_scoping/mod.rs index fbe3de43e..e9bfdcf81 100644 --- a/deps/swc/crates/swc_ecma_compat_es2015/src/block_scoping/mod.rs +++ b/deps/swc/crates/swc_ecma_compat_es2015/src/block_scoping/mod.rs @@ -14,7 +14,6 @@ use swc_ecma_utils::{ use swc_ecma_visit::{ noop_visit_mut_type, visit_mut_obj_and_computed, visit_mut_pass, VisitMut, VisitMutWith, }; -use swc_trace_macro::swc_trace; mod vars; @@ -430,7 +429,6 @@ impl BlockScoping { } } -#[swc_trace] impl VisitMut for BlockScoping { noop_visit_mut_type!(fail); @@ -679,7 +677,6 @@ impl FlowHelper<'_> { } } -#[swc_trace] impl VisitMut for FlowHelper<'_> { noop_visit_mut_type!(fail); @@ -912,7 +909,6 @@ impl MutationHandler<'_> { } } -#[swc_trace] impl VisitMut for MutationHandler<'_> { noop_visit_mut_type!(fail); diff --git a/deps/swc/crates/swc_ecma_compat_es2015/src/block_scoping/vars.rs b/deps/swc/crates/swc_ecma_compat_es2015/src/block_scoping/vars.rs index 54fbc82a8..171754dbb 100644 --- a/deps/swc/crates/swc_ecma_compat_es2015/src/block_scoping/vars.rs +++ b/deps/swc/crates/swc_ecma_compat_es2015/src/block_scoping/vars.rs @@ -5,7 +5,6 @@ use swc_common::{Mark, SyntaxContext}; use swc_ecma_ast::*; use swc_ecma_transforms_base::{rename::rename_with_config, scope::ScopeKind}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith}; -use swc_trace_macro::swc_trace; pub(super) fn block_scoped_vars() -> impl VisitMut { BlockScopedVars::default() @@ -36,7 +35,6 @@ struct ParentScope<'a> { vars: &'a IndexMap, } -#[swc_trace] impl BlockScopedVars { fn add_usage(&mut self, ident: &Ident) { if !self @@ -108,7 +106,6 @@ impl BlockScopedVars { } } -#[swc_trace] impl Scope { fn rename(&mut self, parent: ParentScope, rename_map: &mut FxHashMap, fn_only: bool) { for s in self.children.iter_mut() { @@ -239,7 +236,6 @@ impl ParentScope<'_> { } } -#[swc_trace] impl VisitMut for BlockScopedVars { noop_visit_mut_type!(fail); diff --git a/deps/swc/crates/swc_ecma_compat_es2015/src/classes/constructor.rs b/deps/swc/crates/swc_ecma_compat_es2015/src/classes/constructor.rs index 36be6bd18..5addf99b4 100644 --- a/deps/swc/crates/swc_ecma_compat_es2015/src/classes/constructor.rs +++ b/deps/swc/crates/swc_ecma_compat_es2015/src/classes/constructor.rs @@ -6,7 +6,7 @@ use swc_ecma_transforms_base::{helper, helper_expr}; use swc_ecma_transforms_classes::super_field::SuperFieldAccessFolder; use swc_ecma_utils::{default_constructor_with_span, private_ident, quote_ident, ExprFactory}; use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith}; -use swc_trace_macro::swc_trace; +#[cfg(debug_assertions)] use tracing::debug; use super::Config; @@ -25,6 +25,7 @@ pub(super) fn fold_constructor( // Black magic to detect injected constructor. let is_constructor_default = constructor.span.is_dummy(); if is_constructor_default { + #[cfg(debug_assertions)] debug!("Dropping constructor parameters because the constructor is injected"); constructor.params.take(); } @@ -231,7 +232,6 @@ struct ConstructorFolder { this_ref_count: usize, } -#[swc_trace] impl VisitMut for ConstructorFolder { noop_visit_mut_type!(fail); @@ -420,7 +420,6 @@ impl VisitMut for ConstructorFolder { } } -#[swc_trace] impl ConstructorFolder { fn get_this(&mut self) -> &Ident { self.this_ref_count += 1; diff --git a/deps/swc/crates/swc_ecma_compat_es2015/src/classes/mod.rs b/deps/swc/crates/swc_ecma_compat_es2015/src/classes/mod.rs index d3f23eeab..5bcdeea99 100644 --- a/deps/swc/crates/swc_ecma_compat_es2015/src/classes/mod.rs +++ b/deps/swc/crates/swc_ecma_compat_es2015/src/classes/mod.rs @@ -16,7 +16,6 @@ use swc_ecma_utils::{ use swc_ecma_visit::{ noop_visit_mut_type, noop_visit_type, visit_mut_pass, Visit, VisitMut, VisitMutWith, VisitWith, }; -use swc_trace_macro::swc_trace; use self::{ constructor::fold_constructor, @@ -98,7 +97,6 @@ struct Data { get: Option>, } -#[swc_trace] impl Classes { fn visit_mut_stmt_like(&mut self, stmts: &mut Vec) where @@ -201,7 +199,6 @@ impl Classes { } } -#[swc_trace] #[fast_path(ClassFinder)] impl VisitMut for Classes { noop_visit_mut_type!(fail); @@ -331,7 +328,6 @@ impl VisitMut for Classes { } } -#[swc_trace] impl Classes { fn add_pure_comments(&mut self, start: &mut BytePos) { *start = BytePos::PURE; diff --git a/deps/swc/crates/swc_ecma_compat_es2015/src/computed_props.rs b/deps/swc/crates/swc_ecma_compat_es2015/src/computed_props.rs index c193d973d..974da6514 100644 --- a/deps/swc/crates/swc_ecma_compat_es2015/src/computed_props.rs +++ b/deps/swc/crates/swc_ecma_compat_es2015/src/computed_props.rs @@ -6,7 +6,6 @@ use swc_ecma_utils::{quote_ident, ExprFactory, StmtLike}; use swc_ecma_visit::{ noop_visit_mut_type, noop_visit_type, visit_mut_pass, Visit, VisitMut, VisitMutWith, VisitWith, }; -use swc_trace_macro::swc_trace; /// `@babel/plugin-transform-computed-properties` /// @@ -60,7 +59,6 @@ struct ComputedProps { c: Config, } -#[swc_trace] impl VisitMut for ComputedProps { noop_visit_mut_type!(fail); @@ -368,7 +366,6 @@ impl Visit for ComplexVisitor { } } -#[swc_trace] impl ComputedProps { fn visit_mut_stmt_like(&mut self, stmts: &mut Vec) where diff --git a/deps/swc/crates/swc_ecma_compat_es2015/src/destructuring.rs b/deps/swc/crates/swc_ecma_compat_es2015/src/destructuring.rs index 229cf9d76..53483f65a 100644 --- a/deps/swc/crates/swc_ecma_compat_es2015/src/destructuring.rs +++ b/deps/swc/crates/swc_ecma_compat_es2015/src/destructuring.rs @@ -13,7 +13,6 @@ use swc_ecma_utils::{ use swc_ecma_visit::{ noop_visit_mut_type, noop_visit_type, visit_mut_pass, Visit, VisitMut, VisitMutWith, VisitWith, }; -use swc_trace_macro::swc_trace; /// `@babel/plugin-transform-destructuring` /// @@ -150,7 +149,6 @@ fn make_ref_ident_for_for_stmt() -> Ident { private_ident!("ref") } -#[swc_trace] impl AssignFolder { fn visit_mut_var_decl(&mut self, decls: &mut Vec, decl: VarDeclarator) { match decl.name { @@ -474,7 +472,6 @@ impl AssignFolder { } } -#[swc_trace] #[fast_path(DestructuringVisitor)] impl VisitMut for Destructuring { noop_visit_mut_type!(fail); @@ -494,7 +491,6 @@ impl VisitMut for Destructuring { } } -#[swc_trace] impl Destructuring { fn visit_mut_fn_like( &mut self, @@ -606,7 +602,6 @@ impl AssignFolder { } } -#[swc_trace] #[fast_path(DestructuringVisitor)] impl VisitMut for AssignFolder { noop_visit_mut_type!(fail); @@ -1104,7 +1099,6 @@ impl VisitMut for AssignFolder { } } -#[swc_trace] impl Destructuring { fn visit_mut_stmt_like(&mut self, stmts: &mut Vec) where @@ -1177,7 +1171,7 @@ fn make_ref_ident(c: Config, decls: &mut Vec, init: Option, diff --git a/deps/swc/crates/swc_ecma_compat_es2015/src/for_of.rs b/deps/swc/crates/swc_ecma_compat_es2015/src/for_of.rs index 203569fbf..b0cd36b5b 100644 --- a/deps/swc/crates/swc_ecma_compat_es2015/src/for_of.rs +++ b/deps/swc/crates/swc_ecma_compat_es2015/src/for_of.rs @@ -13,7 +13,6 @@ use swc_ecma_utils::{ alias_if_required, member_expr, prepend_stmt, private_ident, quote_ident, ExprFactory, }; use swc_ecma_visit::{noop_visit_mut_type, visit_mut_pass, VisitMut, VisitMutWith}; -use swc_trace_macro::swc_trace; /// `@babel/plugin-transform-for-of` /// @@ -74,7 +73,6 @@ struct ForOf { top_level_vars: Vec, } -#[swc_trace] impl ForOf { fn fold_for_stmt( &mut self, @@ -569,7 +567,7 @@ impl ForOf { /// } /// } /// ``` -#[tracing::instrument(level = "debug", skip_all)] +#[cfg_attr(debug_assertions, tracing::instrument(level = "debug", skip_all))] fn make_finally_block( iterator_return: Box, normal_completion_ident: &Ident, @@ -656,7 +654,6 @@ impl Parallel for ForOf { } } -#[swc_trace] impl ParExplode for ForOf { fn after_one_stmt(&mut self, stmts: &mut Vec) { // Add variable declaration @@ -693,7 +690,6 @@ impl ParExplode for ForOf { } } -#[swc_trace] #[parallel(explode)] impl VisitMut for ForOf { noop_visit_mut_type!(fail); diff --git a/deps/swc/crates/swc_ecma_compat_es2015/src/generator.rs b/deps/swc/crates/swc_ecma_compat_es2015/src/generator.rs index 26bd31cb8..d3e4dd06f 100644 --- a/deps/swc/crates/swc_ecma_compat_es2015/src/generator.rs +++ b/deps/swc/crates/swc_ecma_compat_es2015/src/generator.rs @@ -19,6 +19,7 @@ use swc_ecma_utils::{ use swc_ecma_visit::{ noop_visit_mut_type, noop_visit_type, visit_mut_pass, Visit, VisitMut, VisitMutWith, VisitWith, }; +#[cfg(debug_assertions)] use tracing::debug; /// Generator based on tsc generator at https://github.com/microsoft/TypeScript/blob/162224763681465b417274383317ca9a0a573835/src/compiler/transformers/generators.ts @@ -38,10 +39,14 @@ struct Wrapper { macro_rules! dev_span { ($($tt:tt)*) => {{ - if cfg!(debug_assertions) { + #[cfg(debug_assertions)] + { Some(tracing::span!(tracing::Level::ERROR, $($tt)*).entered()) - } else { - None + } + + #[cfg(not(debug_assertions))] + { + () } }}; } @@ -1014,7 +1019,7 @@ impl VisitMut for Generator { } } - #[tracing::instrument(level = "debug", skip_all)] + #[cfg_attr(debug_assertions, tracing::instrument(level = "debug", skip_all))] fn visit_mut_stmt(&mut self, node: &mut Stmt) { match node { Stmt::Break(b) => { @@ -1579,6 +1584,7 @@ impl Generator { let mut cnt = 0; while variables_written < var_len { + #[cfg(debug_assertions)] #[cfg(debug_assertions)] debug!("variables_written: {} / {}", variables_written, var_len); @@ -2074,6 +2080,7 @@ impl Generator { let mut pending_clauses = Vec::new(); while clauses_written < node.cases.len() { + #[cfg(debug_assertions)] #[cfg(debug_assertions)] debug!("clauses_written: {}", clauses_written); @@ -2135,6 +2142,7 @@ impl Generator { } fn transform_and_emit_labeled_stmt(&mut self, mut node: LabeledStmt) { + #[cfg(debug_assertions)] #[cfg(debug_assertions)] debug!("transform_and_emit_labeled_stmt: {:?}", node.label); @@ -2263,6 +2271,7 @@ impl Generator { let label = Label(self.next_label_id as _); self.next_label_id += 1; #[cfg(debug_assertions)] + #[cfg(debug_assertions)] debug!("define_label: {:?}", label); if label.0 as usize >= self.label_offsets.as_ref().unwrap().len() { @@ -2289,6 +2298,7 @@ impl Generator { self.label_offsets.as_mut().unwrap()[label.0 as usize] = self.operations.as_deref().map_or(0, |v| v.len() as _); + #[cfg(debug_assertions)] #[cfg(debug_assertions)] debug!( "mark_label: {:?}; offset: {}", @@ -2313,6 +2323,7 @@ impl Generator { #[cfg(debug_assertions)] if cfg!(debug_assertions) { + #[cfg(debug_assertions)] debug!("Begin block {}: {:?}", index, block); } @@ -2336,6 +2347,7 @@ impl Generator { #[cfg(debug_assertions)] let index = self.block_actions.as_ref().unwrap().len(); + #[cfg(debug_assertions)] #[cfg(debug_assertions)] debug!("End block {}", index); @@ -2654,6 +2666,7 @@ impl Generator { /// /// - `label_text`: An optional name of a containing labeled statement. fn find_break_target(&self, label_text: Option) -> Label { + #[cfg(debug_assertions)] #[cfg(debug_assertions)] debug!("find_break_target: label_text={:?}", label_text); @@ -2716,6 +2729,7 @@ impl Generator { fn create_label(&mut self, label: Option