mirror of
https://github.com/swc-project/swc.git
synced 2024-11-23 09:38:16 +03:00
fix(swc): Fix bugs (#2034)
swc_ecma_transforms_base: - `resolver`: Handle constructor properties correctly. (#2021) swc_ecma_transforms_compat: - `block_scoping`: Handle arrows in loops. (#2027) - `block_scoping`: Handle nested for loops with function between them. (#2027) - `regenerator`: Handle rhs of `||` correctly. (#2024) swc: - Add a test for #1734. (#1734)
This commit is contained in:
parent
9793926cc8
commit
53b031b019
292
Cargo.lock
generated
292
Cargo.lock
generated
@ -60,7 +60,7 @@ version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
||||
dependencies = [
|
||||
"winapi 0.3.9",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -69,7 +69,7 @@ version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
|
||||
dependencies = [
|
||||
"winapi 0.3.9",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -113,7 +113,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"winapi 0.3.9",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -188,12 +188,6 @@ version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.0.1"
|
||||
@ -228,7 +222,7 @@ dependencies = [
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
"time",
|
||||
"winapi 0.3.9",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -559,22 +553,6 @@ version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
||||
|
||||
[[package]]
|
||||
name = "fuchsia-zircon"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"fuchsia-zircon-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fuchsia-zircon-sys"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.16"
|
||||
@ -619,7 +597,7 @@ dependencies = [
|
||||
"futures-io",
|
||||
"futures-task",
|
||||
"memchr",
|
||||
"pin-project-lite 0.2.7",
|
||||
"pin-project-lite",
|
||||
"pin-utils",
|
||||
"slab",
|
||||
]
|
||||
@ -679,11 +657,11 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
||||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
version = "0.2.7"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535"
|
||||
checksum = "825343c4eef0b63f541f8903f395dc5beb362a979b5799a84062527ef1e37726"
|
||||
dependencies = [
|
||||
"bytes 0.5.6",
|
||||
"bytes",
|
||||
"fnv",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
@ -694,7 +672,6 @@ dependencies = [
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tracing",
|
||||
"tracing-futures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -733,19 +710,20 @@ version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "527e8c9ac747e28542699a951517aa9a6945af506cd1f2e1b53a576c17b6cc11"
|
||||
dependencies = [
|
||||
"bytes 1.0.1",
|
||||
"bytes",
|
||||
"fnv",
|
||||
"itoa",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http-body"
|
||||
version = "0.3.1"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b"
|
||||
checksum = "399c583b2979440c60be0821a6199eca73bc3c8dcd9d070d75ac726e2c6186e5"
|
||||
dependencies = [
|
||||
"bytes 0.5.6",
|
||||
"bytes",
|
||||
"http",
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -756,9 +734,9 @@ checksum = "f3a87b616e37e93c22fb19bcd386f02f3af5ea98a25670ad0fce773de23c5e68"
|
||||
|
||||
[[package]]
|
||||
name = "httpdate"
|
||||
version = "0.3.2"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47"
|
||||
checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440"
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
@ -771,11 +749,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.13.10"
|
||||
version = "0.14.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a6f157065790a3ed2f88679250419b5cdd96e714a0d65f7797fd337186e96bb"
|
||||
checksum = "0b61cf2d1aebcf6e6352c97b81dc2244ca29194be1b276f5d8ad5c6330fffb11"
|
||||
dependencies = [
|
||||
"bytes 0.5.6",
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
@ -785,7 +763,7 @@ dependencies = [
|
||||
"httparse",
|
||||
"httpdate",
|
||||
"itoa",
|
||||
"pin-project",
|
||||
"pin-project-lite",
|
||||
"socket2",
|
||||
"tokio",
|
||||
"tower-service",
|
||||
@ -795,15 +773,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hyper-tls"
|
||||
version = "0.4.3"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d979acc56dcb5b8dddba3917601745e877576475aa046df3226eabdecef78eed"
|
||||
checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
|
||||
dependencies = [
|
||||
"bytes 0.5.6",
|
||||
"bytes",
|
||||
"hyper",
|
||||
"native-tls",
|
||||
"tokio",
|
||||
"tokio-tls",
|
||||
"tokio-native-tls",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -840,15 +818,6 @@ dependencies = [
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iovec"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ipnet"
|
||||
version = "2.3.1"
|
||||
@ -920,16 +889,6 @@ dependencies = [
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kernel32-sys"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||
dependencies = [
|
||||
"winapi 0.2.8",
|
||||
"winapi-build",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
@ -1044,16 +1003,6 @@ version = "0.3.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
|
||||
|
||||
[[package]]
|
||||
name = "mime_guess"
|
||||
version = "2.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212"
|
||||
dependencies = [
|
||||
"mime",
|
||||
"unicase",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.4.4"
|
||||
@ -1066,33 +1015,24 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "0.6.23"
|
||||
version = "0.7.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4"
|
||||
checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10",
|
||||
"fuchsia-zircon",
|
||||
"fuchsia-zircon-sys",
|
||||
"iovec",
|
||||
"kernel32-sys",
|
||||
"libc",
|
||||
"log",
|
||||
"miow",
|
||||
"net2",
|
||||
"slab",
|
||||
"winapi 0.2.8",
|
||||
"ntapi",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miow"
|
||||
version = "0.2.2"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d"
|
||||
checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21"
|
||||
dependencies = [
|
||||
"kernel32-sys",
|
||||
"net2",
|
||||
"winapi 0.2.8",
|
||||
"ws2_32-sys",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1104,7 +1044,7 @@ dependencies = [
|
||||
"napi-sys",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"winapi 0.3.9",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1148,17 +1088,6 @@ dependencies = [
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "net2"
|
||||
version = "0.2.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10",
|
||||
"libc",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "new_debug_unreachable"
|
||||
version = "1.0.4"
|
||||
@ -1207,7 +1136,16 @@ version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a9da8c9922c35a1033d76f7272dfc2e7ee20392083d75aeea6ced23c6266578"
|
||||
dependencies = [
|
||||
"winapi 0.3.9",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ntapi"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1361,7 +1299,7 @@ version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9"
|
||||
dependencies = [
|
||||
"winapi 0.3.9",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1393,7 +1331,7 @@ dependencies = [
|
||||
"rand 0.6.5",
|
||||
"rustc_version",
|
||||
"smallvec 0.6.14",
|
||||
"winapi 0.3.9",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1468,32 +1406,6 @@ dependencies = [
|
||||
"siphasher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project"
|
||||
version = "1.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "576bc800220cc65dac09e99e97b08b358cfab6e17078de8dc5fee223bd2d0c08"
|
||||
dependencies = [
|
||||
"pin-project-internal",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-internal"
|
||||
version = "1.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e8fe8163d14ce7f0cdac2e040116f22eac817edabff0be91e8aff7e9accf389"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.7"
|
||||
@ -1631,7 +1543,7 @@ dependencies = [
|
||||
"rand_os",
|
||||
"rand_pcg 0.1.2",
|
||||
"rand_xorshift",
|
||||
"winapi 0.3.9",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1767,7 +1679,7 @@ checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_core 0.4.2",
|
||||
"winapi 0.3.9",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1781,7 +1693,7 @@ dependencies = [
|
||||
"libc",
|
||||
"rand_core 0.4.2",
|
||||
"rdrand",
|
||||
"winapi 0.3.9",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1884,17 +1796,17 @@ version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
|
||||
dependencies = [
|
||||
"winapi 0.3.9",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "reqwest"
|
||||
version = "0.10.10"
|
||||
version = "0.11.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0718f81a8e14c4dbb3b34cf23dc6aaf9ab8a0dfec160c534b3dbca1aaa21f47c"
|
||||
checksum = "246e9f61b9bb77df069a947682be06e31ac43ea37862e244a69f177694ea6d22"
|
||||
dependencies = [
|
||||
"base64 0.13.0",
|
||||
"bytes 0.5.6",
|
||||
"bytes",
|
||||
"encoding_rs",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
@ -1907,14 +1819,13 @@ dependencies = [
|
||||
"lazy_static",
|
||||
"log",
|
||||
"mime",
|
||||
"mime_guess",
|
||||
"native-tls",
|
||||
"percent-encoding",
|
||||
"pin-project-lite 0.2.7",
|
||||
"pin-project-lite",
|
||||
"serde",
|
||||
"serde_urlencoded",
|
||||
"tokio",
|
||||
"tokio-tls",
|
||||
"tokio-native-tls",
|
||||
"url",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
@ -1965,7 +1876,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"winapi 0.3.9",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2120,13 +2031,12 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.3.19"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e"
|
||||
checksum = "765f090f0e423d2b55843402a07915add955e7d60657db13707a159727326cad"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
"winapi 0.3.9",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2607,7 +2517,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_transforms_base"
|
||||
version = "0.26.0"
|
||||
version = "0.26.1"
|
||||
dependencies = [
|
||||
"fxhash",
|
||||
"once_cell",
|
||||
@ -2638,7 +2548,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_transforms_compat"
|
||||
version = "0.29.0"
|
||||
version = "0.29.1"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"fxhash",
|
||||
@ -2922,7 +2832,7 @@ dependencies = [
|
||||
"rand 0.8.4",
|
||||
"redox_syscall",
|
||||
"remove_dir_all",
|
||||
"winapi 0.3.9",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2970,7 +2880,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi 0.3.9",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2999,27 +2909,25 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "0.2.25"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092"
|
||||
checksum = "4b7b349f11a7047e6d1276853e612d152f5e8a352c61917887cc2169e2366b4c"
|
||||
dependencies = [
|
||||
"bytes 0.5.6",
|
||||
"fnv",
|
||||
"futures-core",
|
||||
"iovec",
|
||||
"lazy_static",
|
||||
"autocfg 1.0.1",
|
||||
"bytes",
|
||||
"libc",
|
||||
"memchr",
|
||||
"mio",
|
||||
"num_cpus",
|
||||
"pin-project-lite 0.1.12",
|
||||
"slab",
|
||||
"pin-project-lite",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-tls"
|
||||
version = "0.3.1"
|
||||
name = "tokio-native-tls"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343"
|
||||
checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b"
|
||||
dependencies = [
|
||||
"native-tls",
|
||||
"tokio",
|
||||
@ -3027,15 +2935,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tokio-util"
|
||||
version = "0.3.1"
|
||||
version = "0.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499"
|
||||
checksum = "1caa0b0c8d94a049db56b5acf8cba99dc0623aab1b26d5b5f5e2d945846b3592"
|
||||
dependencies = [
|
||||
"bytes 0.5.6",
|
||||
"bytes",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"log",
|
||||
"pin-project-lite 0.1.12",
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
@ -3061,8 +2969,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"log",
|
||||
"pin-project-lite 0.2.7",
|
||||
"pin-project-lite",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
@ -3075,16 +2982,6 @@ dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-futures"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
|
||||
dependencies = [
|
||||
"pin-project",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "try-lock"
|
||||
version = "0.2.3"
|
||||
@ -3097,15 +2994,6 @@ version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06"
|
||||
|
||||
[[package]]
|
||||
name = "unicase"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
|
||||
dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.5"
|
||||
@ -3167,7 +3055,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
|
||||
dependencies = [
|
||||
"same-file",
|
||||
"winapi 0.3.9",
|
||||
"winapi",
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
@ -3195,7 +3083,7 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
||||
|
||||
[[package]]
|
||||
name = "wasm"
|
||||
version = "1.2.75"
|
||||
version = "1.2.76"
|
||||
dependencies = [
|
||||
"console_error_panic_hook",
|
||||
"once_cell",
|
||||
@ -3287,12 +3175,6 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
@ -3303,12 +3185,6 @@ dependencies = [
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-build"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
@ -3321,7 +3197,7 @@ version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi 0.3.9",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3336,15 +3212,5 @@ version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69"
|
||||
dependencies = [
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ws2_32-sys"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
|
||||
dependencies = [
|
||||
"winapi 0.2.8",
|
||||
"winapi-build",
|
||||
"winapi",
|
||||
]
|
||||
|
@ -44,7 +44,7 @@ swc_ecma_visit = {version = "0.35.0", path = "../ecmascript/visit"}
|
||||
[dev-dependencies]
|
||||
hex = "0.4"
|
||||
ntest = "0.7.2"
|
||||
reqwest = {version = "0.10.8", features = ["blocking"]}
|
||||
reqwest = {version = "0.11.4", features = ["blocking"]}
|
||||
sha-1 = "0.9"
|
||||
swc_ecma_transforms = {version = "0.63.0", path = "../ecmascript/transforms", features = ["react", "typescript"]}
|
||||
tempfile = "3.1.0"
|
||||
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecma_transforms_base"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.26.0"
|
||||
version = "0.26.1"
|
||||
|
||||
[dependencies]
|
||||
fxhash = "0.2.1"
|
||||
|
@ -0,0 +1,7 @@
|
||||
class Item extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
input = this.props.item;
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
class Item extends Component {
|
||||
constructor(props){
|
||||
super(props);
|
||||
}
|
||||
input = this.props.item;
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
class Item extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
input = this.props.item;
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
class Item extends Component {
|
||||
constructor(props__2){
|
||||
super(props__2);
|
||||
}
|
||||
input__0 = this.props.item;
|
||||
}
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
license = "Apache-2.0/MIT"
|
||||
name = "swc_ecma_transforms_compat"
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "0.29.0"
|
||||
version = "0.29.1"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
@ -70,6 +70,8 @@ impl BlockScoping {
|
||||
where
|
||||
T: FoldWith<Self>,
|
||||
{
|
||||
let len = self.scope.len();
|
||||
|
||||
let remove = match kind {
|
||||
ScopeKind::ForLetLoop { .. } => false,
|
||||
_ => true,
|
||||
@ -78,7 +80,7 @@ impl BlockScoping {
|
||||
let node = node.fold_with(self);
|
||||
|
||||
if remove {
|
||||
self.scope.pop();
|
||||
self.scope.truncate(len);
|
||||
}
|
||||
|
||||
node
|
||||
@ -433,6 +435,14 @@ impl Fold for BlockScoping {
|
||||
}
|
||||
}
|
||||
|
||||
fn fold_block_stmt(&mut self, n: BlockStmt) -> BlockStmt {
|
||||
let vars = take(&mut self.vars);
|
||||
let n = n.fold_children_with(self);
|
||||
debug_assert_eq!(self.vars, vec![]);
|
||||
self.vars = vars;
|
||||
n
|
||||
}
|
||||
|
||||
fn fold_constructor(&mut self, f: Constructor) -> Constructor {
|
||||
Constructor {
|
||||
key: f.key.fold_with(self),
|
||||
@ -567,6 +577,10 @@ impl Fold for BlockScoping {
|
||||
node
|
||||
}
|
||||
|
||||
fn fold_module_items(&mut self, n: Vec<ModuleItem>) -> Vec<ModuleItem> {
|
||||
self.fold_stmt_like(n)
|
||||
}
|
||||
|
||||
fn fold_setter_prop(&mut self, f: SetterProp) -> SetterProp {
|
||||
SetterProp {
|
||||
key: f.key.fold_with(self),
|
||||
@ -576,6 +590,10 @@ impl Fold for BlockScoping {
|
||||
}
|
||||
}
|
||||
|
||||
fn fold_stmts(&mut self, n: Vec<Stmt>) -> Vec<Stmt> {
|
||||
self.fold_stmt_like(n)
|
||||
}
|
||||
|
||||
fn fold_var_decl(&mut self, var: VarDecl) -> VarDecl {
|
||||
let old = self.var_decl_kind;
|
||||
self.var_decl_kind = var.kind;
|
||||
@ -612,22 +630,6 @@ impl Fold for BlockScoping {
|
||||
|
||||
WhileStmt { body, test, ..node }
|
||||
}
|
||||
|
||||
fn fold_block_stmt(&mut self, n: BlockStmt) -> BlockStmt {
|
||||
let vars = take(&mut self.vars);
|
||||
let n = n.fold_children_with(self);
|
||||
debug_assert_eq!(self.vars, vec![]);
|
||||
self.vars = vars;
|
||||
n
|
||||
}
|
||||
|
||||
fn fold_module_items(&mut self, n: Vec<ModuleItem>) -> Vec<ModuleItem> {
|
||||
self.fold_stmt_like(n)
|
||||
}
|
||||
|
||||
fn fold_stmts(&mut self, n: Vec<Stmt>) -> Vec<Stmt> {
|
||||
self.fold_stmt_like(n)
|
||||
}
|
||||
}
|
||||
|
||||
impl BlockScoping {
|
||||
@ -994,6 +996,10 @@ struct FunctionFinder {
|
||||
impl Visit for FunctionFinder {
|
||||
noop_visit_type!();
|
||||
|
||||
fn visit_arrow_expr(&mut self, _: &ArrowExpr, _: &dyn Node) {
|
||||
self.found = true;
|
||||
}
|
||||
|
||||
fn visit_function(&mut self, _: &Function, _: &dyn Node) {
|
||||
self.found = true
|
||||
}
|
||||
|
@ -580,7 +580,14 @@ impl CaseHandler<'_> {
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
let right = e.right.map(|e| self.explode_expr(e, false));
|
||||
let right = e.right.map(|e| {
|
||||
self.explode_expr_via_temp_var(
|
||||
result.clone(),
|
||||
has_leaping_children,
|
||||
e,
|
||||
ignore_result,
|
||||
)
|
||||
});
|
||||
|
||||
self.mark(after);
|
||||
|
||||
|
@ -1,11 +1,8 @@
|
||||
use self::{
|
||||
class_name_tdz::ClassNameTdzFolder,
|
||||
private_field::FieldAccessFolder,
|
||||
this_in_static::ThisInStaticFolder,
|
||||
used_name::{UsedNameCollector, UsedNameRenamer},
|
||||
class_name_tdz::ClassNameTdzFolder, private_field::FieldAccessFolder,
|
||||
this_in_static::ThisInStaticFolder, used_name::UsedNameCollector,
|
||||
};
|
||||
use std::{collections::HashSet, mem::take};
|
||||
use swc_atoms::JsWord;
|
||||
use swc_common::SyntaxContext;
|
||||
use swc_common::{util::move_map::MoveMap, Mark, Spanned, DUMMY_SP};
|
||||
use swc_ecma_ast::*;
|
||||
@ -734,8 +731,7 @@ impl ClassProperties {
|
||||
typescript_constructor_properties
|
||||
};
|
||||
|
||||
let constructor =
|
||||
self.process_constructor(constructor, has_super, &used_names, constructor_exprs);
|
||||
let constructor = self.process_constructor(constructor, has_super, constructor_exprs);
|
||||
if let Some(c) = constructor {
|
||||
members.push(ClassMember::Constructor(c));
|
||||
}
|
||||
@ -808,45 +804,15 @@ impl ClassProperties {
|
||||
&mut self,
|
||||
constructor: Option<Constructor>,
|
||||
has_super: bool,
|
||||
used_names: &[JsWord],
|
||||
constructor_exprs: Vec<Box<Expr>>,
|
||||
) -> Option<Constructor> {
|
||||
let constructor = constructor
|
||||
.map(|c| {
|
||||
if self.typescript {
|
||||
c
|
||||
} else {
|
||||
let mut folder = UsedNameRenamer {
|
||||
mark: Mark::fresh(Mark::root()),
|
||||
used_names,
|
||||
};
|
||||
|
||||
// Handle collisions like
|
||||
//
|
||||
// var foo = "bar";
|
||||
//
|
||||
// class Foo {
|
||||
// bar = foo;
|
||||
// static bar = baz;
|
||||
//
|
||||
// constructor() {
|
||||
// var foo = "foo";
|
||||
// var baz = "baz";
|
||||
// }
|
||||
// }
|
||||
let body = c.body.fold_with(&mut folder);
|
||||
|
||||
let params = c.params.fold_with(&mut folder);
|
||||
Constructor { body, params, ..c }
|
||||
}
|
||||
})
|
||||
.or_else(|| {
|
||||
if constructor_exprs.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(default_constructor(has_super))
|
||||
}
|
||||
});
|
||||
let constructor = constructor.or_else(|| {
|
||||
if constructor_exprs.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(default_constructor(has_super))
|
||||
}
|
||||
});
|
||||
|
||||
if let Some(mut c) = constructor {
|
||||
// Prepend properties
|
@ -1,50 +1,7 @@
|
||||
use swc_atoms::JsWord;
|
||||
use swc_common::Mark;
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_visit::noop_visit_type;
|
||||
use swc_ecma_visit::{noop_fold_type, Fold, FoldWith, Node, Visit, VisitWith};
|
||||
|
||||
/// Used to rename **binding** identifiers in constructor.
|
||||
pub(super) struct UsedNameRenamer<'a> {
|
||||
pub mark: Mark,
|
||||
pub used_names: &'a [JsWord],
|
||||
}
|
||||
|
||||
impl<'a> Fold for UsedNameRenamer<'a> {
|
||||
noop_fold_type!();
|
||||
|
||||
fn fold_expr(&mut self, e: Expr) -> Expr {
|
||||
match e {
|
||||
Expr::Ident(..) => e,
|
||||
_ => e.fold_children_with(self),
|
||||
}
|
||||
}
|
||||
|
||||
fn fold_ident(&mut self, ident: Ident) -> Ident {
|
||||
if self.used_names.contains(&ident.sym) {
|
||||
return Ident {
|
||||
span: ident.span.apply_mark(self.mark),
|
||||
..ident
|
||||
};
|
||||
}
|
||||
ident
|
||||
}
|
||||
|
||||
fn fold_member_expr(&mut self, e: MemberExpr) -> MemberExpr {
|
||||
if e.computed {
|
||||
MemberExpr {
|
||||
obj: e.obj.fold_with(self),
|
||||
prop: e.prop.fold_with(self),
|
||||
..e
|
||||
}
|
||||
} else {
|
||||
MemberExpr {
|
||||
obj: e.obj.fold_with(self),
|
||||
..e
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
use swc_ecma_visit::{Node, Visit, VisitWith};
|
||||
|
||||
pub(super) struct UsedNameCollector<'a> {
|
||||
pub used_names: &'a mut Vec<JsWord>,
|
||||
|
@ -587,49 +587,50 @@ test!(
|
||||
|_| block_scoping(),
|
||||
issue_1231_1,
|
||||
"
|
||||
function combineOverlappingMatches(matches) {
|
||||
let hasOverlaps = false
|
||||
function combineOverlappingMatches(matches) {
|
||||
let hasOverlaps = false
|
||||
|
||||
for (let i = matches.length - 1; i >= 0; i--) {
|
||||
let currentMatch = matches[i]
|
||||
let overlap = matches.find(match => {
|
||||
return match !== currentMatch && match.itemsType === currentMatch.itemsType
|
||||
})
|
||||
|
||||
for (let i = matches.length - 1; i >= 0; i--) {
|
||||
let currentMatch = matches[i]
|
||||
let overlap = matches.find(match => {
|
||||
return match !== currentMatch && match.itemsType === currentMatch.itemsType
|
||||
})
|
||||
|
||||
if (overlap) {
|
||||
hasOverlaps = true
|
||||
matches.splice(i, 1)
|
||||
}
|
||||
}
|
||||
|
||||
if (hasOverlaps) {
|
||||
combineOverlappingMatches(matches)
|
||||
if (overlap) {
|
||||
hasOverlaps = true
|
||||
matches.splice(i, 1)
|
||||
}
|
||||
}
|
||||
|
||||
combineOverlappingMatches([1])
|
||||
",
|
||||
"
|
||||
function combineOverlappingMatches(matches) {
|
||||
var hasOverlaps = false;
|
||||
for(var i = matches.length - 1; i >= 0; i--){
|
||||
var currentMatch = matches[i];
|
||||
var overlap = matches.find((match)=>{
|
||||
return match !== currentMatch && match.itemsType === currentMatch.itemsType;
|
||||
});
|
||||
if (overlap) {
|
||||
hasOverlaps = true;
|
||||
matches.splice(i, 1);
|
||||
}
|
||||
}
|
||||
if (hasOverlaps) {
|
||||
combineOverlappingMatches(matches);
|
||||
}
|
||||
if (hasOverlaps) {
|
||||
combineOverlappingMatches(matches)
|
||||
}
|
||||
combineOverlappingMatches([
|
||||
1
|
||||
]);
|
||||
"
|
||||
}
|
||||
|
||||
combineOverlappingMatches([1])
|
||||
",
|
||||
"
|
||||
function combineOverlappingMatches(matches) {
|
||||
var _loop = function(i) {
|
||||
var currentMatch = matches[i];
|
||||
var overlap = matches.find((match)=>{
|
||||
return match !== currentMatch && match.itemsType === currentMatch.itemsType;
|
||||
});
|
||||
if (overlap) {
|
||||
hasOverlaps = true;
|
||||
matches.splice(i, 1);
|
||||
}
|
||||
};
|
||||
var hasOverlaps = false;
|
||||
for(var i = matches.length - 1; i >= 0; i--)_loop(i);
|
||||
if (hasOverlaps) {
|
||||
combineOverlappingMatches(matches);
|
||||
}
|
||||
}
|
||||
combineOverlappingMatches([
|
||||
1
|
||||
]);
|
||||
"
|
||||
);
|
||||
|
||||
test!(
|
||||
@ -637,72 +638,73 @@ test!(
|
||||
|_| block_scoping(),
|
||||
issue_1415_1,
|
||||
"
|
||||
export function test(items) {
|
||||
const infoMap = new WeakMap();
|
||||
for (let i = 0; i < items.length; i += 1) {
|
||||
const item = items[i];
|
||||
let info;
|
||||
switch (item.type) {
|
||||
case 'branch1':
|
||||
info = item.method1();
|
||||
break;
|
||||
case 'branch2':
|
||||
info = item.method2();
|
||||
break;
|
||||
case 'branch3':
|
||||
info = item.method3(
|
||||
Object.fromEntries(
|
||||
item.subItems.map((t) => [item.alias ?? t.name, getInfo(t)])
|
||||
)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
throw new Error('boom');
|
||||
}
|
||||
infoMap.set(item, info); // important
|
||||
}
|
||||
|
||||
function getInfo(item) {
|
||||
if (!infoMap.has(item)) {
|
||||
throw new Error('no info yet');
|
||||
}
|
||||
return infoMap.get(item);
|
||||
}
|
||||
}
|
||||
",
|
||||
"
|
||||
export function test(items) {
|
||||
var infoMap = new WeakMap();
|
||||
for(var i = 0; i < items.length; i += 1){
|
||||
var item = items[i];
|
||||
var info = void 0;
|
||||
switch(item.type){
|
||||
case 'branch1':
|
||||
info = item.method1();
|
||||
break;
|
||||
case 'branch2':
|
||||
info = item.method2();
|
||||
break;
|
||||
case 'branch3':
|
||||
info = item.method3(Object.fromEntries(item.subItems.map((t)=>[
|
||||
item.alias ?? t.name,
|
||||
getInfo(t)
|
||||
]
|
||||
)));
|
||||
break;
|
||||
default:
|
||||
throw new Error('boom');
|
||||
}
|
||||
infoMap.set(item, info);
|
||||
}
|
||||
function getInfo(item) {
|
||||
if (!infoMap.has(item)) {
|
||||
throw new Error('no info yet');
|
||||
}
|
||||
return infoMap.get(item);
|
||||
export function test(items) {
|
||||
const infoMap = new WeakMap();
|
||||
for (let i = 0; i < items.length; i += 1) {
|
||||
const item = items[i];
|
||||
let info;
|
||||
switch (item.type) {
|
||||
case 'branch1':
|
||||
info = item.method1();
|
||||
break;
|
||||
case 'branch2':
|
||||
info = item.method2();
|
||||
break;
|
||||
case 'branch3':
|
||||
info = item.method3(
|
||||
Object.fromEntries(
|
||||
item.subItems.map((t) => [item.alias ?? t.name, getInfo(t)])
|
||||
)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
throw new Error('boom');
|
||||
}
|
||||
infoMap.set(item, info); // important
|
||||
}
|
||||
"
|
||||
|
||||
function getInfo(item) {
|
||||
if (!infoMap.has(item)) {
|
||||
throw new Error('no info yet');
|
||||
}
|
||||
return infoMap.get(item);
|
||||
}
|
||||
}
|
||||
",
|
||||
"
|
||||
export function test(items) {
|
||||
var _loop = function(i) {
|
||||
var item = items[i];
|
||||
var info = void 0;
|
||||
switch(item.type){
|
||||
case 'branch1':
|
||||
info = item.method1();
|
||||
break;
|
||||
case 'branch2':
|
||||
info = item.method2();
|
||||
break;
|
||||
case 'branch3':
|
||||
info = item.method3(Object.fromEntries(item.subItems.map((t)=>[
|
||||
item.alias ?? t.name,
|
||||
getInfo(t)
|
||||
]
|
||||
)));
|
||||
break;
|
||||
default:
|
||||
throw new Error('boom');
|
||||
}
|
||||
infoMap.set(item, info);
|
||||
};
|
||||
var infoMap = new WeakMap();
|
||||
for(var i = 0; i < items.length; i += 1)_loop(i);
|
||||
function getInfo(item) {
|
||||
if (!infoMap.has(item)) {
|
||||
throw new Error('no info yet');
|
||||
}
|
||||
return infoMap.get(item);
|
||||
}
|
||||
}
|
||||
"
|
||||
);
|
||||
|
||||
test!(
|
||||
@ -882,3 +884,79 @@ test!(
|
||||
}
|
||||
"
|
||||
);
|
||||
|
||||
test!(
|
||||
::swc_ecma_parser::Syntax::default(),
|
||||
|_| block_scoping(),
|
||||
issue_2027_1,
|
||||
"
|
||||
const keys = {
|
||||
a: 1,
|
||||
b: 2,
|
||||
}
|
||||
|
||||
const controller = {}
|
||||
|
||||
for (const key in keys) {
|
||||
controller[key] = (c, ...d) => {
|
||||
console.log(keys[key])
|
||||
}
|
||||
}
|
||||
",
|
||||
"
|
||||
var _loop = function(key) {
|
||||
controller[key] = (c, ...d)=>{
|
||||
console.log(keys[key]);
|
||||
};
|
||||
};
|
||||
var keys = {
|
||||
a: 1,
|
||||
b: 2
|
||||
};
|
||||
var controller = {
|
||||
};
|
||||
for(var key in keys)_loop(key);
|
||||
"
|
||||
);
|
||||
|
||||
test!(
|
||||
::swc_ecma_parser::Syntax::default(),
|
||||
|t| {
|
||||
let mark = Mark::fresh(Mark::root());
|
||||
|
||||
es2015(mark, Some(t.comments.clone()), Default::default())
|
||||
},
|
||||
issue_2027_2,
|
||||
"
|
||||
const keys = {
|
||||
a: 1,
|
||||
b: 2,
|
||||
}
|
||||
|
||||
const controller = {}
|
||||
|
||||
for (const key in keys) {
|
||||
controller[key] = (c, ...d) => {
|
||||
console.log(keys[key])
|
||||
}
|
||||
}
|
||||
",
|
||||
"
|
||||
var _loop = function(key) {
|
||||
controller[key] = function(c) {
|
||||
for(var _len = arguments.length, d = new Array(_len > 1 ? _len - 1 : 0), _key = 1; \
|
||||
_key < _len; _key++){
|
||||
d[_key - 1] = arguments[_key];
|
||||
}
|
||||
console.log(keys[key]);
|
||||
};
|
||||
};
|
||||
var keys = {
|
||||
a: 1,
|
||||
b: 2
|
||||
};
|
||||
var controller = {
|
||||
};
|
||||
for(var key in keys)_loop(key);
|
||||
"
|
||||
);
|
||||
|
@ -1615,3 +1615,52 @@ test!(
|
||||
});
|
||||
"#
|
||||
);
|
||||
|
||||
test!(
|
||||
Syntax::default(),
|
||||
|_| {
|
||||
let mark = Mark::fresh(Mark::root());
|
||||
es2015::<SingleThreadedComments>(mark, None, Default::default())
|
||||
},
|
||||
issue_2024_1,
|
||||
"
|
||||
_asyncToGenerator(function*() {
|
||||
const sleep = ()=>new Promise((resolve)=>setTimeout(()=>resolve(undefined), 500));
|
||||
const result = (yield sleep()) || 'fallback';
|
||||
console.log(result);
|
||||
})();
|
||||
",
|
||||
"
|
||||
var regeneratorRuntime = require('regenerator-runtime');
|
||||
_asyncToGenerator(regeneratorRuntime.mark(function _callee() {
|
||||
var sleep, result;
|
||||
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
||||
while(1)switch(_ctx.prev = _ctx.next){
|
||||
case 0:
|
||||
sleep = function() {
|
||||
return new Promise(function(resolve) {
|
||||
return setTimeout(function() {
|
||||
return resolve(undefined);
|
||||
}, 500);
|
||||
});
|
||||
};
|
||||
_ctx.next = 3;
|
||||
return sleep();
|
||||
case 3:
|
||||
_ctx.t0 = _ctx.sent;
|
||||
if (_ctx.t0) {
|
||||
_ctx.next = 6;
|
||||
break;
|
||||
}
|
||||
_ctx.t0 = 'fallback';
|
||||
case 6:
|
||||
result = _ctx.t0;
|
||||
console.log(result);
|
||||
case 8:
|
||||
case 'end':
|
||||
return _ctx.stop();
|
||||
}
|
||||
}, _callee);
|
||||
}))();
|
||||
"
|
||||
);
|
||||
|
@ -2586,15 +2586,17 @@ test!(
|
||||
case 0:
|
||||
_ctx.t0 = cache[key];
|
||||
if (_ctx.t0) {
|
||||
_ctx.next = 4;
|
||||
_ctx.next = 5;
|
||||
break;
|
||||
}
|
||||
_ctx.next = 4;
|
||||
return fetchThing(key);
|
||||
case 4:
|
||||
_ctx.t0 = _ctx.sent;
|
||||
case 5:
|
||||
it = _ctx.t0;
|
||||
return _ctx.abrupt('return', it);
|
||||
case 6:
|
||||
case 7:
|
||||
case 'end':
|
||||
return _ctx.stop();
|
||||
}
|
||||
|
@ -3779,7 +3779,7 @@ var qux = function() {
|
||||
|
||||
(function () {
|
||||
class Baz {
|
||||
constructor(force1){
|
||||
constructor(force){
|
||||
_defineProperty(this, 'fn', (function() {
|
||||
return console.log(this);
|
||||
}).bind(this));
|
||||
@ -5542,3 +5542,26 @@ test!(
|
||||
}
|
||||
"
|
||||
);
|
||||
|
||||
test!(
|
||||
syntax(),
|
||||
|_| class_properties(),
|
||||
issue_2021_1,
|
||||
"
|
||||
class Item extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
input = this.props.item;
|
||||
}
|
||||
",
|
||||
"
|
||||
class Item extends Component {
|
||||
constructor(props){
|
||||
super(props);
|
||||
_defineProperty(this, 'input', this.props.item);
|
||||
}
|
||||
}
|
||||
"
|
||||
);
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@swc/core",
|
||||
"version": "1.2.75",
|
||||
"version": "1.2.76",
|
||||
"description": "Super-fast alternative for babel",
|
||||
"homepage": "https://swc.rs",
|
||||
"main": "./index.js",
|
||||
|
5
tests/fixture/issue-1734/case1-B/input/.swcrc
Normal file
5
tests/fixture/issue-1734/case1-B/input/.swcrc
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"module": {
|
||||
"type": "commonjs"
|
||||
}
|
||||
}
|
4
tests/fixture/issue-1734/case1-B/input/index.js
Normal file
4
tests/fixture/issue-1734/case1-B/input/index.js
Normal file
@ -0,0 +1,4 @@
|
||||
import { foo } from './A'
|
||||
import baz from './A'
|
||||
|
||||
console.log(baz, foo)
|
8
tests/fixture/issue-1734/case1-B/output/index.js
Normal file
8
tests/fixture/issue-1734/case1-B/output/index.js
Normal file
@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
var _a = _interopRequireWildcard(require("./A"));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
console.log(_a.default, _a.foo);
|
5
tests/fixture/issue-1734/case2-C/input/.swcrc
Normal file
5
tests/fixture/issue-1734/case2-C/input/.swcrc
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"module": {
|
||||
"type": "commonjs"
|
||||
}
|
||||
}
|
3
tests/fixture/issue-1734/case2-C/input/index.js
Normal file
3
tests/fixture/issue-1734/case2-C/input/index.js
Normal file
@ -0,0 +1,3 @@
|
||||
import baz, { foo } from './A'
|
||||
|
||||
console.log(baz, foo) // <-- baz foo
|
27
tests/fixture/issue-1734/case2-C/output/index.js
Normal file
27
tests/fixture/issue-1734/case2-C/output/index.js
Normal file
@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
var _a = _interopRequireWildcard(require("./A"));
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
} else {
|
||||
var newObj = {
|
||||
};
|
||||
if (obj != null) {
|
||||
for(var key in obj){
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
|
||||
};
|
||||
if (desc.get || desc.set) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
return newObj;
|
||||
}
|
||||
}
|
||||
console.log(_a.default, _a.foo) // <-- baz foo
|
||||
;
|
5
tests/fixture/issue-1734/case3-D/input/.swcrc
Normal file
5
tests/fixture/issue-1734/case3-D/input/.swcrc
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"module": {
|
||||
"type": "commonjs"
|
||||
}
|
||||
}
|
4
tests/fixture/issue-1734/case3-D/input/index.js
Normal file
4
tests/fixture/issue-1734/case3-D/input/index.js
Normal file
@ -0,0 +1,4 @@
|
||||
import baz from './A'
|
||||
import { foo } from './A'
|
||||
|
||||
console.log(baz, foo)
|
26
tests/fixture/issue-1734/case3-D/output/index.js
Normal file
26
tests/fixture/issue-1734/case3-D/output/index.js
Normal file
@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
var _a = _interopRequireWildcard(require("./A"));
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
} else {
|
||||
var newObj = {
|
||||
};
|
||||
if (obj != null) {
|
||||
for(var key in obj){
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
|
||||
};
|
||||
if (desc.get || desc.set) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
return newObj;
|
||||
}
|
||||
}
|
||||
console.log(_a.default, _a.foo);
|
5
tests/fixture/issue-2021/es2016/input/.swcrc
Normal file
5
tests/fixture/issue-2021/es2016/input/.swcrc
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"jsc": {
|
||||
"target": "es2016"
|
||||
}
|
||||
}
|
7
tests/fixture/issue-2021/es2016/input/index.js
Normal file
7
tests/fixture/issue-2021/es2016/input/index.js
Normal file
@ -0,0 +1,7 @@
|
||||
class Item extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
input = this.props.item;
|
||||
}
|
19
tests/fixture/issue-2021/es2016/output/index.js
Normal file
19
tests/fixture/issue-2021/es2016/output/index.js
Normal file
@ -0,0 +1,19 @@
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
class Item extends Component {
|
||||
constructor(props){
|
||||
super(props);
|
||||
_defineProperty(this, "input", this.props.item);
|
||||
}
|
||||
}
|
5
tests/fixture/issue-2021/es2017/input/.swcrc
Normal file
5
tests/fixture/issue-2021/es2017/input/.swcrc
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"jsc": {
|
||||
"target": "es2017"
|
||||
}
|
||||
}
|
7
tests/fixture/issue-2021/es2017/input/index.js
Normal file
7
tests/fixture/issue-2021/es2017/input/index.js
Normal file
@ -0,0 +1,7 @@
|
||||
class Item extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
input = this.props.item;
|
||||
}
|
19
tests/fixture/issue-2021/es2017/output/index.js
Normal file
19
tests/fixture/issue-2021/es2017/output/index.js
Normal file
@ -0,0 +1,19 @@
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
class Item extends Component {
|
||||
constructor(props){
|
||||
super(props);
|
||||
_defineProperty(this, "input", this.props.item);
|
||||
}
|
||||
}
|
5
tests/fixture/issue-2021/es2018/input/.swcrc
Normal file
5
tests/fixture/issue-2021/es2018/input/.swcrc
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"jsc": {
|
||||
"target": "es2018"
|
||||
}
|
||||
}
|
7
tests/fixture/issue-2021/es2018/input/index.js
Normal file
7
tests/fixture/issue-2021/es2018/input/index.js
Normal file
@ -0,0 +1,7 @@
|
||||
class Item extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
input = this.props.item;
|
||||
}
|
19
tests/fixture/issue-2021/es2018/output/index.js
Normal file
19
tests/fixture/issue-2021/es2018/output/index.js
Normal file
@ -0,0 +1,19 @@
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
class Item extends Component {
|
||||
constructor(props){
|
||||
super(props);
|
||||
_defineProperty(this, "input", this.props.item);
|
||||
}
|
||||
}
|
5
tests/fixture/issue-2021/es2019/input/.swcrc
Normal file
5
tests/fixture/issue-2021/es2019/input/.swcrc
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"jsc": {
|
||||
"target": "es2019"
|
||||
}
|
||||
}
|
7
tests/fixture/issue-2021/es2019/input/index.js
Normal file
7
tests/fixture/issue-2021/es2019/input/index.js
Normal file
@ -0,0 +1,7 @@
|
||||
class Item extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
input = this.props.item;
|
||||
}
|
19
tests/fixture/issue-2021/es2019/output/index.js
Normal file
19
tests/fixture/issue-2021/es2019/output/index.js
Normal file
@ -0,0 +1,19 @@
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
class Item extends Component {
|
||||
constructor(props){
|
||||
super(props);
|
||||
_defineProperty(this, "input", this.props.item);
|
||||
}
|
||||
}
|
5
tests/fixture/issue-2021/es2020/input/.swcrc
Normal file
5
tests/fixture/issue-2021/es2020/input/.swcrc
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"jsc": {
|
||||
"target": "es2020"
|
||||
}
|
||||
}
|
7
tests/fixture/issue-2021/es2020/input/index.js
Normal file
7
tests/fixture/issue-2021/es2020/input/index.js
Normal file
@ -0,0 +1,7 @@
|
||||
class Item extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
input = this.props.item;
|
||||
}
|
6
tests/fixture/issue-2021/es2020/output/index.js
Normal file
6
tests/fixture/issue-2021/es2020/output/index.js
Normal file
@ -0,0 +1,6 @@
|
||||
class Item extends Component {
|
||||
constructor(props){
|
||||
super(props);
|
||||
}
|
||||
input = this.props.item;
|
||||
}
|
5
tests/fixture/issue-2021/es2021/input/.swcrc
Normal file
5
tests/fixture/issue-2021/es2021/input/.swcrc
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"jsc": {
|
||||
"target": "es2021"
|
||||
}
|
||||
}
|
7
tests/fixture/issue-2021/es2021/input/index.js
Normal file
7
tests/fixture/issue-2021/es2021/input/index.js
Normal file
@ -0,0 +1,7 @@
|
||||
class Item extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
input = this.props.item;
|
||||
}
|
6
tests/fixture/issue-2021/es2021/output/index.js
Normal file
6
tests/fixture/issue-2021/es2021/output/index.js
Normal file
@ -0,0 +1,6 @@
|
||||
class Item extends Component {
|
||||
constructor(props){
|
||||
super(props);
|
||||
}
|
||||
input = this.props.item;
|
||||
}
|
11
tests/fixture/issue-2021/full/input/.swcrc
Normal file
11
tests/fixture/issue-2021/full/input/.swcrc
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"module": {
|
||||
"type": "commonjs"
|
||||
},
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "ecmascript"
|
||||
},
|
||||
"target": "es2018"
|
||||
}
|
||||
}
|
7
tests/fixture/issue-2021/full/input/index.js
Normal file
7
tests/fixture/issue-2021/full/input/index.js
Normal file
@ -0,0 +1,7 @@
|
||||
class Item extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
input = this.props.item;
|
||||
}
|
20
tests/fixture/issue-2021/full/output/index.js
Normal file
20
tests/fixture/issue-2021/full/output/index.js
Normal file
@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
class Item extends Component {
|
||||
constructor(props){
|
||||
super(props);
|
||||
_defineProperty(this, "input", this.props.item);
|
||||
}
|
||||
}
|
5
tests/fixture/issue-2024/es2016/input/.swcrc
Normal file
5
tests/fixture/issue-2024/es2016/input/.swcrc
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"jsc": {
|
||||
"target": "es2016"
|
||||
}
|
||||
}
|
5
tests/fixture/issue-2024/es2016/input/index.js
Normal file
5
tests/fixture/issue-2024/es2016/input/index.js
Normal file
@ -0,0 +1,5 @@
|
||||
(async () => {
|
||||
const sleep = () => new Promise(resolve => setTimeout(() => resolve(undefined), 500));
|
||||
const result = (await sleep()) || 'fallback';
|
||||
console.log(result);
|
||||
})();
|
37
tests/fixture/issue-2024/es2016/output/index.js
Normal file
37
tests/fixture/issue-2024/es2016/output/index.js
Normal file
@ -0,0 +1,37 @@
|
||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
||||
try {
|
||||
var info = gen[key](arg);
|
||||
var value = info.value;
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
if (info.done) {
|
||||
resolve(value);
|
||||
} else {
|
||||
Promise.resolve(value).then(_next, _throw);
|
||||
}
|
||||
}
|
||||
function _asyncToGenerator(fn) {
|
||||
return function() {
|
||||
var self = this, args = arguments;
|
||||
return new Promise(function(resolve, reject) {
|
||||
var gen = fn.apply(self, args);
|
||||
function _next(value) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
||||
}
|
||||
function _throw(err) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
||||
}
|
||||
_next(undefined);
|
||||
});
|
||||
};
|
||||
}
|
||||
_asyncToGenerator(function*() {
|
||||
const sleep = ()=>new Promise((resolve)=>setTimeout(()=>resolve(undefined)
|
||||
, 500)
|
||||
)
|
||||
;
|
||||
const result = (yield sleep()) || 'fallback';
|
||||
console.log(result);
|
||||
})();
|
5
tests/fixture/issue-2024/full/input/.swcrc
Normal file
5
tests/fixture/issue-2024/full/input/.swcrc
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"module": {
|
||||
"type": "commonjs"
|
||||
}
|
||||
}
|
5
tests/fixture/issue-2024/full/input/index.js
Normal file
5
tests/fixture/issue-2024/full/input/index.js
Normal file
@ -0,0 +1,5 @@
|
||||
(async () => {
|
||||
const sleep = () => new Promise(resolve => setTimeout(() => resolve(undefined), 500));
|
||||
const result = (await sleep()) || 'fallback';
|
||||
console.log(result);
|
||||
})();
|
66
tests/fixture/issue-2024/full/output/index.js
Normal file
66
tests/fixture/issue-2024/full/output/index.js
Normal file
@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
var _regeneratorRuntime = _interopRequireDefault(require("regenerator-runtime"));
|
||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
||||
try {
|
||||
var info = gen[key](arg);
|
||||
var value = info.value;
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
if (info.done) {
|
||||
resolve(value);
|
||||
} else {
|
||||
Promise.resolve(value).then(_next, _throw);
|
||||
}
|
||||
}
|
||||
function _asyncToGenerator(fn) {
|
||||
return function() {
|
||||
var self = this, args = arguments;
|
||||
return new Promise(function(resolve, reject) {
|
||||
var gen = fn.apply(self, args);
|
||||
function _next(value) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
||||
}
|
||||
function _throw(err) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
||||
}
|
||||
_next(undefined);
|
||||
});
|
||||
};
|
||||
}
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
_asyncToGenerator(_regeneratorRuntime.default.mark(function _callee() {
|
||||
var sleep, result;
|
||||
return _regeneratorRuntime.default.wrap(function _callee$(_ctx) {
|
||||
while(1)switch(_ctx.prev = _ctx.next){
|
||||
case 0:
|
||||
sleep = function() {
|
||||
return new Promise(function(resolve) {
|
||||
return setTimeout(function() {
|
||||
return resolve(undefined);
|
||||
}, 500);
|
||||
});
|
||||
};
|
||||
_ctx.next = 3;
|
||||
return sleep();
|
||||
case 3:
|
||||
_ctx.t0 = _ctx.sent;
|
||||
if (_ctx.t0) {
|
||||
_ctx.next = 6;
|
||||
break;
|
||||
}
|
||||
_ctx.t0 = 'fallback';
|
||||
case 6:
|
||||
result = _ctx.t0;
|
||||
console.log(result);
|
||||
case 8:
|
||||
case "end":
|
||||
return _ctx.stop();
|
||||
}
|
||||
}, _callee);
|
||||
}))();
|
1
tests/fixture/issue-2024/no-module/input/.swcrc
Normal file
1
tests/fixture/issue-2024/no-module/input/.swcrc
Normal file
@ -0,0 +1 @@
|
||||
{}
|
5
tests/fixture/issue-2024/no-module/input/index.js
Normal file
5
tests/fixture/issue-2024/no-module/input/index.js
Normal file
@ -0,0 +1,5 @@
|
||||
(async () => {
|
||||
const sleep = () => new Promise(resolve => setTimeout(() => resolve(undefined), 500));
|
||||
const result = (await sleep()) || 'fallback';
|
||||
console.log(result);
|
||||
})();
|
60
tests/fixture/issue-2024/no-module/output/index.js
Normal file
60
tests/fixture/issue-2024/no-module/output/index.js
Normal file
@ -0,0 +1,60 @@
|
||||
import regeneratorRuntime from "regenerator-runtime";
|
||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
||||
try {
|
||||
var info = gen[key](arg);
|
||||
var value = info.value;
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
if (info.done) {
|
||||
resolve(value);
|
||||
} else {
|
||||
Promise.resolve(value).then(_next, _throw);
|
||||
}
|
||||
}
|
||||
function _asyncToGenerator(fn) {
|
||||
return function() {
|
||||
var self = this, args = arguments;
|
||||
return new Promise(function(resolve, reject) {
|
||||
var gen = fn.apply(self, args);
|
||||
function _next(value) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
||||
}
|
||||
function _throw(err) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
||||
}
|
||||
_next(undefined);
|
||||
});
|
||||
};
|
||||
}
|
||||
_asyncToGenerator(regeneratorRuntime.mark(function _callee() {
|
||||
var sleep, result;
|
||||
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
||||
while(1)switch(_ctx.prev = _ctx.next){
|
||||
case 0:
|
||||
sleep = function() {
|
||||
return new Promise(function(resolve) {
|
||||
return setTimeout(function() {
|
||||
return resolve(undefined);
|
||||
}, 500);
|
||||
});
|
||||
};
|
||||
_ctx.next = 3;
|
||||
return sleep();
|
||||
case 3:
|
||||
_ctx.t0 = _ctx.sent;
|
||||
if (_ctx.t0) {
|
||||
_ctx.next = 6;
|
||||
break;
|
||||
}
|
||||
_ctx.t0 = 'fallback';
|
||||
case 6:
|
||||
result = _ctx.t0;
|
||||
console.log(result);
|
||||
case 8:
|
||||
case "end":
|
||||
return _ctx.stop();
|
||||
}
|
||||
}, _callee);
|
||||
}))();
|
12
tests/fixture/issue-2027/case1/input/index.js
Normal file
12
tests/fixture/issue-2027/case1/input/index.js
Normal file
@ -0,0 +1,12 @@
|
||||
const keys = {
|
||||
a: 1,
|
||||
b: 2,
|
||||
}
|
||||
|
||||
const controller = {}
|
||||
|
||||
for (const key in keys) {
|
||||
controller[key] = (c, ...d) => {
|
||||
console.log(keys[key])
|
||||
}
|
||||
}
|
15
tests/fixture/issue-2027/case1/output/index.js
Normal file
15
tests/fixture/issue-2027/case1/output/index.js
Normal file
@ -0,0 +1,15 @@
|
||||
var _loop = function(key) {
|
||||
controller[key] = function(c) {
|
||||
for(var _len = arguments.length, d = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
||||
d[_key - 1] = arguments[_key];
|
||||
}
|
||||
console.log(keys[key]);
|
||||
};
|
||||
};
|
||||
var keys = {
|
||||
a: 1,
|
||||
b: 2
|
||||
};
|
||||
var controller = {
|
||||
};
|
||||
for(var key in keys)_loop(key);
|
@ -6,7 +6,7 @@ license = "Apache-2.0 AND MIT"
|
||||
name = "wasm"
|
||||
publish = false
|
||||
repository = "https://github.com/swc-project/swc.git"
|
||||
version = "1.2.75"
|
||||
version = "1.2.76"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
Loading…
Reference in New Issue
Block a user