From 55c06554bdde634e3a7e9d608f186824ce4c9192 Mon Sep 17 00:00:00 2001 From: Nathaniel Furniss Date: Tue, 2 Dec 2025 11:24:45 -0800 Subject: [PATCH 1/4] Upgrade swc_core to 46.0.3 --- Cargo.lock | 278 ++++++++++++++++----------------------------- Cargo.toml | 2 +- src/ast_utils.rs | 19 ++-- src/jsx_visitor.rs | 12 +- src/macro_utils.rs | 34 +++--- 5 files changed, 130 insertions(+), 215 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e790a89..923ba20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -50,12 +50,6 @@ version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" -[[package]] -name = "arrayvec" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" - [[package]] name = "ascii" version = "1.1.0" @@ -64,11 +58,10 @@ checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" [[package]] name = "ast_node" -version = "3.0.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fb5864e2f5bf9fd9797b94b2dfd1554d4c3092b535008b27d7e15c86675a2f" +checksum = "c4902c7f39335a2390500ee791d6cb1778e742c7b97952497ec81449a5bfa3a7" dependencies = [ - "proc-macro2", "quote", "swc_macros_common", "syn", @@ -98,9 +91,9 @@ dependencies = [ [[package]] name = "better_scoped_tls" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50fd297a11c709be8348aec039c8b91de16075d2b2bdaee1bd562c0875993664" +checksum = "7cd228125315b132eed175bf47619ac79b945b26e56b848ba203ae4ea8603609" dependencies = [ "scoped-tls", ] @@ -429,11 +422,10 @@ dependencies = [ [[package]] name = "from_variant" -version = "2.0.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d7ccf961415e7aa17ef93dcb6c2441faaa8e768abe09e659b908089546f74c5" +checksum = "308530a56b099da144ebc5d8e179f343ad928fa2b3558d1eb3db9af18d6eff43" dependencies = [ - "proc-macro2", "swc_macros_common", "syn", ] @@ -490,15 +482,15 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hstr" -version = "1.0.0" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71399f53a92ef72ee336a4b30201c6e944827e14e0af23204c291aad9c24cc85" +checksum = "0c43c0a9e8fbdb3bb9dc8eee85e1e2ac81605418b4c83b6b7413cbf14d56ca5c" dependencies = [ "hashbrown 0.14.5", "new_debug_unreachable", "once_cell", - "phf", "rustc-hash", + "serde", "triomphe", ] @@ -736,11 +728,11 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "matchers" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" dependencies = [ - "regex-automata 0.1.10", + "regex-automata", ] [[package]] @@ -802,12 +794,11 @@ checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" [[package]] name = "nu-ansi-term" -version = "0.46.0" +version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "overload", - "winapi", + "windows-sys 0.59.0", ] [[package]] @@ -861,12 +852,6 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a80800c0488c3a21695ea981a54918fbb37abf04f4d0720c453632255e2ff0e" -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - [[package]] name = "owo-colors" version = "4.1.0" @@ -875,23 +860,13 @@ checksum = "fb37767f6569cd834a413442455e0f066d0d522de8630436e2a1761d9726ba56" [[package]] name = "par-core" -version = "1.0.4" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "757892557993c69e82f9de0f9051e87144278aa342f03bf53617bbf044554484" +checksum = "e96cbd21255b7fb29a5d51ef38a779b517a91abd59e2756c039583f43ef4c90f" dependencies = [ "once_cell", ] -[[package]] -name = "par-iter" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a5b20f31e9ba82bfcbbb54a67aa40be6cebec9f668ba5753be138f9523c531a" -dependencies = [ - "either", - "par-core", -] - [[package]] name = "parking_lot" version = "0.12.3" @@ -1073,17 +1048,8 @@ checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.8", - "regex-syntax 0.8.5", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", + "regex-automata", + "regex-syntax", ] [[package]] @@ -1094,15 +1060,9 @@ checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.5", + "regex-syntax", ] -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - [[package]] name = "regex-syntax" version = "0.8.5" @@ -1212,20 +1172,36 @@ dependencies = [ "serde", ] +[[package]] +name = "seq-macro" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc" + [[package]] name = "serde" -version = "1.0.213" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.213" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", @@ -1332,11 +1308,10 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "string_enum" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9fe66b8ee349846ce2f9557a26b8f1e74843c4a13fb381f9a3d73617a5f956a" +checksum = "ae36a4951ca7bd1cfd991c241584a9824a70f6aff1e7d4f693fb3f2465e4030e" dependencies = [ - "proc-macro2", "quote", "swc_macros_common", "syn", @@ -1350,45 +1325,41 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "swc_allocator" -version = "4.0.0" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc6b926f0d94bbb34031fe5449428cfa1268cdc0b31158d6ad9c97e0fc1e79dd" +checksum = "9d7eefd2c8b228a8c73056482b2ae4b3a1071fbe07638e3b55ceca8570cc48bb" dependencies = [ "allocator-api2", "bumpalo", "hashbrown 0.14.5", - "ptr_meta", "rustc-hash", - "triomphe", ] [[package]] name = "swc_atoms" -version = "5.0.0" +version = "8.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d7077ba879f95406459bc0c81f3141c529b34580bc64d7ab7bd15e7118a0391" +checksum = "b40c2b43a19b5d0706aca8669ae5b77b92bd141f7f8ce5e980e0e52430f54b20" dependencies = [ "bytecheck", "hstr", "once_cell", "rancor", "rkyv", - "rustc-hash", "serde", ] [[package]] name = "swc_common" -version = "12.0.1" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd2adffdd9f42af6cfefa16b1aaa8a0984a21854637ef9d89332dd29420d4b23" +checksum = "09e51fecd32bb0989543f0a64f4103cbd728e375838be83d768ce6989f5ea631" dependencies = [ "anyhow", "ast_node", "better_scoped_tls", "bytecheck", "bytes-str", - "cfg-if", "either", "from_variant", "new_debug_unreachable", @@ -1400,7 +1371,6 @@ dependencies = [ "rustc-hash", "serde", "siphasher", - "swc_allocator", "swc_atoms", "swc_eq_ignore_macros", "swc_sourcemap", @@ -1413,11 +1383,10 @@ dependencies = [ [[package]] name = "swc_core" -version = "27.0.6" +version = "46.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b047b6c583f238704fda957aa88d379100216c742a79d4d8f90ef85f0bf5ea38" +checksum = "f062270a2c008b097af0f2f512fb7f6137c3ef26527fcfa7e1477acc7dc78bba" dependencies = [ - "once_cell", "swc_allocator", "swc_atoms", "swc_common", @@ -1436,9 +1405,9 @@ dependencies = [ [[package]] name = "swc_ecma_ast" -version = "12.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82007a7a4fb30198baf82f79244aca929d9845e16fcf897179773e4ebfed20f5" +checksum = "7da8bb0e5aaa6e077f178a28d29bc7da4a8ddaf012b3c21c043cb5f72a0b9779" dependencies = [ "bitflags", "bytecheck", @@ -1449,7 +1418,6 @@ dependencies = [ "rancor", "rkyv", "rustc-hash", - "scoped-tls", "string_enum", "swc_atoms", "swc_common", @@ -1459,9 +1427,9 @@ dependencies = [ [[package]] name = "swc_ecma_codegen" -version = "14.0.0" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af054998dc8a578e8232b94ef046fe06f470b6d8f7f3cbe5c37e7f71dd0e48db" +checksum = "43b756350060f51856d6d1f6ce63183b299d783d9d4458c1ecd6a3d72f4acf7e" dependencies = [ "ascii", "compact_str", @@ -1483,72 +1451,41 @@ dependencies = [ [[package]] name = "swc_ecma_codegen_macros" -version = "2.0.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e99e1931669a67c83e2c2b4375674f6901d1480994a76aa75b23f1389e6c5076" +checksum = "e276dc62c0a2625a560397827989c82a93fd545fcf6f7faec0935a82cc4ddbb8" dependencies = [ "proc-macro2", - "quote", "swc_macros_common", "syn", ] -[[package]] -name = "swc_ecma_lexer" -version = "15.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0e1f330dc2c4b381232b00f32b5de2c7178e2cdb5249f4c41ec9e13d45c66a5" -dependencies = [ - "arrayvec", - "bitflags", - "either", - "new_debug_unreachable", - "num-bigint", - "num-traits", - "phf", - "rustc-hash", - "serde", - "smallvec", - "smartstring", - "stacker", - "swc_atoms", - "swc_common", - "swc_ecma_ast", - "tracing", - "typed-arena", -] - [[package]] name = "swc_ecma_parser" -version = "15.0.2" +version = "26.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f78a70fc7b448889412e42a730f1e34f2850b1fd49af424e39248135ada747b" +checksum = "6ac3281dd9eef03b877fe9cef75a4c8951ce6df0c5f381868f302ee3c58fa6e2" dependencies = [ - "arrayvec", "bitflags", "either", - "new_debug_unreachable", "num-bigint", - "num-traits", "phf", "rustc-hash", + "seq-macro", "serde", - "smallvec", "smartstring", "stacker", "swc_atoms", "swc_common", "swc_ecma_ast", - "swc_ecma_lexer", "tracing", - "typed-arena", ] [[package]] name = "swc_ecma_testing" -version = "13.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07366b063e9ae158868ff28a867ff6e295dc373bc2eb3b704070041baf968f0a" +checksum = "26ba3446b9060debb0aa7f722b9bcdaf7865f88a91ab1e77f3b35f11f7935d3a" dependencies = [ "anyhow", "hex", @@ -1559,19 +1496,17 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_base" -version = "16.0.0" +version = "29.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47c511aff4fabb634c1799a6d6fa2a5057a4f0f482e097e31aeb43939b0ad601" +checksum = "0e757ebf73dcab085bed9d1290bbe387c4cf889e21e105b4f480cbafac865ed9" dependencies = [ "better_scoped_tls", - "bitflags", "indexmap", "once_cell", "par-core", "phf", "rustc-hash", "serde", - "smallvec", "swc_atoms", "swc_common", "swc_ecma_ast", @@ -1583,9 +1518,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_testing" -version = "19.0.0" +version = "32.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e2f31fd1f0f220445f432038fc9592c8df3bb5e9e63f921e38de1077dc942e1" +checksum = "43c95e674bc46c27db53aaa9b293fcfdb10b65a0fe02d33be1106ea6d0ad3b1e" dependencies = [ "ansi_term", "anyhow", @@ -1594,7 +1529,6 @@ dependencies = [ "serde", "serde_json", "sha2", - "swc_allocator", "swc_common", "swc_ecma_ast", "swc_ecma_codegen", @@ -1610,15 +1544,14 @@ dependencies = [ [[package]] name = "swc_ecma_utils" -version = "16.0.0" +version = "23.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a8afc858d9cd7aa2b480d55174ff9c7ee02de003ac5f9e140398206af566b0f" +checksum = "6c17da9ae2d3ad51e865bb27aa97f68b89441ef0b6ee1ba507913c412303c9b7" dependencies = [ "indexmap", "num_cpus", "once_cell", "par-core", - "par-iter", "rustc-hash", "ryu-js", "swc_atoms", @@ -1626,14 +1559,13 @@ dependencies = [ "swc_ecma_ast", "swc_ecma_visit", "tracing", - "unicode-id", ] [[package]] name = "swc_ecma_visit" -version = "12.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0698960f28169c5eaa01127273aca31999bbbb6b1d3f2576ee5400daaa295d0a" +checksum = "d6e6fea33cf8e654d46998cb65bf2915d3dbaab869a25f0ae2c70a86f1e7c2a4" dependencies = [ "new_debug_unreachable", "num-bigint", @@ -1646,9 +1578,9 @@ dependencies = [ [[package]] name = "swc_eq_ignore_macros" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96e15288bf385ab85eb83cff7f9e2d834348da58d0a31b33bdb572e66ee413e" +checksum = "c16ce73424a6316e95e09065ba6a207eba7765496fed113702278b7711d4b632" dependencies = [ "proc-macro2", "quote", @@ -1657,25 +1589,22 @@ dependencies = [ [[package]] name = "swc_error_reporters" -version = "14.0.0" +version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "863dea960d5c8646125462d5b283b03a8b709879729c6713c14e413b0c7a3f8f" +checksum = "f8457a012c93109582b926c97716ff4408923bd54690a8b1fd6b138b1b6334cd" dependencies = [ "anyhow", "miette", "once_cell", - "parking_lot", "serde", - "serde_derive", - "serde_json", "swc_common", ] [[package]] name = "swc_macros_common" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a509f56fca05b39ba6c15f3e58636c3924c78347d63853632ed2ffcb6f5a0ac7" +checksum = "aae1efbaa74943dc5ad2a2fb16cbd78b77d7e4d63188f3c5b4df2b4dcd2faaae" dependencies = [ "proc-macro2", "quote", @@ -1684,9 +1613,9 @@ dependencies = [ [[package]] name = "swc_plugin" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b45099a38ed45528bef939d0eac1a0c1347749d0c67d3dd744d545316c5fd05" +checksum = "92b27449420554de6ad8d49004ad3d36e6ac64ecb51d1b0fe1002afcd7a45d85" dependencies = [ "once_cell", ] @@ -1704,9 +1633,9 @@ dependencies = [ [[package]] name = "swc_plugin_proxy" -version = "12.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e55c2e46b9cc32e206a6f041621468717bbc5748d3321f2e99648340843d16ce" +checksum = "5aa8c82358eebd41d96ffe6f9e8d8ebb77218e1e44ec9bd5b9d986a060ae896e" dependencies = [ "better_scoped_tls", "bytecheck", @@ -1750,23 +1679,21 @@ dependencies = [ [[package]] name = "swc_transform_common" -version = "6.0.0" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d2564e80c5c664914f327640288f5637b0f0acf6a340b92e0082655e558f51" +checksum = "ac052dc4f163680187023eaad6737cfeec2f7b69ac063bb004b3a4cc52407924" dependencies = [ "better_scoped_tls", - "once_cell", "rustc-hash", "serde", - "serde_json", "swc_common", ] [[package]] name = "swc_visit" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9138b6a36bbe76dd6753c4c0794f7e26480ea757bee499738bedbbb3ae3ec5f3" +checksum = "62fb71484b486c185e34d2172f0eabe7f4722742aad700f426a494bb2de232a2" dependencies = [ "either", "new_debug_unreachable", @@ -1824,11 +1751,10 @@ dependencies = [ [[package]] name = "testing" -version = "13.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6995a7c9eaf999e15d3c367e6d8443323c35965a424beb224cdb98dd6a35af83" +checksum = "e6071e9f3c50d975c85e606f2cc37c3a3ccff34cafc065f412fe7e04b94ae944" dependencies = [ - "ansi_term", "cargo_metadata", "difference", "once_cell", @@ -1846,9 +1772,9 @@ dependencies = [ [[package]] name = "testing_macros" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2d27bf245b90a80d5aa231133418ae7db98f032855ce5292e12071ab29c4b26" +checksum = "b7442bd3ca09f38d4788dc5ebafbc1967c3717726b4b074db011d470b353548b" dependencies = [ "anyhow", "glob", @@ -1928,9 +1854,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "2d15d90a0b5c19378952d479dc858407149d7bb45a14de0142f6c534b16fc647" dependencies = [ "pin-project-lite", "tracing-attributes", @@ -1939,9 +1865,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.27" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", @@ -1950,9 +1876,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "7a04e24fab5c89c6a36eb8558c9656f30d81de51dfa4d3b45f26b21d61fa0a6c" dependencies = [ "once_cell", "valuable", @@ -1971,14 +1897,14 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.18" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" dependencies = [ "matchers", "nu-ansi-term", "once_cell", - "regex", + "regex-automata", "sharded-slab", "smallvec", "thread_local", @@ -1997,24 +1923,12 @@ dependencies = [ "stable_deref_trait", ] -[[package]] -name = "typed-arena" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" - [[package]] name = "typenum" version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" -[[package]] -name = "unicode-id" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10103c57044730945224467c09f71a4db0071c123a0648cc3e818913bde6b561" - [[package]] name = "unicode-id-start" version = "1.3.1" diff --git a/Cargo.toml b/Cargo.toml index f41b33a..6f77bc5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ serde = "1.0.207" serde_json = "1.0.125" regex = "1.10.6" once_cell = "1.19.0" -swc_core = { version = "27.0.6", features = [ +swc_core = { version = "46.0.3", features = [ "ecma_plugin_transform", "ecma_utils", "ecma_visit", diff --git a/src/ast_utils.rs b/src/ast_utils.rs index c8673e5..bf850d3 100644 --- a/src/ast_utils.rs +++ b/src/ast_utils.rs @@ -44,7 +44,7 @@ pub fn get_local_ident_from_object_pat_prop( pub fn get_jsx_attr_value_as_string(val: &JSXAttrValue) -> Option { match val { // offset="5" - JSXAttrValue::Lit(Lit::Str(Str { value, .. })) => Some(value.to_string()), + JSXAttrValue::Str(Str { value, .. }) => Some(value.to_string_lossy().into_owned()), // offset={..} JSXAttrValue::JSXExprContainer(JSXExprContainer { expr: JSXExpr::Expr(expr), @@ -52,7 +52,9 @@ pub fn get_jsx_attr_value_as_string(val: &JSXAttrValue) -> Option { }) => { match expr.as_ref() { // offset={"5"} - Expr::Lit(Lit::Str(Str { value, .. })) => Some(value.to_string()), + Expr::Lit(Lit::Str(Str { value, .. })) => { + Some(value.to_string_lossy().into_owned()) + } // offset={5} Expr::Lit(Lit::Num(Number { value, .. })) => Some(value.to_string()), _ => None, @@ -65,7 +67,7 @@ pub fn get_jsx_attr_value_as_string(val: &JSXAttrValue) -> Option { pub fn get_expr_as_string(val: &Expr) -> Option { match val { // "Hello" - Expr::Lit(Lit::Str(Str { value, .. })) => Some(value.to_string()), + Expr::Lit(Lit::Str(Str { value, .. })) => Some(value.to_string_lossy().into_owned()), // `Hello` Expr::Tpl(Tpl { quasis, .. }) => { @@ -136,14 +138,15 @@ pub fn get_object_prop<'a>(props: &'a [PropOrSpread], name: &str) -> Option<&'a .filter_map(|prop_or_spread| to_key_value_prop(prop_or_spread)) .find(|prop| { get_prop_key(prop) - .and_then(|key| if key == name { Some(key) } else { None }) - .is_some() + .map(|key| key.as_str() == name) + .unwrap_or(false) }) } -pub fn get_prop_key(prop: &KeyValueProp) -> Option<&Atom> { +pub fn get_prop_key(prop: &KeyValueProp) -> Option { match &prop.key { - PropName::Ident(IdentName { sym, .. }) | PropName::Str(Str { value: sym, .. }) => Some(sym), + PropName::Ident(IdentName { sym, .. }) => Some(sym.clone()), + PropName::Str(Str { value, .. }) => Some(value.to_string_lossy().into_owned().into()), _ => None, } } @@ -178,7 +181,7 @@ pub fn create_import(source: Atom, imported: IdentName, local: IdentName) -> Mod })], src: Box::new(Str { span: DUMMY_SP, - value: source, + value: source.to_string().into(), raw: None, }), with: None, diff --git a/src/jsx_visitor.rs b/src/jsx_visitor.rs index 641e828..8e279a9 100644 --- a/src/jsx_visitor.rs +++ b/src/jsx_visitor.rs @@ -110,8 +110,8 @@ impl TransJSXVisitor<'_> { match attr_value { // some="# books" - JSXAttrValue::Lit(Lit::Str(str)) => { - let string: String = str.value.clone().to_string(); + JSXAttrValue::Str(str) => { + let string: String = str.value.to_string_lossy().into_owned(); tokens.push(MsgToken::String(string)); } @@ -121,8 +121,9 @@ impl TransJSXVisitor<'_> { }) => { match exp.as_ref() { // some={"# books"} - Expr::Lit(Lit::Str(str)) => tokens - .push(MsgToken::String(str.value.clone().to_string())), + Expr::Lit(Lit::Str(str)) => tokens.push(MsgToken::String( + str.value.to_string_lossy().into_owned(), + )), // some={`# books ${name}`} Expr::Tpl(tpl) => { tokens.extend(self.ctx.tokenize_tpl(tpl)); @@ -220,7 +221,8 @@ impl Visit for TransJSXVisitor<'_> { if let JSXExpr::Expr(exp) = &cont.expr { match exp.as_ref() { Expr::Lit(Lit::Str(str)) => { - self.tokens.push(MsgToken::String(str.value.to_string())); + self.tokens + .push(MsgToken::String(str.value.to_string_lossy().into_owned())); } // todo write tests and validate diff --git a/src/macro_utils.rs b/src/macro_utils.rs index 6db76fb..e96f057 100644 --- a/src/macro_utils.rs +++ b/src/macro_utils.rs @@ -61,8 +61,9 @@ impl MacroCtx { /// is given ident exported from @lingui/macro? pub fn is_lingui_ident(&self, name: &str, ident: &Ident) -> bool { + let name_atom: Atom = name.into(); self.symbol_to_id_map - .get(&name.into()) + .get(&name_atom) .and_then(|refs| refs.get(&ident.to_id())) .is_some() } @@ -132,13 +133,12 @@ impl MacroCtx { let mut tokens: Vec = Vec::with_capacity(tpl.quasis.len()); for (i, tpl_element) in tpl.quasis.iter().enumerate() { - tokens.push(MsgToken::String( - tpl_element - .cooked - .as_ref() - .unwrap_or(&tpl_element.raw) - .to_string(), - )); + let value = tpl_element + .cooked + .as_ref() + .map(|c| c.to_string_lossy().into_owned()) + .unwrap_or_else(|| tpl_element.raw.to_string()); + tokens.push(MsgToken::String(value)); if let Some(exp) = tpl.exprs.get(i) { if let Expr::Call(call) = exp.as_ref() { @@ -209,7 +209,9 @@ impl MacroCtx { pub fn try_tokenize_expr(&self, expr: &Expr) -> Option> { match expr { // String Literal: "has # friend" - Expr::Lit(Lit::Str(str)) => Some(vec![MsgToken::String(str.clone().value.to_string())]), + Expr::Lit(Lit::Str(str)) => Some(vec![MsgToken::String( + str.value.to_string_lossy().into_owned(), + )]), // Template Literal: `${name} has # friend` Expr::Tpl(tpl) => Some(self.tokenize_tpl(tpl)), @@ -227,18 +229,12 @@ impl MacroCtx { pub fn get_js_choice_case_key(&self, prop: &KeyValueProp) -> Option { match &prop.key { // {one: ""} - PropName::Ident(IdentName { sym, .. }) + PropName::Ident(IdentName { sym, .. }) => Some(sym.clone()), // {"one": ""} - | PropName::Str(Str { value: sym, .. }) => { - Some(sym.clone()) - } + PropName::Str(Str { value, .. }) => Some(value.to_string_lossy().into_owned().into()), // {0: ""} -> `={number}` - PropName::Num(Number { value, .. }) => { - Some(format!("={value}").into()) - } - _ => { - None - } + PropName::Num(Number { value, .. }) => Some(format!("={value}").into()), + _ => None, } } From d40927d6f6a603cc7fb26ea3b701c65c62d2e00d Mon Sep 17 00:00:00 2001 From: Nathaniel Furniss Date: Wed, 3 Dec 2025 13:26:37 -0800 Subject: [PATCH 2/4] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0b64d87..1135842 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ Below is a table referencing the swc_core version used during the plugin build, | `5.4.0` | [`14.1.0`](https://plugins.swc.rs/versions/range/138) | | `5.5.0` ~ `5.5.2` | [`15.0.1`](https://plugins.swc.rs/versions/range/271) | | `5.6.0` ~ `5.6.1` | [`27.0.6`](https://plugins.swc.rs/versions/range/364) | +| `5.7.0` | [`46.0.3`](https://plugins.swc.rs/versions/range/713)| > **Note** From c223e58c1b39770c5584684ba8908a9a7bff3958 Mon Sep 17 00:00:00 2001 From: Andrii Bodnar Date: Fri, 5 Dec 2025 11:22:04 +0200 Subject: [PATCH 3/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1135842..43d3e3a 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ Below is a table referencing the swc_core version used during the plugin build, | `5.4.0` | [`14.1.0`](https://plugins.swc.rs/versions/range/138) | | `5.5.0` ~ `5.5.2` | [`15.0.1`](https://plugins.swc.rs/versions/range/271) | | `5.6.0` ~ `5.6.1` | [`27.0.6`](https://plugins.swc.rs/versions/range/364) | -| `5.7.0` | [`46.0.3`](https://plugins.swc.rs/versions/range/713)| +| `5.7.0` | [`46.0.3`](https://plugins.swc.rs/versions/range/713) | > **Note** From 62b86e1c531251f20a4c8cfbc0777fcba10bc9e1 Mon Sep 17 00:00:00 2001 From: Andrii Bodnar Date: Mon, 8 Dec 2025 11:58:24 +0200 Subject: [PATCH 4/4] Apply suggestions from code review --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 923ba20..c44d5ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -687,7 +687,7 @@ checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "lingui_macro_plugin" -version = "5.6.1" +version = "5.8.0" dependencies = [ "data-encoding", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index 6f77bc5..7e53672 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lingui_macro_plugin" -version = "5.6.1" +version = "5.8.0" edition = "2021" [lib]