diff --git a/package-lock.json b/package-lock.json index b004fb9..61d9cd8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rollup-plugin-swc3", - "version": "0.1.0", + "version": "0.1.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "rollup-plugin-swc3", - "version": "0.1.0", + "version": "0.1.1", "license": "MIT", "dependencies": { "@rollup/pluginutils": "^4.1.1", @@ -15,8 +15,9 @@ "jsonc-parser": "^3.0.0" }, "devDependencies": { + "@rollup/plugin-commonjs": "^21.0.1", "@rollup/plugin-json": "^4.1.0", - "@swc/core": "^1.2.108", + "@swc/core": "^1.2.111", "@types/chai": "^4.2.22", "@types/mocha": "^9.0.0", "@types/node": "^16.11.7", @@ -36,7 +37,7 @@ "node": ">=12" }, "peerDependencies": { - "@swc/core": ">=1.2.0", + "@swc/core": ">=1.2.111", "rollup": "^2.0.0" } }, @@ -202,6 +203,50 @@ "node": ">= 8" } }, + "node_modules/@rollup/plugin-commonjs": { + "version": "21.0.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-21.0.1.tgz", + "integrity": "sha512-EA+g22lbNJ8p5kuZJUYyhhDK7WgJckW5g4pNN7n4mAFUM96VuwUnNT3xr2Db2iCZPI1pJPbGyfT5mS9T1dHfMg==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^3.1.0", + "commondir": "^1.0.1", + "estree-walker": "^2.0.1", + "glob": "^7.1.6", + "is-reference": "^1.2.1", + "magic-string": "^0.25.7", + "resolve": "^1.17.0" + }, + "engines": { + "node": ">= 8.0.0" + }, + "peerDependencies": { + "rollup": "^2.38.3" + } + }, + "node_modules/@rollup/plugin-commonjs/node_modules/@rollup/pluginutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", + "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", + "dev": true, + "dependencies": { + "@types/estree": "0.0.39", + "estree-walker": "^1.0.1", + "picomatch": "^2.2.2" + }, + "engines": { + "node": ">= 8.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0" + } + }, + "node_modules/@rollup/plugin-commonjs/node_modules/@rollup/pluginutils/node_modules/estree-walker": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", + "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "dev": true + }, "node_modules/@rollup/plugin-json": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-4.1.0.tgz", @@ -250,9 +295,9 @@ } }, "node_modules/@swc/core": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.2.108.tgz", - "integrity": "sha512-OnENqiVLs1a9fy8lnEh3EtLgmFRgK0fZDCTV8CxVpMIzrYr7KnAZ/H4hc6MnxMkxqc+EJJWDIAd6LQ2ZHvLmNg==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.2.111.tgz", + "integrity": "sha512-efI4NV08apB6hpWuJr9SCR5Zr8hqbhqMtSMJc3YBqKutUJppOQfcN7AMm+lI4Me3kwgVpgKC+E5lviUX6N++qA==", "dev": true, "dependencies": { "@node-rs/helper": "^1.0.0" @@ -265,24 +310,24 @@ "url": "https://opencollective.com/swc" }, "optionalDependencies": { - "@swc/core-android-arm64": "^1.2.108", - "@swc/core-darwin-arm64": "^1.2.108", - "@swc/core-darwin-x64": "^1.2.108", - "@swc/core-freebsd-x64": "^1.2.108", - "@swc/core-linux-arm-gnueabihf": "^1.2.108", - "@swc/core-linux-arm64-gnu": "^1.2.108", - "@swc/core-linux-arm64-musl": "^1.2.108", - "@swc/core-linux-x64-gnu": "^1.2.108", - "@swc/core-linux-x64-musl": "^1.2.108", - "@swc/core-win32-arm64-msvc": "^1.2.108", - "@swc/core-win32-ia32-msvc": "^1.2.108", - "@swc/core-win32-x64-msvc": "^1.2.108" + "@swc/core-android-arm64": "^1.2.111", + "@swc/core-darwin-arm64": "^1.2.111", + "@swc/core-darwin-x64": "^1.2.111", + "@swc/core-freebsd-x64": "^1.2.111", + "@swc/core-linux-arm-gnueabihf": "^1.2.111", + "@swc/core-linux-arm64-gnu": "^1.2.111", + "@swc/core-linux-arm64-musl": "^1.2.111", + "@swc/core-linux-x64-gnu": "^1.2.111", + "@swc/core-linux-x64-musl": "^1.2.111", + "@swc/core-win32-arm64-msvc": "^1.2.111", + "@swc/core-win32-ia32-msvc": "^1.2.111", + "@swc/core-win32-x64-msvc": "^1.2.111" } }, "node_modules/@swc/core-android-arm64": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-android-arm64/-/core-android-arm64-1.2.108.tgz", - "integrity": "sha512-/+8hIUYptTpLi6gyIJuWyO8+nR661q3nlJdEBfmG9hzVEq7vK6wQQG9ctYfI8eRThnWXwg95O1hwQQRN7fgnRQ==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-android-arm64/-/core-android-arm64-1.2.111.tgz", + "integrity": "sha512-CtIw5i0kfEb2CHbbjwnH8RmeNn0CxFuzUKzzLx6Q3DuYEaV743ueM2iORSkLmwns0rcgFWBVSFIf6xJeWErlOA==", "cpu": [ "arm64" ], @@ -296,9 +341,9 @@ } }, "node_modules/@swc/core-darwin-arm64": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.2.108.tgz", - "integrity": "sha512-f39PTTnRHnX9I+XtvbwTbyMBF+JbzkJMrzNE4i2PS8dYSC5yVHI3S5CEqh0pG7Ihu+V1vmkPDs+qN7WgJPQ/2w==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.2.111.tgz", + "integrity": "sha512-/dMyb+7RRYJu5EgPZGyQRnCyDo4h7icBjOW7Q1MHboyQIloFBB7bfLIizRFuUzNi5T89nczfjXjzP84jPODq7Q==", "cpu": [ "arm64" ], @@ -312,9 +357,9 @@ } }, "node_modules/@swc/core-darwin-x64": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.2.108.tgz", - "integrity": "sha512-DGSgGj5hdZWQdTY9neUXcmH48bH4dF2AHPtDh7Ce49HnETn2oztf/4Fhfnpa3z97jrhvxZ9WvE0Mvrvu1wAmBw==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.2.111.tgz", + "integrity": "sha512-C0K7pLWG5VdGHBgdOFG4pU4d3kCLCyFcJ6DzRpkFzsWfdxekqPatNfrhkPoK6g1xmYRu6wDN91KTszBlvHXHYg==", "cpu": [ "x64" ], @@ -328,9 +373,9 @@ } }, "node_modules/@swc/core-freebsd-x64": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-freebsd-x64/-/core-freebsd-x64-1.2.108.tgz", - "integrity": "sha512-fuynErhCBhc6JABGExU0bp/BAsmIWueila8HeWFkNBFH0SoVfnKkRGLSfGRPn/nFvvjniBxYYEwUEqewKrpS3w==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-freebsd-x64/-/core-freebsd-x64-1.2.111.tgz", + "integrity": "sha512-vpzTanJ6pwlMmtwLtu7622+ewC4BrkLoZuI9kxki5EoAqDZDT5zS/VYEjRNntfcNrEgu6/HqtZ8wjCZWcRN23w==", "cpu": [ "x64" ], @@ -344,9 +389,9 @@ } }, "node_modules/@swc/core-linux-arm-gnueabihf": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.2.108.tgz", - "integrity": "sha512-90X5xQqpU6EBNSMdjjAV+VhJBw4HS4H01zpFvMSgcOYDUTa3lZf5L5m1KBDOUg3XczotUtP6JJPVIR07GpR82g==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.2.111.tgz", + "integrity": "sha512-E4220K7pDIJy3GcVzoaX5xTvPiEfDaA9/YqT9jEG+y5mShYhVHnariDWFfeQ7EMcziCbuk0+HJnYC155V/3F8w==", "cpu": [ "arm" ], @@ -360,9 +405,9 @@ } }, "node_modules/@swc/core-linux-arm64-gnu": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.2.108.tgz", - "integrity": "sha512-sEIckU72jDgoC3yzbqvW08Uwy8tenvJwygh+2CiEGHJ/YvaXA+wrrBSYp/HStvYMZXOJP6e1FVAELTkDNJbkjg==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.2.111.tgz", + "integrity": "sha512-b5Y3WogFfr1rK7rLPEKPInzZsO9uKlu2Or2feGo1jf4ISpJTEo4FHTXOANeUbSxXqKtnSKS4yXglz8z0oO3WKA==", "cpu": [ "arm64" ], @@ -376,9 +421,9 @@ } }, "node_modules/@swc/core-linux-arm64-musl": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.2.108.tgz", - "integrity": "sha512-jjdojRe2MdkiI4/cwjn6nzOoUhamRYJYFT4RH9CeVWou43iAQvxAX+f0nLo1GKrpmzQ9knp969iO0bgCB0Ax6A==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.2.111.tgz", + "integrity": "sha512-iWzAEpc4wScjxge4ctWB0lL2/8M1Z0v8dHtE8mM/4ye6yUAo9QRDipRKVeRQ7sxjcvZoyNxJ3e1oo3uTPUdUeA==", "cpu": [ "arm64" ], @@ -392,9 +437,9 @@ } }, "node_modules/@swc/core-linux-x64-gnu": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.2.108.tgz", - "integrity": "sha512-SteNOLrIp6YtaQkHzzmvVj4Xu3usvDM7R97Qf8bvnsZ7GyIotfVkIGbf6PttGtMKDNMxNnrsY1/6Z/zDcOtiKw==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.2.111.tgz", + "integrity": "sha512-jJaKxsy7ePZ1dB+LQKAFNsprYMeeMeOaoE7o3fyOZba+FBJ1iR8EgZg68OJLmqawHpBk/pn2PefaJXejUQyxjA==", "cpu": [ "x64" ], @@ -408,9 +453,9 @@ } }, "node_modules/@swc/core-linux-x64-musl": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.2.108.tgz", - "integrity": "sha512-vOlBtLsi+mchJfTIMZmf3Lif6PAXFPfEFXcZRBFC6M9GxFgF1hgscVvSmdcyLpKqMN8a25fOKbdA6qcqQ3qrwg==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.2.111.tgz", + "integrity": "sha512-JNSOePB9GqLOMpVSm2hii2ApzKaMYdbifCBoefl20mWNtZ/K3TLSOIlRdpEZkS4Str9p3WzksTj/gqYiTu3Ygg==", "cpu": [ "x64" ], @@ -424,9 +469,9 @@ } }, "node_modules/@swc/core-win32-arm64-msvc": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.2.108.tgz", - "integrity": "sha512-Rz1/jqJgTysMt2l3gT6/pIeVdQgsIQcK4sKYTD3VttvZ4L+eNv3LGubkrDWPGz4RWq/fZn2aRoQTp09POrV2RA==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.2.111.tgz", + "integrity": "sha512-73wLT42Tet2qPQxzr5CpZQwxuX0u+r1xTGpNOFYo8vdtjmPdWwbZZaMafIehol/G6NBiDZMuqonwMik6u1e2+A==", "cpu": [ "arm64" ], @@ -440,9 +485,9 @@ } }, "node_modules/@swc/core-win32-ia32-msvc": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.2.108.tgz", - "integrity": "sha512-Mr/WPgBt8IjhJkukT3Img+pzC6SAlp5c0iBjO/Vy+uBHLz3b1/gutbc1FtqyFfbjqtmygIq0wir1m7gXHtfMhA==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.2.111.tgz", + "integrity": "sha512-8XmYrlv1/Gl2fLbC46dJweXKfDBXrEzhdl+bYG+M3Xw3JE/gJIP/weQj+pweF12wNEQd7Z+fEw40jcG3z/dE1A==", "cpu": [ "ia32" ], @@ -456,9 +501,9 @@ } }, "node_modules/@swc/core-win32-x64-msvc": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.2.108.tgz", - "integrity": "sha512-wH7+u1DUwHZOwR7bbX1hmXmHpvylxxnwo/Nh4X0kx9aRCBMvDnNHqnQb5jl1FysEpVYzntLvjX2GSYLHQdJ/Ag==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.2.111.tgz", + "integrity": "sha512-dpvQuuq9IDZAtB3p3bibz2K+hoxUDL+SjxDjZWvSA8ZjRRB9AXtvBHknQyXA2LHGKO+0unlK+goO0Q2VDzzQ7w==", "cpu": [ "x64" ], @@ -1010,6 +1055,12 @@ "dev": true, "optional": true }, + "node_modules/commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", + "dev": true + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -1641,6 +1692,12 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "node_modules/function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, "node_modules/functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", @@ -1742,6 +1799,18 @@ "node": ">=4.x" } }, + "node_modules/has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, "node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -1825,6 +1894,18 @@ "node": ">=8" } }, + "node_modules/is-core-module": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.0.tgz", + "integrity": "sha512-vd15qHsaqrRL7dtH6QNuy0ndJmRDrS9HAM1CAiSifNUFv4x1a0CCVsj18hJ1mShxIG6T2i1sO78MkP56r0nYRw==", + "dev": true, + "dependencies": { + "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -1864,6 +1945,15 @@ "node": ">=8" } }, + "node_modules/is-reference": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "dev": true, + "dependencies": { + "@types/estree": "*" + } + }, "node_modules/is-unicode-supported": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", @@ -2362,6 +2452,12 @@ "node": ">=8" } }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, "node_modules/path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", @@ -2483,6 +2579,19 @@ "node": ">=0.10.0" } }, + "node_modules/resolve": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", + "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "dev": true, + "dependencies": { + "is-core-module": "^2.2.0", + "path-parse": "^1.0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", @@ -3290,6 +3399,42 @@ "fastq": "^1.6.0" } }, + "@rollup/plugin-commonjs": { + "version": "21.0.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-21.0.1.tgz", + "integrity": "sha512-EA+g22lbNJ8p5kuZJUYyhhDK7WgJckW5g4pNN7n4mAFUM96VuwUnNT3xr2Db2iCZPI1pJPbGyfT5mS9T1dHfMg==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^3.1.0", + "commondir": "^1.0.1", + "estree-walker": "^2.0.1", + "glob": "^7.1.6", + "is-reference": "^1.2.1", + "magic-string": "^0.25.7", + "resolve": "^1.17.0" + }, + "dependencies": { + "@rollup/pluginutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", + "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", + "dev": true, + "requires": { + "@types/estree": "0.0.39", + "estree-walker": "^1.0.1", + "picomatch": "^2.2.2" + }, + "dependencies": { + "estree-walker": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", + "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "dev": true + } + } + } + } + }, "@rollup/plugin-json": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-4.1.0.tgz", @@ -3328,107 +3473,107 @@ } }, "@swc/core": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.2.108.tgz", - "integrity": "sha512-OnENqiVLs1a9fy8lnEh3EtLgmFRgK0fZDCTV8CxVpMIzrYr7KnAZ/H4hc6MnxMkxqc+EJJWDIAd6LQ2ZHvLmNg==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.2.111.tgz", + "integrity": "sha512-efI4NV08apB6hpWuJr9SCR5Zr8hqbhqMtSMJc3YBqKutUJppOQfcN7AMm+lI4Me3kwgVpgKC+E5lviUX6N++qA==", "dev": true, "requires": { "@node-rs/helper": "^1.0.0", - "@swc/core-android-arm64": "^1.2.108", - "@swc/core-darwin-arm64": "^1.2.108", - "@swc/core-darwin-x64": "^1.2.108", - "@swc/core-freebsd-x64": "^1.2.108", - "@swc/core-linux-arm-gnueabihf": "^1.2.108", - "@swc/core-linux-arm64-gnu": "^1.2.108", - "@swc/core-linux-arm64-musl": "^1.2.108", - "@swc/core-linux-x64-gnu": "^1.2.108", - "@swc/core-linux-x64-musl": "^1.2.108", - "@swc/core-win32-arm64-msvc": "^1.2.108", - "@swc/core-win32-ia32-msvc": "^1.2.108", - "@swc/core-win32-x64-msvc": "^1.2.108" + "@swc/core-android-arm64": "^1.2.111", + "@swc/core-darwin-arm64": "^1.2.111", + "@swc/core-darwin-x64": "^1.2.111", + "@swc/core-freebsd-x64": "^1.2.111", + "@swc/core-linux-arm-gnueabihf": "^1.2.111", + "@swc/core-linux-arm64-gnu": "^1.2.111", + "@swc/core-linux-arm64-musl": "^1.2.111", + "@swc/core-linux-x64-gnu": "^1.2.111", + "@swc/core-linux-x64-musl": "^1.2.111", + "@swc/core-win32-arm64-msvc": "^1.2.111", + "@swc/core-win32-ia32-msvc": "^1.2.111", + "@swc/core-win32-x64-msvc": "^1.2.111" } }, "@swc/core-android-arm64": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-android-arm64/-/core-android-arm64-1.2.108.tgz", - "integrity": "sha512-/+8hIUYptTpLi6gyIJuWyO8+nR661q3nlJdEBfmG9hzVEq7vK6wQQG9ctYfI8eRThnWXwg95O1hwQQRN7fgnRQ==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-android-arm64/-/core-android-arm64-1.2.111.tgz", + "integrity": "sha512-CtIw5i0kfEb2CHbbjwnH8RmeNn0CxFuzUKzzLx6Q3DuYEaV743ueM2iORSkLmwns0rcgFWBVSFIf6xJeWErlOA==", "dev": true, "optional": true }, "@swc/core-darwin-arm64": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.2.108.tgz", - "integrity": "sha512-f39PTTnRHnX9I+XtvbwTbyMBF+JbzkJMrzNE4i2PS8dYSC5yVHI3S5CEqh0pG7Ihu+V1vmkPDs+qN7WgJPQ/2w==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.2.111.tgz", + "integrity": "sha512-/dMyb+7RRYJu5EgPZGyQRnCyDo4h7icBjOW7Q1MHboyQIloFBB7bfLIizRFuUzNi5T89nczfjXjzP84jPODq7Q==", "dev": true, "optional": true }, "@swc/core-darwin-x64": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.2.108.tgz", - "integrity": "sha512-DGSgGj5hdZWQdTY9neUXcmH48bH4dF2AHPtDh7Ce49HnETn2oztf/4Fhfnpa3z97jrhvxZ9WvE0Mvrvu1wAmBw==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.2.111.tgz", + "integrity": "sha512-C0K7pLWG5VdGHBgdOFG4pU4d3kCLCyFcJ6DzRpkFzsWfdxekqPatNfrhkPoK6g1xmYRu6wDN91KTszBlvHXHYg==", "dev": true, "optional": true }, "@swc/core-freebsd-x64": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-freebsd-x64/-/core-freebsd-x64-1.2.108.tgz", - "integrity": "sha512-fuynErhCBhc6JABGExU0bp/BAsmIWueila8HeWFkNBFH0SoVfnKkRGLSfGRPn/nFvvjniBxYYEwUEqewKrpS3w==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-freebsd-x64/-/core-freebsd-x64-1.2.111.tgz", + "integrity": "sha512-vpzTanJ6pwlMmtwLtu7622+ewC4BrkLoZuI9kxki5EoAqDZDT5zS/VYEjRNntfcNrEgu6/HqtZ8wjCZWcRN23w==", "dev": true, "optional": true }, "@swc/core-linux-arm-gnueabihf": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.2.108.tgz", - "integrity": "sha512-90X5xQqpU6EBNSMdjjAV+VhJBw4HS4H01zpFvMSgcOYDUTa3lZf5L5m1KBDOUg3XczotUtP6JJPVIR07GpR82g==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.2.111.tgz", + "integrity": "sha512-E4220K7pDIJy3GcVzoaX5xTvPiEfDaA9/YqT9jEG+y5mShYhVHnariDWFfeQ7EMcziCbuk0+HJnYC155V/3F8w==", "dev": true, "optional": true }, "@swc/core-linux-arm64-gnu": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.2.108.tgz", - "integrity": "sha512-sEIckU72jDgoC3yzbqvW08Uwy8tenvJwygh+2CiEGHJ/YvaXA+wrrBSYp/HStvYMZXOJP6e1FVAELTkDNJbkjg==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.2.111.tgz", + "integrity": "sha512-b5Y3WogFfr1rK7rLPEKPInzZsO9uKlu2Or2feGo1jf4ISpJTEo4FHTXOANeUbSxXqKtnSKS4yXglz8z0oO3WKA==", "dev": true, "optional": true }, "@swc/core-linux-arm64-musl": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.2.108.tgz", - "integrity": "sha512-jjdojRe2MdkiI4/cwjn6nzOoUhamRYJYFT4RH9CeVWou43iAQvxAX+f0nLo1GKrpmzQ9knp969iO0bgCB0Ax6A==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.2.111.tgz", + "integrity": "sha512-iWzAEpc4wScjxge4ctWB0lL2/8M1Z0v8dHtE8mM/4ye6yUAo9QRDipRKVeRQ7sxjcvZoyNxJ3e1oo3uTPUdUeA==", "dev": true, "optional": true }, "@swc/core-linux-x64-gnu": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.2.108.tgz", - "integrity": "sha512-SteNOLrIp6YtaQkHzzmvVj4Xu3usvDM7R97Qf8bvnsZ7GyIotfVkIGbf6PttGtMKDNMxNnrsY1/6Z/zDcOtiKw==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.2.111.tgz", + "integrity": "sha512-jJaKxsy7ePZ1dB+LQKAFNsprYMeeMeOaoE7o3fyOZba+FBJ1iR8EgZg68OJLmqawHpBk/pn2PefaJXejUQyxjA==", "dev": true, "optional": true }, "@swc/core-linux-x64-musl": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.2.108.tgz", - "integrity": "sha512-vOlBtLsi+mchJfTIMZmf3Lif6PAXFPfEFXcZRBFC6M9GxFgF1hgscVvSmdcyLpKqMN8a25fOKbdA6qcqQ3qrwg==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.2.111.tgz", + "integrity": "sha512-JNSOePB9GqLOMpVSm2hii2ApzKaMYdbifCBoefl20mWNtZ/K3TLSOIlRdpEZkS4Str9p3WzksTj/gqYiTu3Ygg==", "dev": true, "optional": true }, "@swc/core-win32-arm64-msvc": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.2.108.tgz", - "integrity": "sha512-Rz1/jqJgTysMt2l3gT6/pIeVdQgsIQcK4sKYTD3VttvZ4L+eNv3LGubkrDWPGz4RWq/fZn2aRoQTp09POrV2RA==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.2.111.tgz", + "integrity": "sha512-73wLT42Tet2qPQxzr5CpZQwxuX0u+r1xTGpNOFYo8vdtjmPdWwbZZaMafIehol/G6NBiDZMuqonwMik6u1e2+A==", "dev": true, "optional": true }, "@swc/core-win32-ia32-msvc": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.2.108.tgz", - "integrity": "sha512-Mr/WPgBt8IjhJkukT3Img+pzC6SAlp5c0iBjO/Vy+uBHLz3b1/gutbc1FtqyFfbjqtmygIq0wir1m7gXHtfMhA==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.2.111.tgz", + "integrity": "sha512-8XmYrlv1/Gl2fLbC46dJweXKfDBXrEzhdl+bYG+M3Xw3JE/gJIP/weQj+pweF12wNEQd7Z+fEw40jcG3z/dE1A==", "dev": true, "optional": true }, "@swc/core-win32-x64-msvc": { - "version": "1.2.108", - "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.2.108.tgz", - "integrity": "sha512-wH7+u1DUwHZOwR7bbX1hmXmHpvylxxnwo/Nh4X0kx9aRCBMvDnNHqnQb5jl1FysEpVYzntLvjX2GSYLHQdJ/Ag==", + "version": "1.2.111", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.2.111.tgz", + "integrity": "sha512-dpvQuuq9IDZAtB3p3bibz2K+hoxUDL+SjxDjZWvSA8ZjRRB9AXtvBHknQyXA2LHGKO+0unlK+goO0Q2VDzzQ7w==", "dev": true, "optional": true }, @@ -3828,6 +3973,12 @@ "dev": true, "optional": true }, + "commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", + "dev": true + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -4310,6 +4461,12 @@ "dev": true, "optional": true }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, "functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", @@ -4381,6 +4538,15 @@ "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", "dev": true }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -4443,6 +4609,15 @@ "binary-extensions": "^2.0.0" } }, + "is-core-module": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.0.tgz", + "integrity": "sha512-vd15qHsaqrRL7dtH6QNuy0ndJmRDrS9HAM1CAiSifNUFv4x1a0CCVsj18hJ1mShxIG6T2i1sO78MkP56r0nYRw==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -4470,6 +4645,15 @@ "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", "dev": true }, + "is-reference": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "dev": true, + "requires": { + "@types/estree": "*" + } + }, "is-unicode-supported": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", @@ -4841,6 +5025,12 @@ "dev": true, "peer": true }, + "path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, "path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", @@ -4915,6 +5105,16 @@ "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", "dev": true }, + "resolve": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", + "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "dev": true, + "requires": { + "is-core-module": "^2.2.0", + "path-parse": "^1.0.6" + } + }, "resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", diff --git a/package.json b/package.json index 8a60838..235c089 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,9 @@ "jsonc-parser": "^3.0.0" }, "devDependencies": { + "@rollup/plugin-commonjs": "^21.0.1", "@rollup/plugin-json": "^4.1.0", - "@swc/core": "^1.2.108", + "@swc/core": "^1.2.111", "@types/chai": "^4.2.22", "@types/mocha": "^9.0.0", "@types/node": "^16.11.7", @@ -45,7 +46,7 @@ "typescript": "^4.4.4" }, "peerDependencies": { - "@swc/core": ">=1.2.0", + "@swc/core": ">=1.2.111", "rollup": "^2.0.0" }, "engines": { diff --git a/src/index.ts b/src/index.ts index 69eafe0..0b84770 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,6 +21,11 @@ export type PluginOptions = { const INCLUDE_REGEXP = /\.[jt]sx?$/; const EXCLUDE_REGEXP = /node_modules/; +const ROLLUP_VIRTUAL_MODULE_IDENTIFIER = '\0'; +const REGEXP_ROLLUP_VIRTUAL_MODULE_IDENTIFIER = /\0/gm; +const ROLLUP_VIRTUAL_MODULE_ESCAPE_IDENTIFIER = '$__SECRET_ROLLUP_VIRTUAL_MODULE_ESCAPE_IDENTIFIER_DO_NOT_USE_OR_YOU_WILL_BE_FIRED__$'; +const REGEXP_ROLLUP_VIRTUAL_MODULE_ESCAPE_IDENTIFIER = /\$__SECRET_ROLLUP_VIRTUAL_MODULE_ESCAPE_IDENTIFIER_DO_NOT_USE_OR_YOU_WILL_BE_FIRED__\$/gm; + const resolveFile = (resolved: string, index = false) => { for (const ext of ['.ts', '.js', '.tsx', '.jsx']) { const file = index ? join(resolved, `index${ext}`) : `${resolved}${ext}`; @@ -39,6 +44,11 @@ function swc(options: PluginOptions = {}): Plugin { name: 'swc', resolveId(importee, importer) { + // ignore IDs with null character, these belong to other plugins + if (importee.startsWith('\0')) { + return null; + } + if (importer && importee[0] === '.') { const resolved = resolve( importer ? dirname(importer) : process.cwd(), @@ -104,7 +114,31 @@ function swc(options: PluginOptions = {}): Plugin { } ]); - return swcTransform(code, swcOption); + /** + * swc cannot transform module ids with "\0", which is the identifier of rollup virtual module + * + * FIXME: This is a temporary workaround, remove when swc fixes it (DO NOT FORGET TO BUMP PEER DEPS VERSION AS WELL!) + * + * @see https://rollupjs.org/guide/en/#conventions + * @see https://github.com/rollup/plugins/blob/02fb349d315f0ffc55970fba5de20e23f8ead881/packages/commonjs/src/helpers.js#L15 + * @see https://github.com/SukkaW/rollup-plugin-swc/pull/1 + * @see https://github.com/swc-project/swc/issues/2853 + */ + const { code: transformedCode, ...rest } = await swcTransform( + code.replace( + REGEXP_ROLLUP_VIRTUAL_MODULE_IDENTIFIER, + ROLLUP_VIRTUAL_MODULE_ESCAPE_IDENTIFIER + ), + swcOption + ); + + return { + ...rest, + code: transformedCode.replace( + REGEXP_ROLLUP_VIRTUAL_MODULE_ESCAPE_IDENTIFIER, + ROLLUP_VIRTUAL_MODULE_IDENTIFIER + ) + }; }, renderChunk(code: string) { diff --git a/test/index.ts b/test/index.ts index aeb75a5..1b7b14d 100644 --- a/test/index.ts +++ b/test/index.ts @@ -3,6 +3,8 @@ import fs from 'fs'; import { rollup, Plugin as RollupPlugin } from 'rollup'; import { swc, PluginOptions } from '../src'; import json from '@rollup/plugin-json'; +import commonjs from '@rollup/plugin-commonjs'; + import 'chai/register-should'; const tmpDir = path.join(__dirname, '.temp'); @@ -150,6 +152,40 @@ console.log(foo$1); `); }); + it('support rollup virtual module (e.g. commonjs plugin)', async () => { + const dir = realFs(getTestName(), { + './fixture/index.js': ` + const Foo = require('./foo') + const { Bar } = require('./bar') + console.log(Foo, Bar) + `, + './fixture/foo.js': ` + module.exports = 'foo' + `, + './fixture/bar.js': ` + exports.Bar = 'bar' + ` + }); + const output = await build( + {}, + { otherRollupPlugins: [commonjs()], dir } + ); + output[0].code.should.equal(`var fixture = {}; + +var foo = 'foo'; + +var bar = {}; + +bar.Bar = 'bar'; + +const Foo = foo; +const { Bar } = bar; +console.log(Foo, Bar); + +export { fixture as default }; +`); + }); + it('use custom jsxFactory (h) from tsconfig', async () => { const dir = realFs(getTestName(), { './fixture/index.tsx': `