From 72a9751dc38bad8bcf23d28d61ed0153667dabd5 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 16:41:39 +0200 Subject: [PATCH 01/24] chore: add test env --- package-lock.json | 831 ++++++++++++++++++++++++++++------ package.json | 6 +- tests/fixture/alias-target.ts | 1 + tests/fixture/alias.ts | 3 + tests/fixture/deno.json | 9 + tests/fixture/deno.lock | 32 ++ tests/fixture/http.ts | 5 + tests/fixture/inlineHttp.ts | 5 + tests/fixture/inlineJsr.ts | 5 + tests/fixture/inlineNpm.ts | 5 + tests/fixture/jsr.ts | 5 + tests/fixture/npm.ts | 5 + tests/fixture/vite.config.ts | 20 + 13 files changed, 796 insertions(+), 136 deletions(-) create mode 100644 tests/fixture/alias-target.ts create mode 100644 tests/fixture/alias.ts create mode 100644 tests/fixture/deno.json create mode 100644 tests/fixture/deno.lock create mode 100644 tests/fixture/http.ts create mode 100644 tests/fixture/inlineHttp.ts create mode 100644 tests/fixture/inlineJsr.ts create mode 100644 tests/fixture/inlineNpm.ts create mode 100644 tests/fixture/jsr.ts create mode 100644 tests/fixture/npm.ts create mode 100644 tests/fixture/vite.config.ts diff --git a/package-lock.json b/package-lock.json index d6623c2..0a44c38 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,12 +12,27 @@ "@types/node": "^22.5.5", "esbuild": "^0.23.1", "rimraf": "^6.0.1", - "typescript": "^5.6.2" + "ts-node": "^10.9.2", + "typescript": "^5.6.2", + "vitest": "^2.1.1" }, "peerDependencies": { "vite": "^5.4.6" } }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.23.1.tgz", @@ -444,6 +459,34 @@ "node": ">=12" } }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", @@ -456,9 +499,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.22.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.22.0.tgz", - "integrity": "sha512-/IZQvg6ZR0tAkEi4tdXOraQoWeJy9gbQ/cx4I7k9dJaCk9qrXEcdouxRVz5kZXt5C2bQ9pILoAA+KB4C/d3pfw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.22.4.tgz", + "integrity": "sha512-Fxamp4aEZnfPOcGA8KSNEohV8hX7zVHOemC8jVBoBUHu5zpJK/Eu3uJwt6BMgy9fkvzxDaurgj96F/NiLukF2w==", "cpu": [ "arm" ], @@ -466,13 +509,12 @@ "optional": true, "os": [ "android" - ], - "peer": true + ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.22.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.22.0.tgz", - "integrity": "sha512-ETHi4bxrYnvOtXeM7d4V4kZWixib2jddFacJjsOjwbgYSRsyXYtZHC4ht134OsslPIcnkqT+TKV4eU8rNBKyyQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.22.4.tgz", + "integrity": "sha512-VXoK5UMrgECLYaMuGuVTOx5kcuap1Jm8g/M83RnCHBKOqvPPmROFJGQaZhGccnsFtfXQ3XYa4/jMCJvZnbJBdA==", "cpu": [ "arm64" ], @@ -480,13 +522,12 @@ "optional": true, "os": [ "android" - ], - "peer": true + ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.22.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.22.0.tgz", - "integrity": "sha512-ZWgARzhSKE+gVUX7QWaECoRQsPwaD8ZR0Oxb3aUpzdErTvlEadfQpORPXkKSdKbFci9v8MJfkTtoEHnnW9Ulng==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.22.4.tgz", + "integrity": "sha512-xMM9ORBqu81jyMKCDP+SZDhnX2QEVQzTcC6G18KlTQEzWK8r/oNZtKuZaCcHhnsa6fEeOBionoyl5JsAbE/36Q==", "cpu": [ "arm64" ], @@ -494,13 +535,12 @@ "optional": true, "os": [ "darwin" - ], - "peer": true + ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.22.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.22.0.tgz", - "integrity": "sha512-h0ZAtOfHyio8Az6cwIGS+nHUfRMWBDO5jXB8PQCARVF6Na/G6XS2SFxDl8Oem+S5ZsHQgtsI7RT4JQnI1qrlaw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.22.4.tgz", + "integrity": "sha512-aJJyYKQwbHuhTUrjWjxEvGnNNBCnmpHDvrb8JFDbeSH3m2XdHcxDd3jthAzvmoI8w/kSjd2y0udT+4okADsZIw==", "cpu": [ "x64" ], @@ -508,13 +548,12 @@ "optional": true, "os": [ "darwin" - ], - "peer": true + ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.22.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.22.0.tgz", - "integrity": "sha512-9pxQJSPwFsVi0ttOmqLY4JJ9pg9t1gKhK0JDbV1yUEETSx55fdyCjt39eBQ54OQCzAF0nVGO6LfEH1KnCPvelA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.22.4.tgz", + "integrity": "sha512-j63YtCIRAzbO+gC2L9dWXRh5BFetsv0j0va0Wi9epXDgU/XUi5dJKo4USTttVyK7fGw2nPWK0PbAvyliz50SCQ==", "cpu": [ "arm" ], @@ -522,13 +561,12 @@ "optional": true, "os": [ "linux" - ], - "peer": true + ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.22.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.22.0.tgz", - "integrity": "sha512-YJ5Ku5BmNJZb58A4qSEo3JlIG4d3G2lWyBi13ABlXzO41SsdnUKi3HQHe83VpwBVG4jHFTW65jOQb8qyoR+qzg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.22.4.tgz", + "integrity": "sha512-dJnWUgwWBX1YBRsuKKMOlXCzh2Wu1mlHzv20TpqEsfdZLb3WoJW2kIEsGwLkroYf24IrPAvOT/ZQ2OYMV6vlrg==", "cpu": [ "arm" ], @@ -536,13 +574,12 @@ "optional": true, "os": [ "linux" - ], - "peer": true + ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.22.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.22.0.tgz", - "integrity": "sha512-U4G4u7f+QCqHlVg1Nlx+qapZy+QoG+NV6ux+upo/T7arNGwKvKP2kmGM4W5QTbdewWFgudQxi3kDNST9GT1/mg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.22.4.tgz", + "integrity": "sha512-AdPRoNi3NKVLolCN/Sp4F4N1d98c4SBnHMKoLuiG6RXgoZ4sllseuGioszumnPGmPM2O7qaAX/IJdeDU8f26Aw==", "cpu": [ "arm64" ], @@ -550,13 +587,12 @@ "optional": true, "os": [ "linux" - ], - "peer": true + ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.22.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.22.0.tgz", - "integrity": "sha512-aQpNlKmx3amwkA3a5J6nlXSahE1ijl0L9KuIjVOUhfOh7uw2S4piR3mtpxpRtbnK809SBtyPsM9q15CPTsY7HQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.22.4.tgz", + "integrity": "sha512-Gl0AxBtDg8uoAn5CCqQDMqAx22Wx22pjDOjBdmG0VIWX3qUBHzYmOKh8KXHL4UpogfJ14G4wk16EQogF+v8hmA==", "cpu": [ "arm64" ], @@ -564,13 +600,12 @@ "optional": true, "os": [ "linux" - ], - "peer": true + ] }, "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.22.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.22.0.tgz", - "integrity": "sha512-9fx6Zj/7vve/Fp4iexUFRKb5+RjLCff6YTRQl4CoDhdMfDoobWmhAxQWV3NfShMzQk1Q/iCnageFyGfqnsmeqQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.22.4.tgz", + "integrity": "sha512-3aVCK9xfWW1oGQpTsYJJPF6bfpWfhbRnhdlyhak2ZiyFLDaayz0EP5j9V1RVLAAxlmWKTDfS9wyRyY3hvhPoOg==", "cpu": [ "ppc64" ], @@ -578,13 +613,12 @@ "optional": true, "os": [ "linux" - ], - "peer": true + ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.22.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.22.0.tgz", - "integrity": "sha512-VWQiCcN7zBgZYLjndIEh5tamtnKg5TGxyZPWcN9zBtXBwfcGSZ5cHSdQZfQH/GB4uRxk0D3VYbOEe/chJhPGLQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.22.4.tgz", + "integrity": "sha512-ePYIir6VYnhgv2C5Xe9u+ico4t8sZWXschR6fMgoPUK31yQu7hTEJb7bCqivHECwIClJfKgE7zYsh1qTP3WHUA==", "cpu": [ "riscv64" ], @@ -592,13 +626,12 @@ "optional": true, "os": [ "linux" - ], - "peer": true + ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.22.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.22.0.tgz", - "integrity": "sha512-EHmPnPWvyYqncObwqrosb/CpH3GOjE76vWVs0g4hWsDRUVhg61hBmlVg5TPXqF+g+PvIbqkC7i3h8wbn4Gp2Fg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.22.4.tgz", + "integrity": "sha512-GqFJ9wLlbB9daxhVlrTe61vJtEY99/xB3C8e4ULVsVfflcpmR6c8UZXjtkMA6FhNONhj2eA5Tk9uAVw5orEs4Q==", "cpu": [ "s390x" ], @@ -606,13 +639,12 @@ "optional": true, "os": [ "linux" - ], - "peer": true + ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.22.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.22.0.tgz", - "integrity": "sha512-tsSWy3YQzmpjDKnQ1Vcpy3p9Z+kMFbSIesCdMNgLizDWFhrLZIoN21JSq01g+MZMDFF+Y1+4zxgrlqPjid5ohg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.22.4.tgz", + "integrity": "sha512-87v0ol2sH9GE3cLQLNEy0K/R0pz1nvg76o8M5nhMR0+Q+BBGLnb35P0fVz4CQxHYXaAOhE8HhlkaZfsdUOlHwg==", "cpu": [ "x64" ], @@ -620,13 +652,12 @@ "optional": true, "os": [ "linux" - ], - "peer": true + ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.22.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.22.0.tgz", - "integrity": "sha512-anr1Y11uPOQrpuU8XOikY5lH4Qu94oS6j0xrulHk3NkLDq19MlX8Ng/pVipjxBJ9a2l3+F39REZYyWQFkZ4/fw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.22.4.tgz", + "integrity": "sha512-UV6FZMUgePDZrFjrNGIWzDo/vABebuXBhJEqrHxrGiU6HikPy0Z3LfdtciIttEUQfuDdCn8fqh7wiFJjCNwO+g==", "cpu": [ "x64" ], @@ -634,13 +665,12 @@ "optional": true, "os": [ "linux" - ], - "peer": true + ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.22.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.22.0.tgz", - "integrity": "sha512-7LB+Bh+Ut7cfmO0m244/asvtIGQr5pG5Rvjz/l1Rnz1kDzM02pSX9jPaS0p+90H5I1x4d1FkCew+B7MOnoatNw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.22.4.tgz", + "integrity": "sha512-BjI+NVVEGAXjGWYHz/vv0pBqfGoUH0IGZ0cICTn7kB9PyjrATSkX+8WkguNjWoj2qSr1im/+tTGRaY+4/PdcQw==", "cpu": [ "arm64" ], @@ -648,13 +678,12 @@ "optional": true, "os": [ "win32" - ], - "peer": true + ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.22.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.22.0.tgz", - "integrity": "sha512-+3qZ4rer7t/QsC5JwMpcvCVPRcJt1cJrYS/TMJZzXIJbxWFQEVhrIc26IhB+5Z9fT9umfVc+Es2mOZgl+7jdJQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.22.4.tgz", + "integrity": "sha512-SiWG/1TuUdPvYmzmYnmd3IEifzR61Tragkbx9D3+R8mzQqDBz8v+BvZNDlkiTtI9T15KYZhP0ehn3Dld4n9J5g==", "cpu": [ "ia32" ], @@ -662,13 +691,12 @@ "optional": true, "os": [ "win32" - ], - "peer": true + ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.22.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.22.0.tgz", - "integrity": "sha512-YdicNOSJONVx/vuPkgPTyRoAPx3GbknBZRCOUkK84FJ/YTfs/F0vl/YsMscrB6Y177d+yDRcj+JWMPMCgshwrA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.22.4.tgz", + "integrity": "sha512-j8pPKp53/lq9lMXN57S8cFz0MynJk8OWNuUnXct/9KCpKU7DgU3bYMJhwWmcqC0UU29p8Lr0/7KEVcaM6bf47Q==", "cpu": [ "x64" ], @@ -676,15 +704,41 @@ "optional": true, "os": [ "win32" - ], - "peer": true + ] + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", + "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true, + "license": "MIT" }, "node_modules/@types/estree": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/@types/node": { "version": "22.5.5", @@ -696,6 +750,146 @@ "undici-types": "~6.19.2" } }, + "node_modules/@vitest/expect": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-2.1.1.tgz", + "integrity": "sha512-YeueunS0HiHiQxk+KEOnq/QMzlUuOzbU1Go+PgAsHvvv3tUkJPm9xWt+6ITNTlzsMXUjmgm5T+U7KBPK2qQV6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "2.1.1", + "@vitest/utils": "2.1.1", + "chai": "^5.1.1", + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/mocker": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-2.1.1.tgz", + "integrity": "sha512-LNN5VwOEdJqCmJ/2XJBywB11DLlkbY0ooDJW3uRX5cZyYCrc4PI/ePX0iQhE3BiEGiQmK4GE7Q/PqCkkaiPnrA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "^2.1.0-beta.1", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.11" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@vitest/spy": "2.1.1", + "msw": "^2.3.5", + "vite": "^5.0.0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/pretty-format": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-2.1.1.tgz", + "integrity": "sha512-SjxPFOtuINDUW8/UkElJYQSFtnWX7tMksSGW0vfjxMneFqxVr8YJ979QpMbDW7g+BIiq88RAGDjf7en6rvLPPQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-2.1.1.tgz", + "integrity": "sha512-uTPuY6PWOYitIkLPidaY5L3t0JJITdGTSwBtwMjKzo5O6RCOEncz9PUN+0pDidX8kTHYjO0EwUIvhlGpnGpxmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "2.1.1", + "pathe": "^1.1.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-2.1.1.tgz", + "integrity": "sha512-BnSku1WFy7r4mm96ha2FzN99AZJgpZOWrAhtQfoxjUU5YMRpq1zmHRq7a5K9/NjqonebO7iVDla+VvZS8BOWMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "2.1.1", + "magic-string": "^0.30.11", + "pathe": "^1.1.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-2.1.1.tgz", + "integrity": "sha512-ZM39BnZ9t/xZ/nF4UwRH5il0Sw93QnZXd9NAZGRpIgj0yvVwPpLd702s/Cx955rGaMlyBQkZJ2Ir7qyY48VZ+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyspy": "^3.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-2.1.1.tgz", + "integrity": "sha512-Y6Q9TsI+qJ2CC0ZKj6VBb+T8UPz593N113nnUykqwANqhgf3QkZeHFlusgKLTqrnVHbj/XDKZcDHol+dxVT+rQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "2.1.1", + "loupe": "^3.1.1", + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/acorn": { + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", + "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", + "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^8.11.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/ansi-regex": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", @@ -722,6 +916,23 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true, + "license": "MIT" + }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -739,6 +950,43 @@ "balanced-match": "^1.0.0" } }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/chai": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.1.1.tgz", + "integrity": "sha512-pT1ZgP8rPNqUgieVaEY+ryQr6Q4HXNg8Ei9UnLUrjN4IA7dvQC5JB+/kxVcPNDHyBcc/26CXPkbNzq3qwrOEKA==", + "dev": true, + "license": "MIT", + "dependencies": { + "assertion-error": "^2.0.1", + "check-error": "^2.1.1", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/check-error": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", + "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 16" + } + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -759,6 +1007,13 @@ "dev": true, "license": "MIT" }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true, + "license": "MIT" + }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -774,6 +1029,34 @@ "node": ">= 8" } }, + "node_modules/debug": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-eql": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", + "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", @@ -828,6 +1111,16 @@ "@esbuild/win32-x64": "0.23.1" } }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, "node_modules/foreground-child": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz", @@ -855,11 +1148,20 @@ "os": [ "darwin" ], - "peer": true, "engines": { "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "node_modules/get-func-name": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", + "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, "node_modules/glob": { "version": "11.0.0", "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.0.tgz", @@ -920,6 +1222,16 @@ "@pkgjs/parseargs": "^0.11.0" } }, + "node_modules/loupe": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.1.tgz", + "integrity": "sha512-edNu/8D5MKVfGVFRhFf8aAxiTM6Wumfz5XsaatSxlD3w4R1d/WEKUTydCdPGbl9K7QG/Ca3GnDV2sIKIpXRQcw==", + "dev": true, + "license": "MIT", + "dependencies": { + "get-func-name": "^2.0.1" + } + }, "node_modules/lru-cache": { "version": "11.0.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.0.1.tgz", @@ -930,6 +1242,23 @@ "node": "20 || >=22" } }, + "node_modules/magic-string": { + "version": "0.30.11", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.11.tgz", + "integrity": "sha512-+Wri9p0QHMy+545hKww7YAu5NyzF8iomPL/RQazugQ9+Ez4Ic3mERMd8ZTX5rfK944j+560ZJi8iAwgak1Ac7A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true, + "license": "ISC" + }, "node_modules/minimatch": { "version": "10.0.1", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.1.tgz", @@ -956,6 +1285,13 @@ "node": ">=16 || 14 >=14.17" } }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, "node_modules/nanoid": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", @@ -967,7 +1303,6 @@ } ], "license": "MIT", - "peer": true, "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -1009,12 +1344,28 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/pathe": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz", + "integrity": "sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/pathval": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", + "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14.16" + } + }, "node_modules/picocolors": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz", "integrity": "sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==", - "license": "ISC", - "peer": true + "license": "ISC" }, "node_modules/postcss": { "version": "8.4.47", @@ -1035,7 +1386,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "nanoid": "^3.3.7", "picocolors": "^1.1.0", @@ -1066,11 +1416,10 @@ } }, "node_modules/rollup": { - "version": "4.22.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.22.0.tgz", - "integrity": "sha512-W21MUIFPZ4+O2Je/EU+GP3iz7PH4pVPUXSbEZdatQnxo29+3rsUjgrJmzuAZU24z7yRAnFN6ukxeAhZh/c7hzg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.22.4.tgz", + "integrity": "sha512-vD8HJ5raRcWOyymsR6Z3o6+RzfEPCnVLMFJ6vRslO1jt4LO6dUo5Qnpg7y4RkZFM2DMe3WUirkI5c16onjrc6A==", "license": "MIT", - "peer": true, "dependencies": { "@types/estree": "1.0.5" }, @@ -1082,22 +1431,22 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.22.0", - "@rollup/rollup-android-arm64": "4.22.0", - "@rollup/rollup-darwin-arm64": "4.22.0", - "@rollup/rollup-darwin-x64": "4.22.0", - "@rollup/rollup-linux-arm-gnueabihf": "4.22.0", - "@rollup/rollup-linux-arm-musleabihf": "4.22.0", - "@rollup/rollup-linux-arm64-gnu": "4.22.0", - "@rollup/rollup-linux-arm64-musl": "4.22.0", - "@rollup/rollup-linux-powerpc64le-gnu": "4.22.0", - "@rollup/rollup-linux-riscv64-gnu": "4.22.0", - "@rollup/rollup-linux-s390x-gnu": "4.22.0", - "@rollup/rollup-linux-x64-gnu": "4.22.0", - "@rollup/rollup-linux-x64-musl": "4.22.0", - "@rollup/rollup-win32-arm64-msvc": "4.22.0", - "@rollup/rollup-win32-ia32-msvc": "4.22.0", - "@rollup/rollup-win32-x64-msvc": "4.22.0", + "@rollup/rollup-android-arm-eabi": "4.22.4", + "@rollup/rollup-android-arm64": "4.22.4", + "@rollup/rollup-darwin-arm64": "4.22.4", + "@rollup/rollup-darwin-x64": "4.22.4", + "@rollup/rollup-linux-arm-gnueabihf": "4.22.4", + "@rollup/rollup-linux-arm-musleabihf": "4.22.4", + "@rollup/rollup-linux-arm64-gnu": "4.22.4", + "@rollup/rollup-linux-arm64-musl": "4.22.4", + "@rollup/rollup-linux-powerpc64le-gnu": "4.22.4", + "@rollup/rollup-linux-riscv64-gnu": "4.22.4", + "@rollup/rollup-linux-s390x-gnu": "4.22.4", + "@rollup/rollup-linux-x64-gnu": "4.22.4", + "@rollup/rollup-linux-x64-musl": "4.22.4", + "@rollup/rollup-win32-arm64-msvc": "4.22.4", + "@rollup/rollup-win32-ia32-msvc": "4.22.4", + "@rollup/rollup-win32-x64-msvc": "4.22.4", "fsevents": "~2.3.2" } }, @@ -1124,6 +1473,13 @@ "node": ">=8" } }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true, + "license": "ISC" + }, "node_modules/signal-exit": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", @@ -1142,11 +1498,24 @@ "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", "license": "BSD-3-Clause", - "peer": true, "engines": { "node": ">=0.10.0" } }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true, + "license": "MIT" + }, + "node_modules/std-env": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.7.0.tgz", + "integrity": "sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==", + "dev": true, + "license": "MIT" + }, "node_modules/string-width": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", @@ -1251,6 +1620,104 @@ "node": ">=8" } }, + "node_modules/tinybench": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyexec": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.0.tgz", + "integrity": "sha512-tVGE0mVJPGb0chKhqmsoosjsS+qUnJVGJpZgsHYQcGoPlG3B51R3PouqTgEGH2Dc9jjFyOqOpix6ZHNMXp1FZg==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinypool": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.0.1.tgz", + "integrity": "sha512-URZYihUbRPcGv95En+sz6MfghfIc2OJ1sv/RmhWZLouPY0/8Vo80viwPvg3dlaS9fuq7fQMEfgRRK7BBZThBEA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.0.0 || >=20.0.0" + } + }, + "node_modules/tinyrainbow": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-1.2.0.tgz", + "integrity": "sha512-weEDEq7Z5eTHPDh4xjX789+fHfF+P8boiFB+0vbWzpbnbsEr/GRaohi/uMKxg8RZMXnl1ItAi/IUHWMsjDV7kQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tinyspy": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-3.0.2.tgz", + "integrity": "sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/ts-node/node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/typescript": { "version": "5.6.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", @@ -1272,12 +1739,18 @@ "devOptional": true, "license": "MIT" }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true, + "license": "MIT" + }, "node_modules/vite": { "version": "5.4.6", "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.6.tgz", "integrity": "sha512-IeL5f8OO5nylsgzd9tq4qD2QqI0k2CQLGrWD0rCN0EQJZpBK5vJAx0I+GDkMOXxQX/OfFHMuLIx6ddAxGX/k+Q==", "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.21.3", "postcss": "^8.4.43", @@ -1332,6 +1805,28 @@ } } }, + "node_modules/vite-node": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-2.1.1.tgz", + "integrity": "sha512-N/mGckI1suG/5wQI35XeR9rsMsPqKXzq1CdUndzVstBj/HvyxxGctwnK6WX43NGt5L3Z5tcRf83g4TITKJhPrA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.3.6", + "pathe": "^1.1.2", + "vite": "^5.0.0" + }, + "bin": { + "vite-node": "vite-node.mjs" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, "node_modules/vite/node_modules/@esbuild/aix-ppc64": { "version": "0.21.5", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", @@ -1344,7 +1839,6 @@ "os": [ "aix" ], - "peer": true, "engines": { "node": ">=12" } @@ -1361,7 +1855,6 @@ "os": [ "android" ], - "peer": true, "engines": { "node": ">=12" } @@ -1378,7 +1871,6 @@ "os": [ "android" ], - "peer": true, "engines": { "node": ">=12" } @@ -1395,7 +1887,6 @@ "os": [ "android" ], - "peer": true, "engines": { "node": ">=12" } @@ -1412,7 +1903,6 @@ "os": [ "darwin" ], - "peer": true, "engines": { "node": ">=12" } @@ -1429,7 +1919,6 @@ "os": [ "darwin" ], - "peer": true, "engines": { "node": ">=12" } @@ -1446,7 +1935,6 @@ "os": [ "freebsd" ], - "peer": true, "engines": { "node": ">=12" } @@ -1463,7 +1951,6 @@ "os": [ "freebsd" ], - "peer": true, "engines": { "node": ">=12" } @@ -1480,7 +1967,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=12" } @@ -1497,7 +1983,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=12" } @@ -1514,7 +1999,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=12" } @@ -1531,7 +2015,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=12" } @@ -1548,7 +2031,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=12" } @@ -1565,7 +2047,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=12" } @@ -1582,7 +2063,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=12" } @@ -1599,7 +2079,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=12" } @@ -1616,7 +2095,6 @@ "os": [ "linux" ], - "peer": true, "engines": { "node": ">=12" } @@ -1633,7 +2111,6 @@ "os": [ "netbsd" ], - "peer": true, "engines": { "node": ">=12" } @@ -1650,7 +2127,6 @@ "os": [ "openbsd" ], - "peer": true, "engines": { "node": ">=12" } @@ -1667,7 +2143,6 @@ "os": [ "sunos" ], - "peer": true, "engines": { "node": ">=12" } @@ -1684,7 +2159,6 @@ "os": [ "win32" ], - "peer": true, "engines": { "node": ">=12" } @@ -1701,7 +2175,6 @@ "os": [ "win32" ], - "peer": true, "engines": { "node": ">=12" } @@ -1718,7 +2191,6 @@ "os": [ "win32" ], - "peer": true, "engines": { "node": ">=12" } @@ -1729,7 +2201,6 @@ "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==", "hasInstallScript": true, "license": "MIT", - "peer": true, "bin": { "esbuild": "bin/esbuild" }, @@ -1762,6 +2233,71 @@ "@esbuild/win32-x64": "0.21.5" } }, + "node_modules/vitest": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-2.1.1.tgz", + "integrity": "sha512-97We7/VC0e9X5zBVkvt7SGQMGrRtn3KtySFQG5fpaMlS+l62eeXRQO633AYhSTC3z7IMebnPPNjGXVGNRFlxBA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/expect": "2.1.1", + "@vitest/mocker": "2.1.1", + "@vitest/pretty-format": "^2.1.1", + "@vitest/runner": "2.1.1", + "@vitest/snapshot": "2.1.1", + "@vitest/spy": "2.1.1", + "@vitest/utils": "2.1.1", + "chai": "^5.1.1", + "debug": "^4.3.6", + "magic-string": "^0.30.11", + "pathe": "^1.1.2", + "std-env": "^3.7.0", + "tinybench": "^2.9.0", + "tinyexec": "^0.3.0", + "tinypool": "^1.0.0", + "tinyrainbow": "^1.2.0", + "vite": "^5.0.0", + "vite-node": "2.1.1", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@types/node": "^18.0.0 || >=20.0.0", + "@vitest/browser": "2.1.1", + "@vitest/ui": "2.1.1", + "happy-dom": "*", + "jsdom": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + } + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -1778,6 +2314,23 @@ "node": ">= 8" } }, + "node_modules/why-is-node-running": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", + "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/wrap-ansi": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", @@ -1875,6 +2428,16 @@ "engines": { "node": ">=8" } + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } } } } diff --git a/package.json b/package.json index 9c335c9..e0d0db3 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "dist/" ], "scripts": { - "test": "echo 'test'", + "test": "vitest", "build": "rimraf dist/ && tsc", "prepublishOnly": "npm run build" }, @@ -23,6 +23,8 @@ "@types/node": "^22.5.5", "esbuild": "^0.23.1", "rimraf": "^6.0.1", - "typescript": "^5.6.2" + "ts-node": "^10.9.2", + "typescript": "^5.6.2", + "vitest": "^2.1.1" } } diff --git a/tests/fixture/alias-target.ts b/tests/fixture/alias-target.ts new file mode 100644 index 0000000..5f1ded4 --- /dev/null +++ b/tests/fixture/alias-target.ts @@ -0,0 +1 @@ +export const result = "it works"; diff --git a/tests/fixture/alias.ts b/tests/fixture/alias.ts new file mode 100644 index 0000000..39f164c --- /dev/null +++ b/tests/fixture/alias.ts @@ -0,0 +1,3 @@ +import { result } from "import-map-alias"; + +console.log(result); diff --git a/tests/fixture/deno.json b/tests/fixture/deno.json new file mode 100644 index 0000000..56b45d0 --- /dev/null +++ b/tests/fixture/deno.json @@ -0,0 +1,9 @@ +{ + "nodeModulesDir": "auto", + "imports": { + "@std/path": "jsr:@std/path@^1.0.6", + "import-map-alias": "./alias-target.ts", + "preact": "npm:preact@^10.24.0", + "preact-http": "https://esm.sh/preact" + } +} diff --git a/tests/fixture/deno.lock b/tests/fixture/deno.lock new file mode 100644 index 0000000..2471038 --- /dev/null +++ b/tests/fixture/deno.lock @@ -0,0 +1,32 @@ +{ + "version": "4", + "specifiers": { + "jsr:@std/path@*": "1.0.6", + "jsr:@std/path@^1.0.6": "1.0.6", + "npm:preact@*": "10.24.0", + "npm:preact@^10.24.0": "10.24.0" + }, + "jsr": { + "@std/path@1.0.6": { + "integrity": "ab2c55f902b380cf28e0eec501b4906e4c1960d13f00e11cfbcd21de15f18fed" + } + }, + "npm": { + "preact@10.24.0": { + "integrity": "sha512-aK8Cf+jkfyuZ0ZZRG9FbYqwmEiGQ4y/PUO4SuTWoyWL244nZZh7bd5h2APd4rSNDYTBNghg1L+5iJN3Skxtbsw==" + } + }, + "redirects": { + "https://esm.sh/preact": "https://esm.sh/preact@10.24.0" + }, + "remote": { + "https://esm.sh/preact@10.24.0": "ab23d4024a0fc68b1632d7e3b5d157d774d5698152b5303adfbda35064e91c7b", + "https://esm.sh/stable/preact@10.24.0/denonext/preact.mjs": "c914516d9df1c45afa542a588beb077ff6a1ab57ec97eb4593006e8794c1752e" + }, + "workspace": { + "dependencies": [ + "jsr:@std/path@^1.0.6", + "npm:preact@^10.24.0" + ] + } +} diff --git a/tests/fixture/http.ts b/tests/fixture/http.ts new file mode 100644 index 0000000..c5d66b8 --- /dev/null +++ b/tests/fixture/http.ts @@ -0,0 +1,5 @@ +import { render } from "preact-http"; + +if (typeof render === "function") { + console.log("it works"); +} diff --git a/tests/fixture/inlineHttp.ts b/tests/fixture/inlineHttp.ts new file mode 100644 index 0000000..1d5847e --- /dev/null +++ b/tests/fixture/inlineHttp.ts @@ -0,0 +1,5 @@ +import { render } from "https://esm.sh/preact"; + +if (typeof render === "function") { + console.log("it works"); +} diff --git a/tests/fixture/inlineJsr.ts b/tests/fixture/inlineJsr.ts new file mode 100644 index 0000000..bd7ec29 --- /dev/null +++ b/tests/fixture/inlineJsr.ts @@ -0,0 +1,5 @@ +import { join } from "jsr:@std/path"; + +if (typeof join === "function") { + console.log("it works"); +} diff --git a/tests/fixture/inlineNpm.ts b/tests/fixture/inlineNpm.ts new file mode 100644 index 0000000..1e62cdf --- /dev/null +++ b/tests/fixture/inlineNpm.ts @@ -0,0 +1,5 @@ +import { render } from "npm:preact"; + +if (typeof render === "function") { + console.log("it works"); +} diff --git a/tests/fixture/jsr.ts b/tests/fixture/jsr.ts new file mode 100644 index 0000000..5806dc8 --- /dev/null +++ b/tests/fixture/jsr.ts @@ -0,0 +1,5 @@ +import { join } from "@std/path"; + +if (typeof join === "function") { + console.log("it works"); +} diff --git a/tests/fixture/npm.ts b/tests/fixture/npm.ts new file mode 100644 index 0000000..a22e076 --- /dev/null +++ b/tests/fixture/npm.ts @@ -0,0 +1,5 @@ +import { render } from "preact"; + +if (typeof render === "function") { + console.log("it works"); +} diff --git a/tests/fixture/vite.config.ts b/tests/fixture/vite.config.ts new file mode 100644 index 0000000..619ddcd --- /dev/null +++ b/tests/fixture/vite.config.ts @@ -0,0 +1,20 @@ +import { defineConfig } from "vite"; +import deno from "../../src/index"; + +export default defineConfig({ + plugins: [deno()], + build: { + lib: { + formats: ["es"], + entry: { + importMapAlias: "alias.ts", + importMapNpm: "npm.ts", + importMapJsr: "jsr.ts", + importMapHttp: "http.ts", + inlineNpm: "inlineNpm.ts", + inlineJsr: "inlineJsr.ts", + inlineHttp: "inlineHttp.ts", + }, + }, + }, +}); From 939e1bfb67df21db62ddf014dcf33f16ff0c056e Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 16:42:04 +0200 Subject: [PATCH 02/24] fix: http resolution --- src/index.ts | 5 ++- src/prefixPlugin.ts | 14 +++++-- src/resolvePlugin.ts | 97 ++++---------------------------------------- src/resolver.ts | 74 +++++++++++++++++++++++++++++++++ tests/plugin.test.ts | 52 ++++++++++++++++++++++++ tests/test-utils.ts | 13 ++++++ 6 files changed, 163 insertions(+), 92 deletions(-) create mode 100644 tests/plugin.test.ts create mode 100644 tests/test-utils.ts diff --git a/src/index.ts b/src/index.ts index acca678..31f48b3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,10 @@ import { Plugin } from "vite"; import prefixPlugin from "./prefixPlugin.js"; import mainPlugin from "./resolvePlugin.js"; +import { DenoResolveResult } from "./resolver.js"; export default function denoPlugin(): Plugin[] { - return [prefixPlugin(), mainPlugin()]; + const cache = new Map(); + + return [prefixPlugin(cache), mainPlugin(cache)]; } diff --git a/src/prefixPlugin.ts b/src/prefixPlugin.ts index 0463f2c..d94bbd3 100644 --- a/src/prefixPlugin.ts +++ b/src/prefixPlugin.ts @@ -1,8 +1,14 @@ import { Plugin } from "vite"; -import { resolveDeno } from "./resolver.js"; +import { + DenoResolveResult, + resolveDeno, + resolveViteSpecifier, +} from "./resolver.js"; import process from "node:process"; -export default function denoPrefixPlugin(): Plugin { +export default function denoPrefixPlugin( + cache: Map, +): Plugin { let root = process.cwd(); return { @@ -11,7 +17,7 @@ export default function denoPrefixPlugin(): Plugin { configResolved(config) { root = config.root; }, - async resolveId(id) { + async resolveId(id, importer) { if (id.startsWith("npm:")) { const resolved = await resolveDeno(id, root); if (resolved === null) return; @@ -19,6 +25,8 @@ export default function denoPrefixPlugin(): Plugin { // TODO: Resolving custom versions is not supported at the moment const actual = resolved.id.slice(0, resolved.id.indexOf("@")); return this.resolve(actual); + } else if (id.startsWith("http:") || id.startsWith("https:")) { + return await resolveViteSpecifier(id, cache, root, importer); } }, }; diff --git a/src/resolvePlugin.ts b/src/resolvePlugin.ts index 8485047..48cac4e 100644 --- a/src/resolvePlugin.ts +++ b/src/resolvePlugin.ts @@ -2,80 +2,29 @@ import { Plugin } from "vite"; import { type DenoMediaType, type DenoResolveResult, - resolveDeno, + isDenoSpecifier, + parseDenoSpecifier, + resolveViteSpecifier, } from "./resolver.js"; import { type Loader, transform } from "esbuild"; import * as fsp from "node:fs/promises"; import process from "node:process"; -const FIX_PROTOCOL_HTTP = /^http:\/[^/]/; - -export default function denoPlugin(): Plugin { +export default function denoPlugin( + cache: Map, +): Plugin { let root = process.cwd(); - // Module info cache - const cache = new Map(); - return { name: "deno", configResolved(config) { root = config.root; }, async resolveId(id, importer) { - // Resolve import map - if (!id.startsWith(".") && !id.startsWith("/")) { - try { - id = import.meta.resolve(id); - } catch { - // Ignore: not resolvable - } - } - - if (importer && isDenoSpecifier(importer)) { - const { id: parentId, resolved: parent } = parseDenoSpecifier(importer); - - // Stich back together the full path if we're dealing with - // an absolute path and the importer was an URL - if ( - id.startsWith("/") && - (parentId.startsWith("http:") || parentId.startsWith("https:")) - ) { - // Vite normalizes slashes because it thinks that these are - // always file paths. - const fixed = FIX_PROTOCOL_HTTP.test(parentId) - ? `http:/${parentId.slice(parentId.indexOf("/"))}` - : `https:/${parentId.slice(parentId.indexOf("/"))}`; - - const url = new URL(fixed); - return `${url.origin}${id}`; - } - - const cached = cache.get(parent); - if (cached === undefined) return; - - const found = cached.dependencies.find((dep) => dep.specifier === id); - - if (found === undefined) return; - - // Check if we need to continue resolution - id = found.code.specifier; - if (!id.startsWith("http://") && !id.startsWith("https://")) { - return found.code.specifier; - } - } + // The "pre"-resolve plugin already resolved it + if (isDenoSpecifier(id)) return; - const resolved = await resolveDeno(id, root); - - // Deno cannot resolve this - if (resolved === null) return; - - cache.set(resolved.id, resolved); - - // Vite can load this - if (resolved.loader === null) return resolved.id; - - // We must load it - return toDenoSpecifier(resolved.loader, id, resolved.id); + return resolveViteSpecifier(id, cache, root, importer); }, async load(id) { if (!isDenoSpecifier(id)) return; @@ -103,34 +52,6 @@ export default function denoPlugin(): Plugin { }; } -type DenoSpecifierName = string & { __brand: "deno" }; - -function isDenoSpecifier(str: string): str is DenoSpecifierName { - return str.startsWith("\0deno"); -} - -function toDenoSpecifier( - loader: DenoMediaType, - id: string, - resolved: string, -): DenoSpecifierName { - return `\0deno::${loader}::${id}::${resolved}` as DenoSpecifierName; -} - -function parseDenoSpecifier(spec: DenoSpecifierName): { - loader: DenoMediaType; - id: string; - resolved: string; -} { - const [_, loader, id, resolved] = spec.split("::") as [ - string, - string, - DenoMediaType, - string, - ]; - return { loader: loader as DenoMediaType, id, resolved }; -} - function mediaTypeToLoader(media: DenoMediaType): Loader { switch (media) { case "JSX": diff --git a/src/resolver.ts b/src/resolver.ts index c61832a..c2472d5 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -102,3 +102,77 @@ export async function resolveDeno( throw new Error(`Unsupported: ${JSON.stringify(mod, null, 2)}`); } + +export async function resolveViteSpecifier( + id: string, + cache: Map, + root: string, + importer?: string, +) { + // Resolve import map + if (!id.startsWith(".") && !id.startsWith("/")) { + try { + id = import.meta.resolve(id); + } catch { + // Ignore: not resolvable + } + } + + if (importer && isDenoSpecifier(importer)) { + const { resolved: parent } = parseDenoSpecifier(importer); + + const cached = cache.get(parent); + if (cached === undefined) return; + + const found = cached.dependencies.find((dep) => dep.specifier === id); + + if (found === undefined) return; + + // Check if we need to continue resolution + id = found.code.specifier; + if (!id.startsWith("http://") && !id.startsWith("https://")) { + return found.code.specifier; + } + } + + const resolved = await resolveDeno(id, root); + + // Deno cannot resolve this + if (resolved === null) return; + + cache.set(resolved.id, resolved); + + // Vite can load this + if (resolved.loader === null) return resolved.id; + + // We must load it + return toDenoSpecifier(resolved.loader, id, resolved.id); +} + +export type DenoSpecifierName = string & { __brand: "deno" }; + +export function isDenoSpecifier(str: string): str is DenoSpecifierName { + return str.startsWith("\0deno"); +} + +export function toDenoSpecifier( + loader: DenoMediaType, + id: string, + resolved: string, +): DenoSpecifierName { + return `\0deno::${loader}::${id}::${resolved}` as DenoSpecifierName; +} + +export function parseDenoSpecifier(spec: DenoSpecifierName): { + loader: DenoMediaType; + id: string; + resolved: string; +} { + const [_, loader, id, resolved] = spec.split("::") as [ + string, + string, + DenoMediaType, + string, + ]; + return { loader: loader as DenoMediaType, id, resolved }; +} diff --git a/tests/plugin.test.ts b/tests/plugin.test.ts new file mode 100644 index 0000000..9073787 --- /dev/null +++ b/tests/plugin.test.ts @@ -0,0 +1,52 @@ +import * as path from "node:path"; +import { execAsync } from "./test-utils.js"; +import { beforeAll, describe, expect, it } from "vitest"; + +const fixtureDir = path.join(import.meta.dirname, "fixture"); + +async function runTest(file: string) { + const res = await execAsync(`node dist/${file}`, { + cwd: fixtureDir, + }); + expect(res.stdout.trim()).toEqual("it works"); +} + +describe("Deno plugin", () => { + beforeAll(async () => { + await execAsync(`npx vite build`, { + cwd: fixtureDir, + }); + }); + + describe("import map", () => { + it("resolves alias", async () => { + await runTest(`importMapAlias.js`); + }); + + it("resolves npm:", async () => { + await runTest(`importMapNpm.js`); + }); + + it("resolves jsr:", async () => { + await runTest(`importMapJsr.js`); + }); + + it("resolves http:", async () => { + await runTest(`importMapHttp.js`); + }); + }); + + describe("inline", () => { + it("resolves npm:", async () => { + await runTest(`inlineNpm.js`); + }); + + it("resolves jsr:", async () => { + await runTest(`inlineJsr.js`); + }); + + it("resolves http:", async () => { + await runTest(`inlineHttp.js`); + }); + }); +}); diff --git a/tests/test-utils.ts b/tests/test-utils.ts new file mode 100644 index 0000000..fd3a50d --- /dev/null +++ b/tests/test-utils.ts @@ -0,0 +1,13 @@ +import child_process from "node:child_process"; + +export async function execAsync( + cmd: string, + options: child_process.ExecOptions, +): Promise<{ stderr: string; stdout: string }> { + return await new Promise((resolve, reject) => + child_process.exec(cmd, options, (error, stdout, stderr) => { + if (error) reject(error); + else resolve({ stdout, stderr }); + }) + ); +} From af357c1a0441d198abe3d4be3d4da5881a9c3bef Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 16:44:38 +0200 Subject: [PATCH 03/24] chore: fix lint errors --- src/resolvePlugin.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/resolvePlugin.ts b/src/resolvePlugin.ts index 48cac4e..60cbda7 100644 --- a/src/resolvePlugin.ts +++ b/src/resolvePlugin.ts @@ -11,7 +11,7 @@ import * as fsp from "node:fs/promises"; import process from "node:process"; export default function denoPlugin( - cache: Map, + cache: Map ): Plugin { let root = process.cwd(); @@ -24,7 +24,7 @@ export default function denoPlugin( // The "pre"-resolve plugin already resolved it if (isDenoSpecifier(id)) return; - return resolveViteSpecifier(id, cache, root, importer); + return await resolveViteSpecifier(id, cache, root, importer); }, async load(id) { if (!isDenoSpecifier(id)) return; From 2cc8727397967e3f1f1b17fbd827f0e52beb6920 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 16:47:20 +0200 Subject: [PATCH 04/24] fix: formatting --- deno.json | 5 +++++ src/resolvePlugin.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 deno.json diff --git a/deno.json b/deno.json new file mode 100644 index 0000000..b319e62 --- /dev/null +++ b/deno.json @@ -0,0 +1,5 @@ +{ + "lint": { + "exclude": ["tests/fixture/dist"] + } +} diff --git a/src/resolvePlugin.ts b/src/resolvePlugin.ts index 60cbda7..091a333 100644 --- a/src/resolvePlugin.ts +++ b/src/resolvePlugin.ts @@ -11,7 +11,7 @@ import * as fsp from "node:fs/promises"; import process from "node:process"; export default function denoPlugin( - cache: Map + cache: Map, ): Plugin { let root = process.cwd(); From f96cd055e503f4db30111e9c13d85e0d4e513e49 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 17:02:16 +0200 Subject: [PATCH 05/24] chore: detect Deno --- deno.json | 6 +++++- src/index.ts | 6 +++--- src/prefixPlugin.ts | 2 +- src/resolver.ts | 18 +++++++++++++++++- tests/test-utils.ts => src/utils.ts | 0 tests/plugin.test.ts | 4 ++-- tsconfig.json | 4 ++-- 7 files changed, 30 insertions(+), 10 deletions(-) rename tests/test-utils.ts => src/utils.ts (100%) diff --git a/deno.json b/deno.json index b319e62..b97458d 100644 --- a/deno.json +++ b/deno.json @@ -1,5 +1,9 @@ { + "unstable": ["sloppy-imports"], "lint": { - "exclude": ["tests/fixture/dist"] + "rules": { + "exclude": ["no-sloppy-imports"] + }, + "exclude": ["tests/fixture/dist/", "dist/"] } } diff --git a/src/index.ts b/src/index.ts index 31f48b3..35c70c9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ import { Plugin } from "vite"; -import prefixPlugin from "./prefixPlugin.js"; -import mainPlugin from "./resolvePlugin.js"; -import { DenoResolveResult } from "./resolver.js"; +import prefixPlugin from "./prefixPlugin"; +import mainPlugin from "./resolvePlugin"; +import { DenoResolveResult } from "./resolver"; export default function denoPlugin(): Plugin[] { const cache = new Map(); diff --git a/src/prefixPlugin.ts b/src/prefixPlugin.ts index d94bbd3..f85dbb1 100644 --- a/src/prefixPlugin.ts +++ b/src/prefixPlugin.ts @@ -3,7 +3,7 @@ import { DenoResolveResult, resolveDeno, resolveViteSpecifier, -} from "./resolver.js"; +} from "./resolver"; import process from "node:process"; export default function denoPrefixPlugin( diff --git a/src/resolver.ts b/src/resolver.ts index c2472d5..d33ec68 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -1,4 +1,6 @@ import { exec } from "node:child_process"; +import process from "node:process"; +import { execAsync } from "./utils"; export type DenoMediaType = | "TypeScript" @@ -52,15 +54,29 @@ function isResolveError( return "error" in info && typeof info.error === "string"; } +let checkedDenoInstall = false; +const DENO_BINARY = process.platform === "win32" ? "deno.exe" : "deno"; + export async function resolveDeno( id: string, cwd: string, ): Promise { + if (!checkedDenoInstall) { + try { + await execAsync(`${DENO_BINARY} --version`, { cwd }); + checkedDenoInstall = true; + } catch { + throw new Error( + `Deno binary could not be found. Install Deno to resolve this error.`, + ); + } + } + // There is no JS-API in Deno to get the final file path in Deno's // cache directory. The `deno info` command reveals that information // though, so we can use that. const output = await new Promise((resolve) => { - exec(`deno info --json '${id}'`, { cwd }, (error, stdout) => { + exec(`${DENO_BINARY} info --json '${id}'`, { cwd }, (error, stdout) => { if (error) resolve(null); else resolve(stdout); }); diff --git a/tests/test-utils.ts b/src/utils.ts similarity index 100% rename from tests/test-utils.ts rename to src/utils.ts diff --git a/tests/plugin.test.ts b/tests/plugin.test.ts index 9073787..60952c3 100644 --- a/tests/plugin.test.ts +++ b/tests/plugin.test.ts @@ -1,8 +1,8 @@ import * as path from "node:path"; -import { execAsync } from "./test-utils.js"; import { beforeAll, describe, expect, it } from "vitest"; +import { execAsync } from "../src/utils.ts"; -const fixtureDir = path.join(import.meta.dirname, "fixture"); +const fixtureDir = path.join(import.meta.dirname!, "fixture"); async function runTest(file: string) { const res = await execAsync(`node dist/${file}`, { diff --git a/tsconfig.json b/tsconfig.json index 8909955..9c7a6d4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,8 +3,8 @@ "outDir": "./dist/", "declaration": true, "target": "ES2020", - "module": "NodeNext", - "moduleResolution": "NodeNext" + "module": "ES2022", + "moduleResolution": "Bundler" }, "include": ["src"], "exclude": ["vendor/"] From fa6bfb81be3d8e069f6762c44c123ece8ff69d0b Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 17:05:46 +0200 Subject: [PATCH 06/24] chore: add Deno to CI --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c8f1191..056d88f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,7 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: denoland/setup-deno@v1 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: From 850568c7fa4abcc04198f4eeb1ab8b6ad84fad43 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 17:12:58 +0200 Subject: [PATCH 07/24] chore: build fixtures on CI --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 056d88f..cc4f7cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,4 +33,8 @@ jobs: - run: npm i - run: npm run build --if-present + - name: Build fixture + working-directory: ./tests/fixture + run: npx vite build --debug + - run: npm test From 53efb05fb11adfd649237cd5af8ded0e8e7abc88 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 17:14:17 +0200 Subject: [PATCH 08/24] chore: follow vite naming convention --- src/prefixPlugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/prefixPlugin.ts b/src/prefixPlugin.ts index f85dbb1..289f4b2 100644 --- a/src/prefixPlugin.ts +++ b/src/prefixPlugin.ts @@ -12,7 +12,7 @@ export default function denoPrefixPlugin( let root = process.cwd(); return { - name: "deno-prefix", + name: "deno:prefix", enforce: "pre", configResolved(config) { root = config.root; From 736950be35ab329dd64644b3824d677d856add1b Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 17:15:41 +0200 Subject: [PATCH 09/24] drop! debug lgos --- src/prefixPlugin.ts | 8 ++++++-- src/resolvePlugin.ts | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/prefixPlugin.ts b/src/prefixPlugin.ts index 289f4b2..423ad8b 100644 --- a/src/prefixPlugin.ts +++ b/src/prefixPlugin.ts @@ -18,15 +18,19 @@ export default function denoPrefixPlugin( root = config.root; }, async resolveId(id, importer) { + console.log("PRE", id, importer); if (id.startsWith("npm:")) { const resolved = await resolveDeno(id, root); if (resolved === null) return; // TODO: Resolving custom versions is not supported at the moment const actual = resolved.id.slice(0, resolved.id.indexOf("@")); - return this.resolve(actual); + const result = this.resolve(actual); + console.log("PRE -> ", result, actual); + return result ?? actual; } else if (id.startsWith("http:") || id.startsWith("https:")) { - return await resolveViteSpecifier(id, cache, root, importer); + const result = await resolveViteSpecifier(id, cache, root, importer); + console.log("PRE -> #2 ", result); } }, }; diff --git a/src/resolvePlugin.ts b/src/resolvePlugin.ts index 091a333..83f1b59 100644 --- a/src/resolvePlugin.ts +++ b/src/resolvePlugin.ts @@ -24,7 +24,9 @@ export default function denoPlugin( // The "pre"-resolve plugin already resolved it if (isDenoSpecifier(id)) return; - return await resolveViteSpecifier(id, cache, root, importer); + const result = await resolveViteSpecifier(id, cache, root, importer); + console.log(id, result); + return result; }, async load(id) { if (!isDenoSpecifier(id)) return; From 2a184e8f95a6e1a5b0f4503929ba5096fa9c77e8 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 17:18:12 +0200 Subject: [PATCH 10/24] chore: use canary Deno --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc4f7cb..da9ac9d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,8 @@ jobs: steps: - uses: actions/checkout@v4 - uses: denoland/setup-deno@v1 + with: + deno-version: canary - run: deno fmt --check - run: deno lint @@ -26,6 +28,8 @@ jobs: steps: - uses: actions/checkout@v4 - uses: denoland/setup-deno@v1 + with: + deno-version: canary - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: From 15a263aa546bcb091db4ca8371ca680b8a1f1e42 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 17:18:44 +0200 Subject: [PATCH 11/24] chore: update action name --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da9ac9d..a80ebf0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Node.js CI +name: CI on: push: From 79c81df8fbb3ff4c1cac99670cd74f0352765a24 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 17:19:15 +0200 Subject: [PATCH 12/24] fix: await promise --- src/prefixPlugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/prefixPlugin.ts b/src/prefixPlugin.ts index 423ad8b..1cbc692 100644 --- a/src/prefixPlugin.ts +++ b/src/prefixPlugin.ts @@ -25,7 +25,7 @@ export default function denoPrefixPlugin( // TODO: Resolving custom versions is not supported at the moment const actual = resolved.id.slice(0, resolved.id.indexOf("@")); - const result = this.resolve(actual); + const result = await this.resolve(actual); console.log("PRE -> ", result, actual); return result ?? actual; } else if (id.startsWith("http:") || id.startsWith("https:")) { From ceb34ecd0605d0ee178dbf85fea564f93aae9bdc Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 17:20:19 +0200 Subject: [PATCH 13/24] fix: missing return --- src/prefixPlugin.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/prefixPlugin.ts b/src/prefixPlugin.ts index 1cbc692..cf30962 100644 --- a/src/prefixPlugin.ts +++ b/src/prefixPlugin.ts @@ -31,6 +31,7 @@ export default function denoPrefixPlugin( } else if (id.startsWith("http:") || id.startsWith("https:")) { const result = await resolveViteSpecifier(id, cache, root, importer); console.log("PRE -> #2 ", result); + return result; } }, }; From f05a167bdbdfaa85dec6b6e8bc7f8f3820a914a4 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 17:22:14 +0200 Subject: [PATCH 14/24] chore: more debug --- src/resolvePlugin.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/resolvePlugin.ts b/src/resolvePlugin.ts index 83f1b59..13b9bc5 100644 --- a/src/resolvePlugin.ts +++ b/src/resolvePlugin.ts @@ -29,12 +29,13 @@ export default function denoPlugin( return result; }, async load(id) { + console.log("LOAD", id); if (!isDenoSpecifier(id)) return; const { loader, resolved } = parseDenoSpecifier(id); + console.log("LOADING", loader, resolved); const content = await fsp.readFile(resolved, "utf-8"); - if (loader === "JavaScript") return content; if (loader === "Json") { return `export default ${content}`; From 42356fc1cedbe582bf9cad3dd6805f722bc76a59 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 17:30:24 +0200 Subject: [PATCH 15/24] chore: add task --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index e0d0db3..24f5223 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "scripts": { "test": "vitest", "build": "rimraf dist/ && tsc", + "build:fixture": "cd tests/fixture && vite build", "prepublishOnly": "npm run build" }, "peerDependencies": { From 76f17c891c3e1c833b5925e6551167de22cd32ed Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 17:30:30 +0200 Subject: [PATCH 16/24] chore: make lsp happy --- tests/fixture/deno.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/fixture/deno.json b/tests/fixture/deno.json index 56b45d0..139bcab 100644 --- a/tests/fixture/deno.json +++ b/tests/fixture/deno.json @@ -1,4 +1,10 @@ { + "unstable": ["sloppy-imports"], + "lint": { + "rules": { + "exclude": ["no-sloppy-imports"] + } + }, "nodeModulesDir": "auto", "imports": { "@std/path": "jsr:@std/path@^1.0.6", From d96396f9701067341ae1e40625d4490a3e8f18ea Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 17:30:36 +0200 Subject: [PATCH 17/24] drop! debug logs --- src/resolver.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/resolver.ts b/src/resolver.ts index d33ec68..89c8020 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -152,6 +152,7 @@ export async function resolveViteSpecifier( } const resolved = await resolveDeno(id, root); + console.log("resolved deno", id, "->", resolved); // Deno cannot resolve this if (resolved === null) return; From eda5a4df3cae83236dcb38e36a2eda9bed8c00a5 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 17:35:37 +0200 Subject: [PATCH 18/24] fix --- src/resolver.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/resolver.ts b/src/resolver.ts index 89c8020..20fefed 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -1,6 +1,7 @@ import { exec } from "node:child_process"; import process from "node:process"; import { execAsync } from "./utils"; +import { resolve } from "path/posix"; export type DenoMediaType = | "TypeScript" @@ -44,6 +45,7 @@ interface DenoInfoJsonV1 { export interface DenoResolveResult { id: string; + kind: "esm" | "npm"; loader: DenoMediaType | null; dependencies: ResolvedInfo["dependencies"]; } @@ -105,12 +107,14 @@ export async function resolveDeno( if (mod.kind === "esm") { return { id: mod.local, + kind: mod.kind, loader: mod.mediaType, dependencies: mod.dependencies, }; } else if (mod.kind === "npm") { return { id: mod.npmPackage, + kind: mod.kind, loader: null, dependencies: [], }; @@ -151,12 +155,17 @@ export async function resolveViteSpecifier( } } - const resolved = await resolveDeno(id, root); + const resolved = cache.get(id) ?? await resolveDeno(id, root); console.log("resolved deno", id, "->", resolved); // Deno cannot resolve this if (resolved === null) return; + if (resolved.kind === "npm") { + resolved.id = id; + } + + console.log("resolved deno", id, "->", resolved); cache.set(resolved.id, resolved); // Vite can load this From cf42051f7b17438fb6f520ef09cba956566302f3 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 17:36:40 +0200 Subject: [PATCH 19/24] chore: remove unused import --- src/resolver.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/resolver.ts b/src/resolver.ts index 20fefed..847a8de 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -1,7 +1,6 @@ import { exec } from "node:child_process"; import process from "node:process"; import { execAsync } from "./utils"; -import { resolve } from "path/posix"; export type DenoMediaType = | "TypeScript" From 113ab9fc08dd02d663adf588bc4ea07c84b0b268 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 17:40:52 +0200 Subject: [PATCH 20/24] logs --- src/prefixPlugin.ts | 3 ++- src/resolvePlugin.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/prefixPlugin.ts b/src/prefixPlugin.ts index cf30962..03d52f7 100644 --- a/src/prefixPlugin.ts +++ b/src/prefixPlugin.ts @@ -18,8 +18,8 @@ export default function denoPrefixPlugin( root = config.root; }, async resolveId(id, importer) { - console.log("PRE", id, importer); if (id.startsWith("npm:")) { + console.log("PRE", id, importer); const resolved = await resolveDeno(id, root); if (resolved === null) return; @@ -29,6 +29,7 @@ export default function denoPrefixPlugin( console.log("PRE -> ", result, actual); return result ?? actual; } else if (id.startsWith("http:") || id.startsWith("https:")) { + console.log("PRE", id, importer); const result = await resolveViteSpecifier(id, cache, root, importer); console.log("PRE -> #2 ", result); return result; diff --git a/src/resolvePlugin.ts b/src/resolvePlugin.ts index 13b9bc5..9b88658 100644 --- a/src/resolvePlugin.ts +++ b/src/resolvePlugin.ts @@ -25,12 +25,12 @@ export default function denoPlugin( if (isDenoSpecifier(id)) return; const result = await resolveViteSpecifier(id, cache, root, importer); - console.log(id, result); + console.log("resolve result", id, result); return result; }, async load(id) { - console.log("LOAD", id); if (!isDenoSpecifier(id)) return; + console.log("LOAD", JSON.stringify(id)); const { loader, resolved } = parseDenoSpecifier(id); From b2667bcea995a0e6b7ea9a0c3ec069cceee716ef Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 25 Sep 2024 17:56:19 +0200 Subject: [PATCH 21/24] fix: let vite handle npm resolution --- src/resolver.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resolver.ts b/src/resolver.ts index 847a8de..77d872c 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -161,7 +161,7 @@ export async function resolveViteSpecifier( if (resolved === null) return; if (resolved.kind === "npm") { - resolved.id = id; + return null; } console.log("resolved deno", id, "->", resolved); From df80e0003862f1638ef52fc0f3ab170919f5cdb9 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Thu, 26 Sep 2024 14:42:59 +0200 Subject: [PATCH 22/24] chore: remove logs --- src/prefixPlugin.ts | 7 +------ src/resolvePlugin.ts | 6 +----- src/resolver.ts | 2 -- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/prefixPlugin.ts b/src/prefixPlugin.ts index 03d52f7..88f1581 100644 --- a/src/prefixPlugin.ts +++ b/src/prefixPlugin.ts @@ -19,20 +19,15 @@ export default function denoPrefixPlugin( }, async resolveId(id, importer) { if (id.startsWith("npm:")) { - console.log("PRE", id, importer); const resolved = await resolveDeno(id, root); if (resolved === null) return; // TODO: Resolving custom versions is not supported at the moment const actual = resolved.id.slice(0, resolved.id.indexOf("@")); const result = await this.resolve(actual); - console.log("PRE -> ", result, actual); return result ?? actual; } else if (id.startsWith("http:") || id.startsWith("https:")) { - console.log("PRE", id, importer); - const result = await resolveViteSpecifier(id, cache, root, importer); - console.log("PRE -> #2 ", result); - return result; + return await resolveViteSpecifier(id, cache, root, importer); } }, }; diff --git a/src/resolvePlugin.ts b/src/resolvePlugin.ts index 9b88658..dfad7da 100644 --- a/src/resolvePlugin.ts +++ b/src/resolvePlugin.ts @@ -24,17 +24,13 @@ export default function denoPlugin( // The "pre"-resolve plugin already resolved it if (isDenoSpecifier(id)) return; - const result = await resolveViteSpecifier(id, cache, root, importer); - console.log("resolve result", id, result); - return result; + return await resolveViteSpecifier(id, cache, root, importer); }, async load(id) { if (!isDenoSpecifier(id)) return; - console.log("LOAD", JSON.stringify(id)); const { loader, resolved } = parseDenoSpecifier(id); - console.log("LOADING", loader, resolved); const content = await fsp.readFile(resolved, "utf-8"); if (loader === "JavaScript") return content; if (loader === "Json") { diff --git a/src/resolver.ts b/src/resolver.ts index 77d872c..7ea51fa 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -155,7 +155,6 @@ export async function resolveViteSpecifier( } const resolved = cache.get(id) ?? await resolveDeno(id, root); - console.log("resolved deno", id, "->", resolved); // Deno cannot resolve this if (resolved === null) return; @@ -164,7 +163,6 @@ export async function resolveViteSpecifier( return null; } - console.log("resolved deno", id, "->", resolved); cache.set(resolved.id, resolved); // Vite can load this From 3ddd9757888525f02ea87270dcc8da9576afc5a3 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Thu, 26 Sep 2024 14:43:12 +0200 Subject: [PATCH 23/24] fix: windows `deno info` --- src/resolver.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resolver.ts b/src/resolver.ts index 7ea51fa..1b84525 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -77,7 +77,7 @@ export async function resolveDeno( // cache directory. The `deno info` command reveals that information // though, so we can use that. const output = await new Promise((resolve) => { - exec(`${DENO_BINARY} info --json '${id}'`, { cwd }, (error, stdout) => { + exec(`${DENO_BINARY} info --json ${id}`, { cwd }, (error, stdout) => { if (error) resolve(null); else resolve(stdout); }); From 99fcd5bc6158d0a9c3c68bc63266270fba27605e Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Thu, 26 Sep 2024 14:45:21 +0200 Subject: [PATCH 24/24] chore: remove provenance flag for now --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7e6c17a..d5f88f1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,6 +16,6 @@ jobs: node-version: "20.x" registry-url: "https://registry.npmjs.org" - run: npm ci - - run: npm publish --provenance --access public + - run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}