diff --git a/Cargo.lock b/Cargo.lock index a06a3a5..c8e25b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,21 +12,6 @@ dependencies = [ "regex", ] -[[package]] -name = "addr2line" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "ahash" version = "0.7.8" @@ -110,21 +95,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" -[[package]] -name = "backtrace" -version = "0.3.73" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - [[package]] name = "base64" version = "0.21.7" @@ -325,6 +295,20 @@ dependencies = [ "parking_lot_core", ] +[[package]] +name = "dashmap" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "804c8821570c3f8b70230c2ba75ffa5c0f9a4189b9a432b6656c536712acae28" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", +] + [[package]] name = "data-encoding" version = "2.6.0" @@ -449,12 +433,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "gimli" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" - [[package]] name = "glob" version = "0.3.1" @@ -669,12 +647,6 @@ dependencies = [ "syn 2.0.66", ] -[[package]] -name = "is_ci" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45" - [[package]] name = "itoa" version = "1.0.11" @@ -738,19 +710,13 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "miette" -version = "4.7.1" +version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c90329e44f9208b55f45711f9558cec15d7ef8295cc65ecd6d4188ae8edc58c" +checksum = "4edc8853320c2a0dab800fbda86253c8938f6ea88510dc92c5f1ed20e794afc1" dependencies = [ - "atty", - "backtrace", + "cfg-if", "miette-derive", - "once_cell", "owo-colors", - "supports-color", - "supports-hyperlinks", - "supports-unicode", - "terminal_size", "textwrap", "thiserror", "unicode-width", @@ -758,22 +724,13 @@ dependencies = [ [[package]] name = "miette-derive" -version = "4.7.1" +version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b5bc45b761bcf1b5e6e6c4128cd93b84c218721a8d9b894aa0aff4ed180174c" +checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", -] - -[[package]] -name = "miniz_oxide" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" -dependencies = [ - "adler", + "syn 2.0.66", ] [[package]] @@ -840,15 +797,6 @@ dependencies = [ "libc", ] -[[package]] -name = "object" -version = "0.36.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" version = "1.19.0" @@ -869,9 +817,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "owo-colors" -version = "3.5.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" +checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" [[package]] name = "parking_lot" @@ -1157,12 +1105,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "rustc-demangle" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" - [[package]] name = "rustc-hash" version = "1.1.0" @@ -1253,18 +1195,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", @@ -1413,40 +1355,12 @@ dependencies = [ "syn 2.0.66", ] -[[package]] -name = "supports-color" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ba6faf2ca7ee42fdd458f4347ae0a9bd6bcc445ad7cb57ad82b383f18870d6f" -dependencies = [ - "atty", - "is_ci", -] - -[[package]] -name = "supports-hyperlinks" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "590b34f7c5f01ecc9d78dba4b3f445f31df750a67621cf31626f3b7441ce6406" -dependencies = [ - "atty", -] - -[[package]] -name = "supports-unicode" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8b945e45b417b125a8ec51f1b7df2f8df7920367700d1f98aedd21e5735f8b2" -dependencies = [ - "atty", -] - [[package]] name = "swc-plugin-inferno" -version = "0.0.21" +version = "0.0.22" dependencies = [ "base64 0.22.1", - "dashmap", + "dashmap 6.0.1", "indexmap", "once_cell", "rayon", @@ -1485,7 +1399,7 @@ checksum = "83406221c501860fce9c27444f44125eafe9e598b8b81be7563d7036784cd05c" dependencies = [ "ahash 0.8.11", "anyhow", - "dashmap", + "dashmap 5.5.3", "once_cell", "regex", "serde", @@ -1493,9 +1407,9 @@ dependencies = [ [[package]] name = "swc_common" -version = "0.34.1" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0a5e455ba23fcd687b05ee944ea2c4b026f7de6bb648be3061a434509963e2" +checksum = "dcad76737c09d8cafdd6cc0bcb5d57a49340fde34cf9357b9bd30e3e25976fbb" dependencies = [ "anyhow", "ast_node", @@ -1551,9 +1465,9 @@ dependencies = [ [[package]] name = "swc_core" -version = "0.95.2" +version = "0.97.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d98a9010ece859955625a9c1a54ac60986063d755acd8e1fd3a6d7a7e96bce1" +checksum = "f382c4167ad363df090ae6cdea5a5b2b4d6e172d485b1e229632e6b83ec3a585" dependencies = [ "once_cell", "swc_atoms", @@ -1571,9 +1485,9 @@ dependencies = [ [[package]] name = "swc_ecma_ast" -version = "0.115.0" +version = "0.116.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065b55c4d3bf7994a47abd420b9d69c69dd48e602030cbc85557077d5705fb63" +checksum = "55ea1ec136cc269287c32be8edc06080e8e6cca86f0592a23ba99eed0ecf3ffd" dependencies = [ "bitflags", "bytecheck", @@ -1590,9 +1504,9 @@ dependencies = [ [[package]] name = "swc_ecma_codegen" -version = "0.151.0" +version = "0.152.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc6602bcf4fd78b2ef0c7b2abcdbd3e35dfa564a6bcfb0f256e86b41ff3299d7" +checksum = "84bbb1ae51db45adf2e24c6417e16ffbe4332023155f4ca055ece227d1798a72" dependencies = [ "memchr", "num-bigint", @@ -1621,9 +1535,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_bugfixes" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f8e8697555cf32b8dd18c62637ce804c8c96343a6752d622e12e84fd0cea336" +checksum = "4504f58f58c5806df2609f07736526a32da3c81e657e7231dbae8f6214f01baa" dependencies = [ "swc_atoms", "swc_common", @@ -1638,9 +1552,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_common" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d2f791e974b5dd20a72c50aaf5507a07c6b7c2778711a4b8f62b881b92035b1" +checksum = "4c9ac5837d8f763f1dade90afaecc20e22e543bdbdcecfce8501fceb35913daf" dependencies = [ "swc_common", "swc_ecma_ast", @@ -1651,9 +1565,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2015" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0514f6652e4bdb327df10c7a577346fa1f2bea5a416360f12763e4bb15d1794" +checksum = "39ab0c57ed3ffde27abe84f5c940fc01446913056171e069c88ea1e99cbd53b4" dependencies = [ "arrayvec", "indexmap", @@ -1677,9 +1591,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2016" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4a58e0626e1d6f156b6c30a596fcaddf99d7fd2826fed118ee848a6b8339d32" +checksum = "c8d125c3b1cf2298497c33da736946bb5c96767dc892c14c8105b18b784b383b" dependencies = [ "swc_atoms", "swc_common", @@ -1694,9 +1608,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2017" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e11928d0da6babf2632d9b1580bb5f476f251c3c5a5ce9ceb9f650e4ee5b38fe" +checksum = "29220224361bee3be154d28263ce758a2c780da73154c37ce2faea6b8398ec5c" dependencies = [ "serde", "swc_atoms", @@ -1712,9 +1626,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2018" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaee1dbdf5d65fe8149c51298c2065bf94e4b32b922c487deeda3f9033e246d6" +checksum = "94529aea2ad2ed3c1823df039e3a663059b57b4ca1a870f5d1346961ebfe25ef" dependencies = [ "serde", "swc_atoms", @@ -1731,9 +1645,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2019" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2243e1b427495d787fc06966b60ba61e194bcd46646c7ee95a0481674a44f353" +checksum = "38eb70eadebadea19fbea565a629992bbd715a53ef4947bd54c51de4cbb8b668" dependencies = [ "swc_atoms", "swc_common", @@ -1747,9 +1661,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2020" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e791d25641ba974d01a1f6f8795244ccb7cb16e916f91b51d72609db6cd94cf3" +checksum = "2d36765e639d8d56a376f591b15fca7dee0c9e6d37ad33845b0ce8f356b24f2f" dependencies = [ "serde", "swc_atoms", @@ -1765,9 +1679,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2021" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "529b0368f8ada330a928ecf82c6c480eefd51cacd2d6e9f3bdedf9187782f0da" +checksum = "e918c74bf2fc267af07c5bacf7913fec5027be85c4051139719e83a6178d5214" dependencies = [ "swc_atoms", "swc_common", @@ -1781,9 +1695,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es2022" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fb64c1ee316e05823b6b698d44017848241626f1e11eaf394a642bc99d4d4cd" +checksum = "29ecb003c73ae936b19689ebf395fb472de193ee9c446255d4993b5d79205f44" dependencies = [ "swc_atoms", "swc_common", @@ -1800,9 +1714,9 @@ dependencies = [ [[package]] name = "swc_ecma_compat_es3" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de9acee5e6867cb91460a48a2cc0900db01fdd90112cdd4c74defc7dcd4577" +checksum = "9602851683999491f784e85637f42637ad423731f92b0fcaf35c92e87e8cf1d0" dependencies = [ "swc_common", "swc_ecma_ast", @@ -1815,12 +1729,12 @@ dependencies = [ [[package]] name = "swc_ecma_loader" -version = "0.46.0" +version = "0.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de65ea1e3f6fe8d62121eb5889ef98ca41b04425df85cd1a3b81637057a2b035" +checksum = "be0c947f8dd1acf8ae93a0577ef0137b002de56107504a320b4f58f2ca4673de" dependencies = [ "anyhow", - "dashmap", + "dashmap 5.5.3", "normpath", "once_cell", "path-clean", @@ -1834,9 +1748,9 @@ dependencies = [ [[package]] name = "swc_ecma_parser" -version = "0.146.1" +version = "0.147.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f884c766155c58b98503961612d1caced9d50267fcbf7914d9407d6fc5447efe" +checksum = "3f85ae931e009c314f88212bd53d84ee9244902e84afa5ede497cb8a763192de" dependencies = [ "either", "new_debug_unreachable", @@ -1856,9 +1770,9 @@ dependencies = [ [[package]] name = "swc_ecma_testing" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f495dae76f1ef3f5be46993b050c3c7f9bf534bcdacf1e40789d32255040776" +checksum = "d9cd4048325823f5ad49b258e8ed416762f0f91224a54292e965bb27fa889691" dependencies = [ "anyhow", "hex", @@ -1869,9 +1783,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms" -version = "0.232.0" +version = "0.233.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e8e66bc10715c10219239772abd2f6be99eda573e69e5abb8646b1f3fce83dc" +checksum = "19259852636b8b4e99d8a85c3970d388b595b507e4f9b3d233d15e006b41bc69" dependencies = [ "swc_atoms", "swc_common", @@ -1883,9 +1797,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_base" -version = "0.140.0" +version = "0.141.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daee7af0abfccc9855656fc36ac472e1e6a61398a3a1a1b3bf05ef7a7e7af6b0" +checksum = "6aa78df903a639ac03fbd2acd963e0d8b74a237f939699d5a7c9a12c0a92d755" dependencies = [ "better_scoped_tls", "bitflags", @@ -1906,9 +1820,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_classes" -version = "0.129.0" +version = "0.130.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3eab5f8179e5b0aedf385eacc2c033691c6d211a7babd1bbbff12cf794a824e" +checksum = "337bd90a98a2889e531d608dccd72aa58003ff89cf6a79afb55f45ea05ef2d7a" dependencies = [ "swc_atoms", "swc_common", @@ -1920,9 +1834,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_compat" -version = "0.166.0" +version = "0.167.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e03c5afd68b80591a3871ac3692f3adaf281c0c3c686db51a73ed91270d6f4c" +checksum = "7b15b38a4f76a157d40ccd7d55b51bcdaf6c7fe90151ff9186e5d80cc6865adc" dependencies = [ "arrayvec", "indexmap", @@ -1968,9 +1882,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_module" -version = "0.183.0" +version = "0.184.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f814b5dacf9b37d3e2df900cef6f00471e78ad73dc595b427ca34fb74543e1d" +checksum = "9822e947a81449ba6dc6f3709bfbdfc0c3411417415e4f886e4191141fbb6966" dependencies = [ "Inflector", "anyhow", @@ -1995,9 +1909,9 @@ dependencies = [ [[package]] name = "swc_ecma_transforms_testing" -version = "0.143.0" +version = "0.144.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2622a94000bb4e04548afe0540150f616c58296d5485c0653d1fae69c23efd98" +checksum = "de98001f39c3ee2227ec1461339a49b68188fc3e617a1fbf149810c3f3f1c858" dependencies = [ "ansi_term", "anyhow", @@ -2021,9 +1935,9 @@ dependencies = [ [[package]] name = "swc_ecma_utils" -version = "0.130.0" +version = "0.131.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "831490c6d4a52f06932fa2c3d87fc0d0aa43211a5df6b5e05a1ec2c57a2f2519" +checksum = "37cd4c3feffadeb7df66104eaa99a1cd283467976e17d640216d38a5094ca179" dependencies = [ "indexmap", "num_cpus", @@ -2040,10 +1954,11 @@ dependencies = [ [[package]] name = "swc_ecma_visit" -version = "0.101.0" +version = "0.102.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce0d997f0c9b4e181225f603d161f6757c2a97022258170982cfe005ec69ec92" +checksum = "c2332919b1de15ca7d9648f95bad1f1b61947be4dfff58ee030dac95f89c2fa6" dependencies = [ + "new_debug_unreachable", "num-bigint", "swc_atoms", "swc_common", @@ -2065,9 +1980,9 @@ dependencies = [ [[package]] name = "swc_error_reporters" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd8f9a90efb59dc5d918b4470e5d152f34cac2f8733bfba141a96440cab3eff" +checksum = "25b661d78ba19637923413c3595950c3c5fc3cbae7e15bdbaa1c8e114f6b815e" dependencies = [ "anyhow", "miette", @@ -2109,9 +2024,9 @@ dependencies = [ [[package]] name = "swc_plugin_proxy" -version = "0.44.0" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98740e5a1ac82ad0de823bcf4aea97a76dce77c1ccff167d148e8a114b2932c0" +checksum = "ea82aae92e65e810160e86ba17c7a88d50810ae3bea64b4696af80239f93f70e" dependencies = [ "better_scoped_tls", "rkyv", @@ -2215,21 +2130,11 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "terminal_size" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "testing" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27d395aa823f3ad1ad845ed74b96188f493b469794cfbe9ef82f03196064086f" +checksum = "8a3c2661c39447b466b77a8c8506473cf7d18c234bbe95375b3fdd2bf86c0c75" dependencies = [ "ansi_term", "cargo_metadata 0.15.4", @@ -2264,9 +2169,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.15.2" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b3e525a49ec206798b40326a44121291b530c963cfb01018f63e135bac543d" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" dependencies = [ "smawk", "unicode-linebreak", @@ -2419,9 +2324,9 @@ checksum = "b1b6def86329695390197b82c1e244a54a131ceb66c996f2088a3876e2ae083f" [[package]] name = "unicode-id-start" -version = "1.0.4" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02aebfa694eccbbbffdd92922c7de136b9fe764396d2f10e21bce1681477cfc1" +checksum = "bc3882f69607a2ac8cc4de3ee7993d8f68bb06f2974271195065b3bd07f2edea" [[package]] name = "unicode-ident" diff --git a/Cargo.toml b/Cargo.toml index 25e66df..b4dbe18 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs"] license = "MIT" name = "swc-plugin-inferno" repository = "https://github.com/infernojs/swc-plugin-inferno.git" -version = "0.0.21" +version = "0.0.22" [lib] crate-type = ["cdylib", "rlib"] @@ -24,22 +24,20 @@ codegen-units = 1 lto = true # Optimize for size opt-level = "s" -# Optimize for performance, this is default, so you don't need to specify it -# opt-level = "z" # Strip debug symbols strip = "symbols" [dependencies] base64 = "0.22.1" -dashmap = "5.5.3" +dashmap = "6.0.1" indexmap = "2.2.6" once_cell = "1.19.0" rayon = { version = "1.10.0", optional = true } -serde = { version = "1.0.203", features = ["derive"], optional = true } +serde = { version = "1.0.204", features = ["derive"], optional = true } sha-1 = "=0.10.1" -swc_core = { version = "0.95.2", features = [ +swc_core = { version = "0.97.2", features = [ "swc_atoms", "swc_common", "swc_ecma_ast", @@ -50,13 +48,13 @@ swc_core = { version = "0.95.2", features = [ "ecma_ast", "common", ] } -swc_ecma_parser = { version = "0.146.1" } +swc_ecma_parser = { version = "0.147.0" } swc_config = { version = "0.1.14" } [dev-dependencies] -swc_ecma_codegen = { version = "0.151.0" } -swc_ecma_transforms_compat = { version = "0.166.0" } -swc_ecma_transforms_module = { version = "0.183.0" } -swc_ecma_transforms_testing = { version = "0.143.0" } -swc_ecma_transforms = { version = "0.232.0" } -testing = { version = "0.36.0" } +swc_ecma_codegen = { version = "0.152.0" } +swc_ecma_transforms_compat = { version = "0.167.0" } +swc_ecma_transforms_module = { version = "0.184.0" } +swc_ecma_transforms_testing = { version = "0.144.0" } +swc_ecma_transforms = { version = "0.233.0" } +testing = { version = "0.37.0" } diff --git a/package.json b/package.json index 9ca395d..61d676e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "swc-plugin-inferno", - "version": "0.0.21", + "version": "0.0.22", "description": "Inferno JSX plugin for SWC `@swc/core`", "main": "swc_plugin_inferno.wasm", "files": [ diff --git a/src/jsx/mod.rs b/src/jsx/mod.rs index bc2de89..f2234bf 100644 --- a/src/jsx/mod.rs +++ b/src/jsx/mod.rs @@ -6,7 +6,7 @@ use swc_config::merge::Merge; use swc_core::common::comments::Comments; use swc_core::common::iter::IdentifyLast; use swc_core::common::util::take::Take; -use swc_core::common::{FileName, Mark, SourceMap, Span, Spanned, DUMMY_SP}; +use swc_core::common::{FileName, Mark, SourceMap, Span, Spanned, DUMMY_SP, SyntaxContext}; use swc_core::ecma::ast::*; use swc_core::ecma::atoms::{Atom, JsWord}; use swc_core::ecma::utils::{drop_span, prepend_stmt, quote_ident, ExprFactory, StmtLike}; @@ -53,7 +53,10 @@ pub fn parse_expr_for_jsx( src: String, top_level_mark: Mark, ) -> Arc> { - let fm = cm.new_source_file(FileName::Custom(format!("", name)), src); + let fm = cm.new_source_file( + FileName::Custom(format!("", name)).into(), + src + ); parse_file_as_expr( &fm, @@ -86,7 +89,7 @@ pub fn parse_expr_for_jsx( fn apply_mark(e: &mut Expr, mark: Mark) { match e { Expr::Ident(i) => { - i.span = i.span.apply_mark(mark); + i.ctxt = i.ctxt.apply_mark(mark); } Expr::Member(MemberExpr { obj, .. }) => { apply_mark(obj, mark); @@ -138,7 +141,7 @@ fn merge_imports( .specifiers .push(ImportSpecifier::Named(ImportNamedSpecifier { span: DUMMY_SP, - local: quote_ident!(*import_to_add), + local: quote_ident!(*import_to_add).into(), imported: None, is_type_only: false, })) @@ -285,7 +288,7 @@ where let fragment = self .import_create_fragment - .get_or_insert_with(|| quote_ident!("createFragment")) + .get_or_insert_with(|| quote_ident!("createFragment").into()) .clone(); let mut children_requires_normalization: bool = false; @@ -314,11 +317,11 @@ where span: DUMMY_SP, callee: self .import_create_text_vnode - .get_or_insert_with(|| quote_ident!("createTextVNode")) + .get_or_insert_with(|| quote_ident!("createTextVNode").into()) .clone() .as_callee(), args: vec![s.as_arg()], - type_args: Default::default(), + ..Default::default() })), } } @@ -376,6 +379,7 @@ where callee: fragment.as_callee(), args: create_fragment_vnode_args(children, false, child_flags as u16, None, None), type_args: None, + ..Default::default() }) } @@ -399,7 +403,7 @@ where if ident.sym == "Fragment" { vnode_kind = VNodeType::Fragment; mut_flags = VNodeFlags::ComponentUnknown as u16; - name_expr = Expr::Ident(Ident::new("createFragment".into(), ident.span)); + name_expr = Expr::Ident(Ident::new("createFragment".into(), ident.span.into(), Default::default())); } else { vnode_kind = Component; mut_flags = VNodeFlags::ComponentUnknown as u16; @@ -424,7 +428,7 @@ where return Expr::Invalid(Invalid { span: DUMMY_SP }); } - JSXElementName::JSXMemberExpr(JSXMemberExpr { obj, prop }) => { + JSXElementName::JSXMemberExpr(JSXMemberExpr { obj, prop, .. }) => { vnode_kind = Component; mut_flags = VNodeFlags::ComponentUnknown as u16; @@ -520,9 +524,9 @@ where .props .push(PropOrSpread::Prop(Box::new(Prop::KeyValue( KeyValueProp { - key: PropName::Ident(Ident::new( + key: PropName::Ident(IdentName::new( "onDblClick".into(), - span, + span )), value: match attr.value { Some(v) => jsx_attr_value_to_expr(v) @@ -688,10 +692,9 @@ where value: converted_sym.into(), }) } else { - PropName::Ident(Ident { + PropName::Ident(IdentName { span: i.span, - sym: converted_sym.into(), - optional: i.optional, + sym: converted_sym.into() }) }; @@ -702,7 +705,7 @@ where value, })))); } - JSXAttrName::JSXNamespacedName(JSXNamespacedName { ns, name }) => { + JSXAttrName::JSXNamespacedName(JSXNamespacedName { ns, name, .. }) => { let value = match attr.value { Some(v) => { jsx_attr_value_to_expr(v).expect("empty expression container?") @@ -767,9 +770,10 @@ where spread: None, expr: Box::new(Expr::Call(CallExpr { span: DUMMY_SP, + ctxt: SyntaxContext::empty().apply_mark(self.unresolved_mark), callee: self .import_create_text_vnode - .get_or_insert_with(|| quote_ident!("createTextVNode")) + .get_or_insert_with(|| quote_ident!("createTextVNode").into()) .clone() .as_callee(), args: vec![s.as_arg()], @@ -832,10 +836,11 @@ where spread: None, expr: Box::new(Expr::Call(CallExpr { span: DUMMY_SP, + ctxt: SyntaxContext::empty().apply_mark(self.unresolved_mark), callee: self .import_create_text_vnode .get_or_insert_with(|| { - quote_ident!("createTextVNode") + quote_ident!("createTextVNode").into() }) .clone() .as_callee(), @@ -963,15 +968,15 @@ where let create_method = if vnode_kind == Component { self.import_create_component - .get_or_insert_with(|| quote_ident!("createComponentVNode")) + .get_or_insert_with(|| quote_ident!("createComponentVNode").into()) .clone() } else if vnode_kind == VNodeType::Element { self.import_create_vnode - .get_or_insert_with(|| quote_ident!("createVNode")) + .get_or_insert_with(|| quote_ident!("createVNode").into()) .clone() } else { self.import_create_fragment - .get_or_insert_with(|| quote_ident!("createFragment")) + .get_or_insert_with(|| quote_ident!("createFragment").into()) .clone() }; @@ -1016,6 +1021,7 @@ where let create_expr = Expr::Call(CallExpr { span, + ctxt: SyntaxContext::empty().apply_mark(self.unresolved_mark), callee: create_method.as_callee(), args: create_method_args, type_args: Default::default(), @@ -1024,9 +1030,10 @@ where if needs_normalization { return Expr::Call(CallExpr { span, + ctxt: SyntaxContext::empty().apply_mark(self.unresolved_mark), callee: self .import_normalize_props - .get_or_insert_with(|| quote_ident!("normalizeProps")) + .get_or_insert_with(|| quote_ident!("normalizeProps").into()) .clone() .as_callee(), args: vec![create_expr.as_arg()], @@ -1354,7 +1361,7 @@ where .map(|imported| { ImportSpecifier::Named(ImportNamedSpecifier { span: DUMMY_SP, - local: quote_ident!(imported), + local: quote_ident!(imported).into(), imported: None, is_type_only: false, }) @@ -1393,6 +1400,7 @@ where fn add_require(imports: Vec<&str>, src: &str, unresolved_mark: Mark) -> Stmt { Stmt::Decl(Decl::Var(Box::new(VarDecl { span: DUMMY_SP, + ctxt: SyntaxContext::empty().apply_mark(unresolved_mark), kind: VarDeclKind::Const, declare: false, decls: vec![VarDeclarator { @@ -1407,6 +1415,7 @@ fn add_require(imports: Vec<&str>, src: &str, unresolved_mark: Mark) -> Stmt { key: BindingIdent { id: Ident { span: DUMMY_SP, + ctxt: SyntaxContext::empty().apply_mark(unresolved_mark), sym: imported.into(), optional: false, }, @@ -1422,10 +1431,12 @@ fn add_require(imports: Vec<&str>, src: &str, unresolved_mark: Mark) -> Stmt { // require('inferno') init: Some(Box::new(Expr::Call(CallExpr { span: DUMMY_SP, + ctxt: SyntaxContext::empty().apply_mark(unresolved_mark), callee: Callee::Expr(Box::new(Expr::Ident(Ident { - span: DUMMY_SP.apply_mark(unresolved_mark), + ctxt: SyntaxContext::empty().apply_mark(unresolved_mark), sym: "require".into(), optional: false, + ..Default::default() }))), args: vec![ExprOrSpread { spread: None, diff --git a/src/jsx/tests.rs b/src/jsx/tests.rs index 5cb109a..9a4c411 100644 --- a/src/jsx/tests.rs +++ b/src/jsx/tests.rs @@ -11,7 +11,7 @@ use swc_core::ecma::transforms::base::hygiene::hygiene; use swc_core::ecma::transforms::base::resolver; use swc_core::ecma::visit::FoldWith; use swc_ecma_codegen::{Config, Emitter}; -use swc_ecma_parser::{EsConfig, Parser, Syntax}; +use swc_ecma_parser::{EsSyntax, Parser, Syntax}; use swc_ecma_transforms_compat::es3::property_literals; use swc_ecma_transforms_module::common_js::common_js; use swc_ecma_transforms_testing::{parse_options, test, test_fixture, FixtureTestConfig, Tester}; @@ -21,7 +21,7 @@ use super::*; use crate::{inferno, pure_annotations}; test!( - Syntax::Typescript(::swc_ecma_parser::TsConfig { + Syntax::Typescript(::swc_ecma_parser::TsSyntax { tsx: true, ..Default::default() }), @@ -35,12 +35,6 @@ test!( Some(t.comments.clone()), Default::default(), unresolved_mark - ), - common_js( - unresolved_mark, - Default::default(), - Default::default(), - Some(t.comments.clone()) ) ) }, @@ -72,7 +66,7 @@ render(, null); ); test!( - ::swc_ecma_parser::Syntax::Typescript(::swc_ecma_parser::TsConfig { + ::swc_ecma_parser::Syntax::Typescript(::swc_ecma_parser::TsSyntax { tsx: true, ..Default::default() }), @@ -121,7 +115,7 @@ render(, null); */ test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -142,7 +136,7 @@ onComponentDidMount={childOnComponentDidMount} * Dynamic children */ test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -154,7 +148,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -166,7 +160,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -180,7 +174,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -192,7 +186,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -204,7 +198,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -216,7 +210,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -228,7 +222,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -240,7 +234,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -252,7 +246,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -264,7 +258,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -276,7 +270,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -288,7 +282,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -304,7 +298,7 @@ test!( */ test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -316,7 +310,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -328,7 +322,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -344,7 +338,7 @@ test!( */ test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -356,7 +350,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -368,7 +362,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -380,7 +374,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -396,7 +390,7 @@ test!( */ test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -408,7 +402,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -420,7 +414,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -432,7 +426,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -444,7 +438,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -456,7 +450,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -468,7 +462,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -480,7 +474,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -492,7 +486,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -504,7 +498,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -516,7 +510,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -528,7 +522,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -540,7 +534,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -552,7 +546,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -564,7 +558,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -576,7 +570,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -588,7 +582,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -600,7 +594,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -612,7 +606,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -624,7 +618,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -636,7 +630,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -649,7 +643,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -661,7 +655,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -673,7 +667,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -685,7 +679,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -697,7 +691,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -709,7 +703,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -721,7 +715,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -733,7 +727,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -745,7 +739,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -757,7 +751,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -769,7 +763,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -781,7 +775,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -794,7 +788,7 @@ test!( // TODO: How to verify errors // test!( -// ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { +// ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { // jsx: true, // ..Default::default() // }), @@ -810,7 +804,7 @@ test!( // TODO: How to verify errors // test!( -// ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { +// ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { // jsx: true, // ..Default::default() // }), @@ -830,7 +824,7 @@ test!( // "#); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -842,7 +836,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -854,7 +848,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -866,7 +860,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -878,7 +872,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -890,7 +884,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -902,7 +896,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -914,7 +908,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -926,7 +920,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -938,7 +932,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -950,7 +944,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -962,7 +956,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -974,7 +968,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -986,7 +980,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -998,7 +992,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1010,7 +1004,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1022,7 +1016,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1034,7 +1028,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1046,7 +1040,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1058,7 +1052,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1070,7 +1064,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1082,7 +1076,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1094,7 +1088,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1106,7 +1100,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1118,7 +1112,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1130,7 +1124,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1142,7 +1136,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1154,7 +1148,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1166,7 +1160,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1178,7 +1172,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1190,7 +1184,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1202,7 +1196,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1216,7 +1210,7 @@ test!( // This could be optimized to have HasVNodeChildren set, // but I'm not sure if anybody writes code like this test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1228,7 +1222,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1241,7 +1235,7 @@ test!( // TODO: How to verify errors // test!( -// ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { +// ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { // jsx: true, // ..Default::default() // }), @@ -1256,7 +1250,7 @@ test!( // "#); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1268,7 +1262,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1342,7 +1336,7 @@ fn integration_tr(t: &mut Tester, options: FixtureOptions) -> impl Fold { } test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1356,7 +1350,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1374,7 +1368,7 @@ var bar = function () { ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1398,7 +1392,7 @@ var x = ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1413,7 +1407,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1430,7 +1424,7 @@ var profile =
); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1449,7 +1443,7 @@ var profile =
); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1472,7 +1466,7 @@ var profile =
); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1482,7 +1476,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1494,7 +1488,7 @@ test!( test!( // This is not worth optimization if Inferno does not have support for static vNodes trees // cloning the element runtime is more expensive than creating new and adds extra memory - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1524,7 +1518,7 @@ class App extends Component { ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1537,7 +1531,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1547,7 +1541,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1557,7 +1551,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1567,7 +1561,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1577,7 +1571,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1600,7 +1594,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1614,7 +1608,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1629,7 +1623,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1655,7 +1649,7 @@ var x = ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1665,7 +1659,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1675,7 +1669,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1690,7 +1684,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1712,7 +1706,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1725,7 +1719,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1735,7 +1729,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1747,7 +1741,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1769,7 +1763,7 @@ Inferno.render( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1822,7 +1816,7 @@ var x = ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1832,7 +1826,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1842,7 +1836,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1853,7 +1847,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1865,7 +1859,7 @@ test!( test!( // Comments are currently stripped out - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1886,7 +1880,7 @@ comment */ ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1897,7 +1891,7 @@ test!( // TODO: Namespaces disabled // test!( -// ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { +// ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { // jsx: true, // ..Default::default() // }), @@ -1918,7 +1912,7 @@ test!( // ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1928,7 +1922,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1941,7 +1935,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1951,7 +1945,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1961,7 +1955,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1971,7 +1965,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1981,7 +1975,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -1991,7 +1985,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -2004,7 +1998,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -2027,7 +2021,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -2038,7 +2032,7 @@ test!( // https://github.com/swc-project/swc/issues/517 test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -2068,7 +2062,7 @@ fn jsx_text() { // https://github.com/swc-project/swc/issues/542 test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -2078,7 +2072,7 @@ test!( ); test!( - Syntax::Es(EsConfig { + Syntax::Es(EsSyntax { jsx: true, ..Default::default() }), @@ -2109,7 +2103,7 @@ fn fixture(input: PathBuf) { } test_fixture( - Syntax::Es(EsConfig { + Syntax::Es(EsSyntax { jsx: true, ..Default::default() }), @@ -2134,7 +2128,7 @@ fn integration(input: PathBuf) { } test_fixture( - Syntax::Es(EsConfig { + Syntax::Es(EsSyntax { jsx: true, ..Default::default() }), @@ -2166,9 +2160,9 @@ fn test_script(src: &str, output: &Path, options: Options) { Tester::run(|tester| { let fm = tester .cm - .new_source_file(FileName::Real("input.js".into()), src.into()); + .new_source_file(FileName::Real("input.js".into()).into(), src.into()); - let syntax = Syntax::Es(EsConfig { + let syntax = Syntax::Es(EsSyntax { jsx: true, ..Default::default() }); diff --git a/src/lib.rs b/src/lib.rs index 82db7a7..9563d0d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -57,7 +57,7 @@ where } #[plugin_transform] -fn inferno_jsx_plugin(program: Program, _data: TransformPluginProgramMetadata) -> Program { +fn inferno_jsx_plugin(program: Program, data: TransformPluginProgramMetadata) -> Program { let top_level_mark = Mark::new(); // TODO: Where to get source map @@ -65,9 +65,9 @@ fn inferno_jsx_plugin(program: Program, _data: TransformPluginProgramMetadata) - program.fold_with(&mut inferno( cm, - Some(&_data.comments), + Some(&data.comments), Default::default(), top_level_mark, - _data.unresolved_mark, + data.unresolved_mark, )) } diff --git a/src/pure_annotations/tests.rs b/src/pure_annotations/tests.rs index b5a609f..9380385 100644 --- a/src/pure_annotations/tests.rs +++ b/src/pure_annotations/tests.rs @@ -13,12 +13,12 @@ fn parse( tester: &mut Tester, src: &str, ) -> Result<(Module, Lrc, Lrc), ()> { - let syntax = ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + let syntax = ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }); let source_map = Lrc::new(SourceMap::default()); - let source_file = source_map.new_source_file(FileName::Anon, src.into()); + let source_file = source_map.new_source_file(FileName::Anon.into(), src.into()); let comments = Lrc::new(SingleThreadedComments::default()); let module = { diff --git a/src/refresh/hook.rs b/src/refresh/hook.rs index 4d3f16d..84d8fb6 100644 --- a/src/refresh/hook.rs +++ b/src/refresh/hook.rs @@ -1,7 +1,6 @@ -use base64::engine::general_purpose::STANDARD; -use base64::Engine; use std::{fmt::Write, mem}; +use base64::prelude::{Engine, BASE64_STANDARD}; use sha1::{Digest, Sha1}; use swc_core::common::util::take::Take; use swc_core::common::{SourceMap, SourceMapper, Spanned, SyntaxContext, DUMMY_SP}; @@ -39,7 +38,7 @@ struct Hook { #[allow(clippy::large_enum_variant)] enum HookCall { Ident(Ident), - Member(Expr, Ident), // for obj and prop + Member(Expr, IdentName), // for obj and prop } pub struct HookRegister<'a> { pub options: &'a RefreshOptions, @@ -62,16 +61,16 @@ impl<'a> HookRegister<'a> { .map(|id| VarDeclarator { span: DUMMY_SP, name: id.into(), - init: Some(Box::new(make_call_expr(quote_ident!(self - .options - .refresh_sig - .clone())))), + init: Some(Box::new(make_call_expr( + quote_ident!(self.options.refresh_sig.clone()).into(), + ))), definite: false, }) .collect(), declare: false, + ..Default::default() } - .into() + .into() } // The second call is around the function itself. This is used to associate a @@ -84,15 +83,15 @@ impl<'a> HookRegister<'a> { for hook in hooks { let name = match &hook.callee { - HookCall::Ident(i) => i, - HookCall::Member(_, i) => i, + HookCall::Ident(i) => i.clone(), + HookCall::Member(_, i) => i.clone().into(), }; sign.push(format!("{}{{{}}}", name.sym, hook.key)); match &hook.callee { - HookCall::Ident(ident) if !is_builtin_hook(ident) => { + HookCall::Ident(ident) if !is_builtin_hook(&ident.sym) => { custom_hook.push(hook.callee); } - HookCall::Member(Expr::Ident(obj_ident), prop) if !is_builtin_hook(prop) => { + HookCall::Member(Expr::Ident(obj_ident), prop) if !is_builtin_hook(&prop.sym) => { if obj_ident.sym.as_ref() != "React" { custom_hook.push(hook.callee); } @@ -107,16 +106,16 @@ impl<'a> HookRegister<'a> { } else { let mut hasher = Sha1::new(); hasher.update(sign); - STANDARD.encode(hasher.finalize()) + BASE64_STANDARD.encode(hasher.finalize()) }; args.push( - Expr::Lit(Lit::Str(Str { + Lit::Str(Str { span: DUMMY_SP, raw: None, value: sign.into(), - })) - .as_arg(), + }) + .as_arg(), ); let mut should_reset = self.should_reset; @@ -130,7 +129,7 @@ impl<'a> HookRegister<'a> { _ => None, }; if !ident - .map(|id| self.current_scope.contains(&id.span.ctxt)) + .map(|id| self.current_scope.contains(&id.ctxt)) .unwrap_or(false) { // We don't have anything to put in the array because Hook is out of scope. @@ -151,14 +150,15 @@ impl<'a> HookRegister<'a> { .map(|hook| { Some( match hook { - HookCall::Ident(ident) => Expr::Ident(ident), - HookCall::Member(obj, prop) => Expr::Member(MemberExpr { + HookCall::Ident(ident) => Expr::from(ident), + HookCall::Member(obj, prop) => MemberExpr { span: DUMMY_SP, obj: Box::new(obj), prop: MemberProp::Ident(prop), - }), + } + .into(), } - .as_arg(), + .as_arg(), ) }) .collect(); @@ -178,28 +178,32 @@ impl<'a> HookRegister<'a> { elems, }))), })], + ..Default::default() }), - type_params: None, - return_type: None, + ..Default::default() } - .as_arg(), + .as_arg(), ); } - Expr::Call(CallExpr { + CallExpr { span: DUMMY_SP, callee: handle.as_callee(), args, - type_args: None, - }) + ..Default::default() + } + .into() } fn gen_hook_register_stmt(&mut self, ident: Ident, sig: HookSig) { self.ident.push(sig.handle.clone()); - self.extra_stmt.push(Stmt::Expr(ExprStmt { - span: DUMMY_SP, - expr: Box::new(self.wrap_with_register(sig.handle, Expr::Ident(ident), sig.hooks)), - })) + self.extra_stmt.push( + ExprStmt { + span: DUMMY_SP, + expr: Box::new(self.wrap_with_register(sig.handle, ident.into(), sig.hooks)), + } + .into(), + ) } } @@ -210,7 +214,7 @@ impl<'a> VisitMut for HookRegister<'a> { let old_ident = self.ident.take(); let old_stmts = self.extra_stmt.take(); - self.current_scope.push(b.span.ctxt); + self.current_scope.push(b.ctxt); let stmt_count = b.stmts.len(); let stmts = mem::replace(&mut b.stmts, Vec::with_capacity(stmt_count)); @@ -262,7 +266,7 @@ impl<'a> VisitMut for HookRegister<'a> { for decl in n.decls.iter_mut() { if let VarDeclarator { // it doesn't quite make sense for other Pat to appear here - name: Pat::Ident(BindingIdent { id, .. }), + name: Pat::Ident(id), init: Some(init), .. } = decl @@ -273,13 +277,13 @@ impl<'a> VisitMut for HookRegister<'a> { if let Some(sig) = collect_hooks(&mut f.body.as_mut().unwrap().stmts, self.cm) { - self.gen_hook_register_stmt(id.clone(), sig); + self.gen_hook_register_stmt(Ident::from(&*id), sig); } } Expr::Arrow(ArrowExpr { body, .. }) => { body.visit_mut_with(self); if let Some(sig) = collect_hooks_arrow(body, self.cm) { - self.gen_hook_register_stmt(id.clone(), sig); + self.gen_hook_register_stmt(Ident::from(&*id), sig); } } _ => self.visit_mut_expr(init), @@ -296,9 +300,9 @@ impl<'a> VisitMut for HookRegister<'a> { // only when expr has ident match d { DefaultDecl::Fn(FnExpr { - ident: Some(ident), - function: f, - }) if f.body.is_some() => { + ident: Some(ident), + function: f, + }) if f.body.is_some() => { if let Some(sig) = collect_hooks(&mut f.body.as_mut().unwrap().stmts, self.cm) { self.gen_hook_register_stmt(ident.clone(), sig); } @@ -358,6 +362,7 @@ fn collect_hooks_arrow(body: &mut BlockStmtOrExpr, cm: &SourceMap) -> Option HookCollector<'a> { let ident = match callee { Expr::Ident(ident) => { hook_call = Some(HookCall::Ident(ident.clone())); - Some(ident) + Some(&ident.sym) } // hook cannot be used in class, so we're fine without SuperProp Expr::Member(MemberExpr { - obj, - prop: MemberProp::Ident(ident), - .. - }) => { + obj, + prop: MemberProp::Ident(ident), + .. + }) => { hook_call = Some(HookCall::Member(*obj.clone(), ident.clone())); - Some(ident) + Some(&ident.sym) } _ => None, }?; - let name = if is_hook_like(&ident.sym) { + let name = if is_hook_like(ident) { Some(ident) } else { None @@ -415,7 +420,7 @@ impl<'a> HookCollector<'a> { String::new() }; // Some built-in Hooks reset on edits to arguments. - if &name.sym == "useState" && !expr.args.is_empty() { + if *name == "useState" && !expr.args.is_empty() { // useState first argument is initial state. let _ = write!( key, @@ -424,7 +429,7 @@ impl<'a> HookCollector<'a> { .span_to_snippet(expr.args[0].span()) .unwrap_or_default() ); - } else if &name.sym == "useReducer" && expr.args.len() > 1 { + } else if name == "useReducer" && expr.args.len() > 1 { // useReducer second argument is initial state. let _ = write!( key, diff --git a/src/refresh/mod.rs b/src/refresh/mod.rs index d22dd31..fe98b47 100644 --- a/src/refresh/mod.rs +++ b/src/refresh/mod.rs @@ -37,7 +37,7 @@ enum Persist { } fn get_persistent_id(ident: &Ident) -> Persist { if ident.sym.starts_with(|c: char| c.is_ascii_uppercase()) { - if cfg!(debug_assertions) && ident.span.ctxt == SyntaxContext::empty() { + if cfg!(debug_assertions) && ident.ctxt == SyntaxContext::empty() { panic!("`{}` should be resolved", ident) } Persist::Component(ident.clone()) @@ -92,13 +92,13 @@ impl Refresh { match init_expr.as_ref() { // TaggedTpl is for something like styled.div`...` Expr::Arrow(_) | Expr::Fn(_) | Expr::TaggedTpl(_) | Expr::Call(_) => { - return Persist::Component(binding.id.clone()) + return Persist::Component(Ident::from(&*binding)) } _ => (), } } - if let Persist::Component(persistent_id) = get_persistent_id(&binding.id) { + if let Persist::Component(persistent_id) = get_persistent_id(&Ident::from(&*binding)) { return match init_expr.as_mut() { Expr::Fn(_) => Persist::Component(persistent_id), Expr::Arrow(ArrowExpr { body, .. }) => { @@ -118,10 +118,10 @@ impl Refresh { hook_reg, ); if let Persist::Hoc(Hoc { - insert, - reg, - hook: Some(hook), - }) = res + insert, + reg, + hook: Some(hook), + }) = res { make_hook_reg(init_expr.as_mut(), hook); Persist::Hoc(Hoc { @@ -177,12 +177,13 @@ impl Refresh { let span = first.span(); let mut args = vec![first.as_arg()]; args.extend(rest_arg.clone()); - first = Box::new(Expr::Call(CallExpr { + first = CallExpr { span, callee: callee.clone(), args, - type_args: None, - })) + ..Default::default() + } + .into() } *first_arg = Box::new(make_assign_stmt(reg_ident, first)); @@ -308,28 +309,28 @@ impl VisitMut for Refresh { // export function Foo() {} ModuleItem::ModuleDecl(ModuleDecl::ExportDecl(ExportDecl { - decl: Decl::Fn(FnDecl { ident, .. }), - .. - })) => get_persistent_id(ident), + decl: Decl::Fn(FnDecl { ident, .. }), + .. + })) => get_persistent_id(ident), // export default function Foo() {} ModuleItem::ModuleDecl(ModuleDecl::ExportDefaultDecl(ExportDefaultDecl { - decl: - DefaultDecl::Fn(FnExpr { - // We don't currently handle anonymous default exports. - ident: Some(ident), - .. - }), - .. - })) => get_persistent_id(ident), + decl: + DefaultDecl::Fn(FnExpr { + // We don't currently handle anonymous default exports. + ident: Some(ident), + .. + }), + .. + })) => get_persistent_id(ident), // const Foo = () => {} // export const Foo = () => {} ModuleItem::Stmt(Stmt::Decl(Decl::Var(var_decl))) | ModuleItem::ModuleDecl(ModuleDecl::ExportDecl(ExportDecl { - decl: Decl::Var(var_decl), - .. - })) => { + decl: Decl::Var(var_decl), + .. + })) => { self.get_persistent_id_from_var_decl(var_decl, &used_in_jsx, &mut hook_visitor) } @@ -338,9 +339,9 @@ impl VisitMut for Refresh { // In those cases it is more plausible people will omit names // so they're worth handling despite possible false positives. ModuleItem::ModuleDecl(ModuleDecl::ExportDefaultExpr(ExportDefaultExpr { - expr, - span, - })) => { + expr, + span, + })) => { if let Expr::Call(call) = expr.as_mut() { if let Persist::Hoc(Hoc { reg, hook, .. }) = self .get_persistent_id_from_possible_hoc( @@ -355,12 +356,11 @@ impl VisitMut for Refresh { if let Some(hook) = hook { make_hook_reg(expr.as_mut(), hook) } - item = ModuleItem::ModuleDecl(ModuleDecl::ExportDefaultExpr( - ExportDefaultExpr { - expr: Box::new(make_assign_stmt(reg[0].0.clone(), expr.take())), - span: *span, - }, - )); + item = ExportDefaultExpr { + expr: Box::new(make_assign_stmt(reg[0].0.clone(), expr.take())), + span: *span, + } + .into(); Persist::Hoc(Hoc { insert: false, reg, @@ -401,29 +401,32 @@ impl VisitMut for Refresh { refresh_regs.push((registration_handle.clone(), persistent_id.to_id())); - items.push(ModuleItem::Stmt(Stmt::Expr(ExprStmt { - span: DUMMY_SP, - expr: Box::new(make_assign_stmt( - registration_handle, - Box::new(Expr::Ident(persistent_id)), - )), - }))); + items.push( + ExprStmt { + span: DUMMY_SP, + expr: Box::new(make_assign_stmt( + registration_handle, + persistent_id.into(), + )), + } + .into(), + ); } Persist::Hoc(mut hoc) => { hoc.reg = hoc.reg.into_iter().rev().collect(); if hoc.insert { let (ident, name) = hoc.reg.last().unwrap(); - items.push(ModuleItem::Stmt(Stmt::Expr(ExprStmt { - span: DUMMY_SP, - expr: Box::new(make_assign_stmt( - ident.clone(), - Box::new(Expr::Ident(Ident::new( - name.0.clone(), - DUMMY_SP.with_ctxt(name.1), - ))), - )), - }))) + items.push( + ExprStmt { + span: DUMMY_SP, + expr: Box::new(make_assign_stmt( + ident.clone(), + Ident::new(name.0.clone(), DUMMY_SP, name.1).into(), + )), + } + .into(), + ) } refresh_regs.append(&mut hoc.reg); } @@ -431,7 +434,7 @@ impl VisitMut for Refresh { } if !hook_visitor.ident.is_empty() { - items.insert(0, ModuleItem::Stmt(hook_visitor.gen_hook_handle())); + items.insert(0, hook_visitor.gen_hook_handle().into()); } // Insert @@ -453,8 +456,9 @@ impl VisitMut for Refresh { definite: false, }) .collect(), + ..Default::default() } - .into(), + .into(), ); } @@ -465,15 +469,18 @@ impl VisitMut for Refresh { // ``` let refresh_reg = self.options.refresh_reg.as_str(); for (handle, persistent_id) in refresh_regs { - items.push(ModuleItem::Stmt(Stmt::Expr(ExprStmt { - span: DUMMY_SP, - expr: Box::new(Expr::Call(CallExpr { + items.push( + ExprStmt { span: DUMMY_SP, - callee: quote_ident!(refresh_reg).as_callee(), - args: vec![handle.as_arg(), quote_str!(persistent_id.0).as_arg()], - type_args: None, - })), - }))); + expr: CallExpr { + callee: quote_ident!(refresh_reg).as_callee(), + args: vec![handle.as_arg(), quote_str!(persistent_id.0).as_arg()], + ..Default::default() + } + .into(), + } + .into(), + ); } *module_items = items @@ -486,10 +493,11 @@ fn make_hook_reg(expr: &mut Expr, mut hook: HocHook) { let span = expr.span(); let mut args = vec![expr.take().as_arg()]; args.append(&mut hook.rest_arg); - *expr = Expr::Call(CallExpr { + *expr = CallExpr { span, callee: hook.callee, args, - type_args: None, - }); + ..Default::default() + } + .into(); } diff --git a/src/refresh/tests.rs b/src/refresh/tests.rs index cb43e5d..821e5b1 100644 --- a/src/refresh/tests.rs +++ b/src/refresh/tests.rs @@ -1,11 +1,13 @@ -use super::*; use swc_core::{ common::{chain, Mark}, ecma::transforms::base::resolver, }; -use swc_ecma_transforms_module::common_js::common_js; use swc_ecma_transforms_testing::{test, Tester}; +use crate::jsx; + +use super::*; + fn tr(t: &mut Tester) -> impl Fold { let unresolved_mark = Mark::new(); let top_level_mark = Mark::new(); @@ -26,7 +28,7 @@ fn tr(t: &mut Tester) -> impl Fold { } test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -44,7 +46,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -69,7 +71,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -90,7 +92,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -106,7 +108,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -120,7 +122,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -141,7 +143,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -161,7 +163,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -187,7 +189,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -210,7 +212,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -220,7 +222,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -240,7 +242,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -254,7 +256,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -268,7 +270,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -284,7 +286,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -302,7 +304,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -337,7 +339,7 @@ test!( // A doesn't get registered because it's not declared locally. // Alias doesn't get registered because its definition is just an identifier. test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -378,7 +380,7 @@ test!( test!( ignore, - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -394,7 +396,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -411,7 +413,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -427,7 +429,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -452,7 +454,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -481,7 +483,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -497,7 +499,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -514,7 +516,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -537,7 +539,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Typescript(::swc_ecma_parser::TsConfig { + ::swc_ecma_parser::Syntax::Typescript(::swc_ecma_parser::TsSyntax { tsx: true, ..Default::default() }), @@ -557,12 +559,11 @@ test!( Some(t.comments.clone()), top_level_mark ), - common_js( - unresolved_mark, - Default::default(), + jsx( + Some(t.comments.clone()), Default::default(), - Some(t.comments.clone()) - ) + unresolved_mark + ), ) }, include_hook_signature_in_commonjs, @@ -578,7 +579,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -602,7 +603,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Typescript(::swc_ecma_parser::TsConfig { + ::swc_ecma_parser::Syntax::Typescript(::swc_ecma_parser::TsSyntax { tsx: true, ..Default::default() }), @@ -629,7 +630,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -652,7 +653,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -668,7 +669,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -701,7 +702,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Typescript(::swc_ecma_parser::TsConfig { + ::swc_ecma_parser::Syntax::Typescript(::swc_ecma_parser::TsSyntax { tsx: true, ..Default::default() }), @@ -741,7 +742,7 @@ test!( ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), @@ -759,7 +760,7 @@ const a = (a) => { ); test!( - ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { + ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsSyntax { jsx: true, ..Default::default() }), diff --git a/src/refresh/util.rs b/src/refresh/util.rs index a429cb8..dc8c226 100644 --- a/src/refresh/util.rs +++ b/src/refresh/util.rs @@ -5,9 +5,9 @@ use swc_core::{ ecma::visit::{noop_visit_type, Visit, VisitWith}, }; -pub fn is_builtin_hook(name: &Ident) -> bool { +pub fn is_builtin_hook(name: &str) -> bool { matches!( - name.sym.as_ref(), + name, "useState" | "useReducer" | "useEffect" @@ -35,7 +35,7 @@ fn assert_hygiene(e: &Expr) { } if let Expr::Ident(i) = e { - if i.span.ctxt == SyntaxContext::empty() { + if i.ctxt == SyntaxContext::empty() { panic!("`{}` should be resolved", i) } } @@ -44,36 +44,39 @@ fn assert_hygiene(e: &Expr) { pub fn make_assign_stmt(handle: Ident, expr: Box) -> Expr { assert_hygiene(&expr); - Expr::Assign(AssignExpr { + AssignExpr { span: expr.span(), op: op!("="), left: handle.into(), right: expr, - }) + } + .into() } pub fn make_call_stmt(handle: Ident) -> Stmt { - Stmt::Expr(ExprStmt { + ExprStmt { span: DUMMY_SP, expr: Box::new(make_call_expr(handle)), - }) + } + .into() } pub fn make_call_expr(handle: Ident) -> Expr { - Expr::Call(CallExpr { + CallExpr { span: DUMMY_SP, callee: handle.as_callee(), args: Vec::new(), - type_args: None, - }) + ..Default::default() + } + .into() } pub fn is_import_or_require(expr: &Expr) -> bool { match expr { Expr::Call(CallExpr { - callee: Callee::Expr(expr), - .. - }) => { + callee: Callee::Expr(expr), + .. + }) => { if let Expr::Ident(ident) = expr.as_ref() { ident.sym.contains("require") } else { @@ -81,13 +84,12 @@ pub fn is_import_or_require(expr: &Expr) -> bool { } } Expr::Call(CallExpr { - callee: Callee::Import(_), - .. - }) => true, + callee: Callee::Import(_), + .. + }) => true, _ => false, } } - pub struct UsedInJsx(AHashSet); impl Visit for UsedInJsx { @@ -98,15 +100,15 @@ impl Visit for UsedInJsx { if let Callee::Expr(expr) = &n.callee { let ident = match expr.as_ref() { - Expr::Ident(ident) => ident, + Expr::Ident(ident) => ident.to_id(), Expr::Member(MemberExpr { - prop: MemberProp::Ident(ident), - .. - }) => ident, + prop: MemberProp::Ident(ident), + .. + }) => (ident.sym.clone(), SyntaxContext::empty()), _ => return, }; if matches!( - ident.sym.as_ref(), + ident.0.as_ref(), "createElement" | "jsx" | "jsxDEV" | "jsxs" ) { if let Some(ExprOrSpread { expr, .. }) = n.args.first() { diff --git a/tests/__swc_snapshots__/src/jsx/tests.rs/should_always_stick_the_create_vnode_ref_to_import_when_compiled_to_commonjs.js b/tests/__swc_snapshots__/src/jsx/tests.rs/should_always_stick_the_create_vnode_ref_to_import_when_compiled_to_commonjs.js index 58d016b..4e41b25 100644 --- a/tests/__swc_snapshots__/src/jsx/tests.rs/should_always_stick_the_create_vnode_ref_to_import_when_compiled_to_commonjs.js +++ b/tests/__swc_snapshots__/src/jsx/tests.rs/should_always_stick_the_create_vnode_ref_to_import_when_compiled_to_commonjs.js @@ -1,22 +1,18 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); -var _inferno = require("inferno"); -const Foo = class Clock extends _inferno.Component { +import { Component, createTextVNode, createVNode, linkEvent, render, createComponentVNode } from 'inferno'; +const Foo = class Clock extends Component { public render() { - return /*#__PURE__*/ (0, _inferno.createComponentVNode)(2, Collapsible, { + return /*#__PURE__*/ createComponentVNode(2, Collapsible, { children: [ - /*#__PURE__*/ (0, _inferno.createVNode)(1, "div", null, [ + /*#__PURE__*/ createVNode(1, "div", null, [ [ - /*#__PURE__*/ (0, _inferno.createVNode)(1, "p", null, "Hello 0", 16), - /*#__PURE__*/ (0, _inferno.createVNode)(1, "p", null, "Hello 1", 16) + /*#__PURE__*/ createVNode(1, "p", null, "Hello 0", 16), + /*#__PURE__*/ createVNode(1, "p", null, "Hello 1", 16) ], - /*#__PURE__*/ (0, _inferno.createVNode)(1, "strong", null, "Hello 2", 16) + /*#__PURE__*/ createVNode(1, "strong", null, "Hello 2", 16) ], 0), - /*#__PURE__*/ (0, _inferno.createVNode)(1, "p", null, "Hello 3", 16) + /*#__PURE__*/ createVNode(1, "p", null, "Hello 3", 16) ] }); } }; -(0, _inferno.render)(/*#__PURE__*/ (0, _inferno.createComponentVNode)(2, Foo), null); +render(/*#__PURE__*/ createComponentVNode(2, Foo), null); diff --git a/tests/__swc_snapshots__/src/refresh/tests.rs/dont_consider_require_as_hoc.js b/tests/__swc_snapshots__/src/refresh/tests.rs/dont_consider_require_as_hoc.js index 6884459..6d5c1c6 100644 --- a/tests/__swc_snapshots__/src/refresh/tests.rs/dont_consider_require_as_hoc.js +++ b/tests/__swc_snapshots__/src/refresh/tests.rs/dont_consider_require_as_hoc.js @@ -5,17 +5,11 @@ const D = import('D'); import E = require('E'); export default function App() { return ; } _c = App; diff --git a/tests/__swc_snapshots__/src/refresh/tests.rs/include_hook_signature_in_commonjs.js b/tests/__swc_snapshots__/src/refresh/tests.rs/include_hook_signature_in_commonjs.js index cf5da48..780de28 100644 --- a/tests/__swc_snapshots__/src/refresh/tests.rs/include_hook_signature_in_commonjs.js +++ b/tests/__swc_snapshots__/src/refresh/tests.rs/include_hook_signature_in_commonjs.js @@ -1,26 +1,17 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "default", { - enumerable: true, - get: function() { - return App; - } -}); -var _hooks = require("./hooks"); -var _foo = /*#__PURE__*/ _interop_require_default(require("./foo")); +import { createVNode } from "inferno"; var _s = $RefreshSig$(); -function App() { +import { useFancyState } from './hooks'; +import useFoo from './foo'; +export default function App() { _s(); - const bar = (0, _hooks.useFancyState)(); - const foo = (0, _foo.default)(); - return

{bar}

; + const bar = useFancyState(); + const foo = useFoo(); + return /*#__PURE__*/ createVNode(1, "h1", null, bar, 0); } _s(App, "useFancyState{bar}\nuseFoo{foo}", false, function() { return [ - _hooks.useFancyState, - _foo.default + useFancyState, + useFoo ]; }); _c = App; diff --git a/tests/jsx/fixture/issue-6939/output.stderr b/tests/jsx/fixture/issue-6939/output.stderr index 541b257..a34bb38 100644 --- a/tests/jsx/fixture/issue-6939/output.stderr +++ b/tests/jsx/fixture/issue-6939/output.stderr @@ -1,4 +1,3 @@ - x The value of property 'key' should not be empty ,-[input.js:1:1] 1 | const test =