fix(vite): remove resolveId workaround and update vite-node (#21423)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Daniel Roe <daniel@roe.dev>
This commit is contained in:
renovate[bot] 2023-06-07 12:42:59 +01:00 committed by GitHub
parent 6d59a027c7
commit 5872015be3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 71 additions and 67 deletions

View File

@ -74,7 +74,7 @@
"typescript": "5.0.4", "typescript": "5.0.4",
"ufo": "1.1.2", "ufo": "1.1.2",
"vite": "4.3.9", "vite": "4.3.9",
"vitest": "0.31.4", "vitest": "0.32.0",
"vue": "3.3.4", "vue": "3.3.4",
"vue-eslint-parser": "9.3.0", "vue-eslint-parser": "9.3.0",
"vue-tsc": "1.6.5" "vue-tsc": "1.6.5"

View File

@ -46,7 +46,7 @@
"nitropack": "2.4.1", "nitropack": "2.4.1",
"unbuild": "latest", "unbuild": "latest",
"vite": "4.3.9", "vite": "4.3.9",
"vitest": "0.31.4", "vitest": "0.32.0",
"webpack": "5.85.1" "webpack": "5.85.1"
}, },
"engines": { "engines": {

View File

@ -112,7 +112,7 @@
"acorn": "8.8.2", "acorn": "8.8.2",
"unbuild": "latest", "unbuild": "latest",
"vite": "4.3.9", "vite": "4.3.9",
"vitest": "0.31.4" "vitest": "0.32.0"
}, },
"peerDependencies": { "peerDependencies": {
"@parcel/watcher": "^2.1.0", "@parcel/watcher": "^2.1.0",

View File

@ -36,12 +36,12 @@
"@jest/globals": "29.5.0", "@jest/globals": "29.5.0",
"playwright": "1.34.3", "playwright": "1.34.3",
"unbuild": "latest", "unbuild": "latest",
"vitest": "0.31.4" "vitest": "0.32.0"
}, },
"peerDependencies": { "peerDependencies": {
"@jest/globals": "^29.5.0", "@jest/globals": "^29.5.0",
"playwright": "^1.34.3", "playwright": "^1.34.3",
"vitest": "^0.30.0 || ^0.31.0", "vitest": "^0.30.0 || ^0.31.0 || ^0.32.0",
"vue": "^3.3.4" "vue": "^3.3.4"
}, },
"peerDependenciesMeta": { "peerDependenciesMeta": {

View File

@ -57,7 +57,7 @@
"ufo": "^1.1.2", "ufo": "^1.1.2",
"unplugin": "^1.3.1", "unplugin": "^1.3.1",
"vite": "~4.3.9", "vite": "~4.3.9",
"vite-node": "^0.31.4", "vite-node": "^0.32.0",
"vite-plugin-checker": "^0.6.0", "vite-plugin-checker": "^0.6.0",
"vue-bundle-renderer": "^1.0.3" "vue-bundle-renderer": "^1.0.3"
}, },

View File

@ -33,14 +33,10 @@ export default async (ssrContext) => {
} }
function createRunner () { function createRunner () {
const _importers = new Map()
return new ViteNodeRunner({ return new ViteNodeRunner({
root: viteNodeOptions.root, // Equals to Nuxt `srcDir` root: viteNodeOptions.root, // Equals to Nuxt `srcDir`
base: viteNodeOptions.base, base: viteNodeOptions.base,
resolveId (id, importer) { _importers.set(id, importer) },
async fetchModule (id) { async fetchModule (id) {
const importer = _importers.get(id)
_importers.delete(id)
id = id.replace(/\/\//g, '/') // TODO: fix in vite-node id = id.replace(/\/\//g, '/') // TODO: fix in vite-node
return await viteNodeFetch('/module/' + encodeURI(id)).catch((err) => { return await viteNodeFetch('/module/' + encodeURI(id)).catch((err) => {
const errorData = err?.data?.data const errorData = err?.data?.data
@ -49,7 +45,7 @@ function createRunner () {
} }
let _err let _err
try { try {
const { message, stack } = formatViteError(errorData, id, importer) const { message, stack } = formatViteError(errorData, id)
_err = createError({ _err = createError({
statusMessage: 'Vite Error', statusMessage: 'Vite Error',
message, message,
@ -76,7 +72,7 @@ function createRunner () {
* @param id {string} * @param id {string}
* @param importer {string} * @param importer {string}
*/ */
function formatViteError (errorData, id, importer) { function formatViteError (errorData, id) {
const errorCode = errorData.name || errorData.reasonCode || errorData.code const errorCode = errorData.name || errorData.reasonCode || errorData.code
const frame = errorData.frame || errorData.source || errorData.pluginCode const frame = errorData.frame || errorData.source || errorData.pluginCode
@ -99,7 +95,7 @@ function formatViteError (errorData, id, importer) {
const stack = [ const stack = [
message, message,
`at ${loc} ${importer ? `(imported from ${importer})` : ''}`, `at ${loc}`,
errorData.stack errorData.stack
].filter(Boolean).join('\n') ].filter(Boolean).join('\n')

View File

@ -123,8 +123,8 @@ importers:
specifier: 4.3.9 specifier: 4.3.9
version: 4.3.9(@types/node@18.16.16) version: 4.3.9(@types/node@18.16.16)
vitest: vitest:
specifier: 0.31.4 specifier: 0.32.0
version: 0.31.4(playwright@1.34.3) version: 0.32.0(playwright@1.34.3)
vue: vue:
specifier: 3.3.4 specifier: 3.3.4
version: 3.3.4 version: 3.3.4
@ -211,8 +211,8 @@ importers:
specifier: 4.3.9 specifier: 4.3.9
version: 4.3.9(@types/node@18.16.16) version: 4.3.9(@types/node@18.16.16)
vitest: vitest:
specifier: 0.31.4 specifier: 0.32.0
version: 0.31.4(playwright@1.34.3) version: 0.32.0(playwright@1.34.3)
webpack: webpack:
specifier: 5.85.1 specifier: 5.85.1
version: 5.85.1 version: 5.85.1
@ -414,7 +414,7 @@ importers:
version: 0.2.0 version: 0.2.0
ofetch: ofetch:
specifier: ^1.0.1 specifier: ^1.0.1
version: 1.0.1 version: 1.1.0
ohash: ohash:
specifier: ^1.1.2 specifier: ^1.1.2
version: 1.1.2 version: 1.1.2
@ -498,8 +498,8 @@ importers:
specifier: 4.3.9 specifier: 4.3.9
version: 4.3.9(@types/node@18.16.16) version: 4.3.9(@types/node@18.16.16)
vitest: vitest:
specifier: 0.31.4 specifier: 0.32.0
version: 0.31.4(playwright@1.34.3) version: 0.32.0(playwright@1.34.3)
packages/schema: packages/schema:
dependencies: dependencies:
@ -599,7 +599,7 @@ importers:
version: 3.0.1 version: 3.0.1
ofetch: ofetch:
specifier: ^1.0.1 specifier: ^1.0.1
version: 1.0.1 version: 1.1.0
pathe: pathe:
specifier: ^1.1.1 specifier: ^1.1.1
version: 1.1.1 version: 1.1.1
@ -620,8 +620,8 @@ importers:
specifier: latest specifier: latest
version: 1.2.1 version: 1.2.1
vitest: vitest:
specifier: 0.31.4 specifier: 0.32.0
version: 0.31.4(playwright@1.34.3) version: 0.32.0(playwright@1.34.3)
packages/vite: packages/vite:
dependencies: dependencies:
@ -722,8 +722,8 @@ importers:
specifier: 4.3.9 specifier: 4.3.9
version: 4.3.9(@types/node@18.16.16) version: 4.3.9(@types/node@18.16.16)
vite-node: vite-node:
specifier: ^0.31.4 specifier: ^0.32.0
version: 0.31.4(@types/node@18.16.16) version: 0.32.0(@types/node@18.16.16)
vite-plugin-checker: vite-plugin-checker:
specifier: ^0.6.0 specifier: ^0.6.0
version: 0.6.0(eslint@8.42.0)(typescript@5.0.4)(vite@4.3.9)(vue-tsc@1.6.5) version: 0.6.0(eslint@8.42.0)(typescript@5.0.4)(vite@4.3.9)(vue-tsc@1.6.5)
@ -912,7 +912,7 @@ importers:
devDependencies: devDependencies:
ofetch: ofetch:
specifier: latest specifier: latest
version: 1.0.1 version: 1.1.0
ufo: ufo:
specifier: latest specifier: latest
version: 1.1.2 version: 1.1.2
@ -921,7 +921,7 @@ importers:
version: 1.3.1 version: 1.3.1
vitest: vitest:
specifier: latest specifier: latest
version: 0.31.4(playwright@1.34.3) version: 0.32.0(playwright@1.34.3)
vue-router: vue-router:
specifier: latest specifier: latest
version: 4.2.2(vue@3.3.4) version: 4.2.2(vue@3.3.4)
@ -934,13 +934,13 @@ importers:
devDependencies: devDependencies:
ofetch: ofetch:
specifier: latest specifier: latest
version: 1.0.1 version: 1.1.0
unplugin: unplugin:
specifier: latest specifier: latest
version: 1.3.1 version: 1.3.1
vitest: vitest:
specifier: latest specifier: latest
version: 0.31.4(playwright@1.34.3) version: 0.32.0(playwright@1.34.3)
vue-router: vue-router:
specifier: latest specifier: latest
version: 4.2.2(vue@3.3.4) version: 4.2.2(vue@3.3.4)
@ -1833,7 +1833,7 @@ packages:
mri: 1.2.0 mri: 1.2.0
nanoid: 4.0.2 nanoid: 4.0.2
node-fetch: 3.3.1 node-fetch: 3.3.1
ofetch: 1.0.1 ofetch: 1.1.0
parse-git-config: 3.0.0 parse-git-config: 3.0.0
rc9: 2.1.0 rc9: 2.1.0
std-env: 3.3.3 std-env: 3.3.3
@ -2497,39 +2497,39 @@ packages:
vite: 4.3.9(@types/node@18.16.16) vite: 4.3.9(@types/node@18.16.16)
vue: 3.3.4 vue: 3.3.4
/@vitest/expect@0.31.4: /@vitest/expect@0.32.0:
resolution: {integrity: sha512-tibyx8o7GUyGHZGyPgzwiaPaLDQ9MMuCOrc03BYT0nryUuhLbL7NV2r/q98iv5STlwMgaKuFJkgBW/8iPKwlSg==} resolution: {integrity: sha512-VxVHhIxKw9Lux+O9bwLEEk2gzOUe93xuFHy9SzYWnnoYZFYg1NfBtnfnYWiJN7yooJ7KNElCK5YtA7DTZvtXtg==}
dependencies: dependencies:
'@vitest/spy': 0.31.4 '@vitest/spy': 0.32.0
'@vitest/utils': 0.31.4 '@vitest/utils': 0.32.0
chai: 4.3.7 chai: 4.3.7
dev: true dev: true
/@vitest/runner@0.31.4: /@vitest/runner@0.32.0:
resolution: {integrity: sha512-Wgm6UER+gwq6zkyrm5/wbpXGF+g+UBB78asJlFkIOwyse0pz8lZoiC6SW5i4gPnls/zUcPLWS7Zog0LVepXnpg==} resolution: {integrity: sha512-QpCmRxftHkr72xt5A08xTEs9I4iWEXIOCHWhQQguWOKE4QH7DXSKZSOFibuwEIMAD7G0ERvtUyQn7iPWIqSwmw==}
dependencies: dependencies:
'@vitest/utils': 0.31.4 '@vitest/utils': 0.32.0
concordance: 5.0.4 concordance: 5.0.4
p-limit: 4.0.0 p-limit: 4.0.0
pathe: 1.1.1 pathe: 1.1.1
dev: true dev: true
/@vitest/snapshot@0.31.4: /@vitest/snapshot@0.32.0:
resolution: {integrity: sha512-LemvNumL3NdWSmfVAMpXILGyaXPkZbG5tyl6+RQSdcHnTj6hvA49UAI8jzez9oQyE/FWLKRSNqTGzsHuk89LRA==} resolution: {integrity: sha512-yCKorPWjEnzpUxQpGlxulujTcSPgkblwGzAUEL+z01FTUg/YuCDZ8dxr9sHA08oO2EwxzHXNLjQKWJ2zc2a19Q==}
dependencies: dependencies:
magic-string: 0.30.0 magic-string: 0.30.0
pathe: 1.1.1 pathe: 1.1.1
pretty-format: 27.5.1 pretty-format: 27.5.1
dev: true dev: true
/@vitest/spy@0.31.4: /@vitest/spy@0.32.0:
resolution: {integrity: sha512-3ei5ZH1s3aqbEyftPAzSuunGICRuhE+IXOmpURFdkm5ybUADk+viyQfejNk6q8M5QGX8/EVKw+QWMEP3DTJDag==} resolution: {integrity: sha512-MruAPlM0uyiq3d53BkwTeShXY0rYEfhNGQzVO5GHBmmX3clsxcWp79mMnkOVcV244sNTeDcHbcPFWIjOI4tZvw==}
dependencies: dependencies:
tinyspy: 2.1.0 tinyspy: 2.1.0
dev: true dev: true
/@vitest/utils@0.31.4: /@vitest/utils@0.32.0:
resolution: {integrity: sha512-DobZbHacWznoGUfYU8XDPY78UubJxXfMNY1+SUdOp1NsI34eopSA6aZMeaGu10waSOeYwE8lxrd/pLfT0RMxjQ==} resolution: {integrity: sha512-53yXunzx47MmbuvcOPpLaVljHaeSu1G2dHdmy7+9ngMnQIkBQcvwOcoclWFnxDMxFbnq8exAfh3aKSZaK71J5A==}
dependencies: dependencies:
concordance: 5.0.4 concordance: 5.0.4
loupe: 2.3.6 loupe: 2.3.6
@ -3319,8 +3319,8 @@ packages:
convert-gitmoji: 0.1.3 convert-gitmoji: 0.1.3
execa: 7.1.1 execa: 7.1.1
mri: 1.2.0 mri: 1.2.0
node-fetch-native: 1.1.1 node-fetch-native: 1.2.0
ofetch: 1.0.1 ofetch: 1.1.0
open: 9.1.0 open: 9.1.0
pathe: 1.1.1 pathe: 1.1.1
pkg-types: 1.0.3 pkg-types: 1.0.3
@ -4890,7 +4890,7 @@ packages:
defu: 6.1.2 defu: 6.1.2
https-proxy-agent: 5.0.1 https-proxy-agent: 5.0.1
mri: 1.2.0 mri: 1.2.0
node-fetch-native: 1.1.1 node-fetch-native: 1.2.0
pathe: 1.1.1 pathe: 1.1.1
tar: 6.1.13 tar: 6.1.13
transitivePeerDependencies: transitivePeerDependencies:
@ -6190,8 +6190,8 @@ packages:
mime: 3.0.0 mime: 3.0.0
mlly: 1.3.0 mlly: 1.3.0
mri: 1.2.0 mri: 1.2.0
node-fetch-native: 1.1.1 node-fetch-native: 1.2.0
ofetch: 1.0.1 ofetch: 1.1.0
ohash: 1.1.2 ohash: 1.1.2
openapi-typescript: 6.2.4 openapi-typescript: 6.2.4
pathe: 1.1.1 pathe: 1.1.1
@ -6237,8 +6237,8 @@ packages:
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
engines: {node: '>=10.5.0'} engines: {node: '>=10.5.0'}
/node-fetch-native@1.1.1: /node-fetch-native@1.2.0:
resolution: {integrity: sha512-9VvspTSUp2Sxbl+9vbZTlFGq9lHwE8GDVVekxx6YsNd1YH59sb3Ba8v3Y3cD8PkLNcileGGcA21PFjVl0jzDaw==} resolution: {integrity: sha512-5IAMBTl9p6PaAjYCnMv5FmqIF6GcZnawAVnzaCG0rX2aYZJ4CxEkZNtVPuTRug7fL7wyM5BQYTlAzcyMPi6oTQ==}
/node-fetch@2.6.9: /node-fetch@2.6.9:
resolution: {integrity: sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==} resolution: {integrity: sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==}
@ -6367,7 +6367,15 @@ packages:
resolution: {integrity: sha512-icBz2JYfEpt+wZz1FRoGcrMigjNKjzvufE26m9+yUiacRQRHwnNlGRPiDnW4op7WX/MR6aniwS8xw8jyVelF2g==} resolution: {integrity: sha512-icBz2JYfEpt+wZz1FRoGcrMigjNKjzvufE26m9+yUiacRQRHwnNlGRPiDnW4op7WX/MR6aniwS8xw8jyVelF2g==}
dependencies: dependencies:
destr: 1.2.2 destr: 1.2.2
node-fetch-native: 1.1.1 node-fetch-native: 1.2.0
ufo: 1.1.2
dev: true
/ofetch@1.1.0:
resolution: {integrity: sha512-yjq2ZUUMto1ITpge2J5vNlUfteLzxfHn9aJC55WtVGD3okKwSfPoLaKpcHXmmKd2kZZUGo+jdkFuuj09Blyeig==}
dependencies:
destr: 1.2.2
node-fetch-native: 1.2.0
ufo: 1.1.2 ufo: 1.1.2
/ohash@1.1.2: /ohash@1.1.2:
@ -8019,7 +8027,7 @@ packages:
consola: 3.1.0 consola: 3.1.0
defu: 6.1.2 defu: 6.1.2
mime: 3.0.0 mime: 3.0.0
node-fetch-native: 1.1.1 node-fetch-native: 1.2.0
pathe: 1.1.1 pathe: 1.1.1
/unhead@1.1.27: /unhead@1.1.27:
@ -8127,8 +8135,8 @@ packages:
listhen: 1.0.4 listhen: 1.0.4
lru-cache: 9.1.1 lru-cache: 9.1.1
mri: 1.2.0 mri: 1.2.0
node-fetch-native: 1.1.1 node-fetch-native: 1.2.0
ofetch: 1.0.1 ofetch: 1.1.0
ufo: 1.1.2 ufo: 1.1.2
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
@ -8199,8 +8207,8 @@ packages:
spdx-expression-parse: 3.0.1 spdx-expression-parse: 3.0.1
dev: true dev: true
/vite-node@0.31.4(@types/node@18.16.16): /vite-node@0.32.0(@types/node@18.16.16):
resolution: {integrity: sha512-uzL377GjJtTbuc5KQxVbDu2xfU/x0wVjUtXQR2ihS21q/NK6ROr4oG0rsSkBBddZUVCwzfx22in76/0ZZHXgkQ==} resolution: {integrity: sha512-220P/y8YacYAU+daOAqiGEFXx2A8AwjadDzQqos6wSukjvvTWNqleJSwoUn0ckyNdjHIKoxn93Nh1vWBqEKr3Q==}
engines: {node: '>=v14.18.0'} engines: {node: '>=v14.18.0'}
hasBin: true hasBin: true
dependencies: dependencies:
@ -8305,8 +8313,8 @@ packages:
optionalDependencies: optionalDependencies:
fsevents: 2.3.2 fsevents: 2.3.2
/vitest@0.31.4(playwright@1.34.3): /vitest@0.32.0(playwright@1.34.3):
resolution: {integrity: sha512-GoV0VQPmWrUFOZSg3RpQAPN+LPmHg2/gxlMNJlyxJihkz6qReHDV6b0pPDcqFLNEPya4tWJ1pgwUNP9MLmUfvQ==} resolution: {integrity: sha512-SW83o629gCqnV3BqBnTxhB10DAwzwEx3z+rqYZESehUB+eWsJxwcBQx7CKy0otuGMJTYh7qCVuUX23HkftGl/Q==}
engines: {node: '>=v14.18.0'} engines: {node: '>=v14.18.0'}
hasBin: true hasBin: true
peerDependencies: peerDependencies:
@ -8339,11 +8347,11 @@ packages:
'@types/chai': 4.3.5 '@types/chai': 4.3.5
'@types/chai-subset': 1.3.3 '@types/chai-subset': 1.3.3
'@types/node': 18.16.16 '@types/node': 18.16.16
'@vitest/expect': 0.31.4 '@vitest/expect': 0.32.0
'@vitest/runner': 0.31.4 '@vitest/runner': 0.32.0
'@vitest/snapshot': 0.31.4 '@vitest/snapshot': 0.32.0
'@vitest/spy': 0.31.4 '@vitest/spy': 0.32.0
'@vitest/utils': 0.31.4 '@vitest/utils': 0.32.0
acorn: 8.8.2 acorn: 8.8.2
acorn-walk: 8.2.0 acorn-walk: 8.2.0
cac: 6.7.14 cac: 6.7.14
@ -8360,7 +8368,7 @@ packages:
tinybench: 2.5.0 tinybench: 2.5.0
tinypool: 0.5.0 tinypool: 0.5.0
vite: 4.3.9(@types/node@18.16.16) vite: 4.3.9(@types/node@18.16.16)
vite-node: 0.31.4(@types/node@18.16.16) vite-node: 0.32.0(@types/node@18.16.16)
why-is-node-running: 2.2.2 why-is-node-running: 2.2.2
transitivePeerDependencies: transitivePeerDependencies:
- less - less

View File

@ -34,7 +34,7 @@ describe.skipIf(isWindows || process.env.TEST_BUILDER === 'webpack' || process.e
it('default client bundle size', async () => { it('default client bundle size', async () => {
stats.client = await analyzeSizes('**/*.js', publicDir) stats.client = await analyzeSizes('**/*.js', publicDir)
expect(roundToKilobytes(stats.client.totalBytes)).toMatchInlineSnapshot('"97.8k"') expect(roundToKilobytes(stats.client.totalBytes)).toMatchInlineSnapshot('"98.3k"')
expect(stats.client.files.map(f => f.replace(/\..*\.js/, '.js'))).toMatchInlineSnapshot(` expect(stats.client.files.map(f => f.replace(/\..*\.js/, '.js'))).toMatchInlineSnapshot(`
[ [
"_nuxt/entry.js", "_nuxt/entry.js",
@ -48,7 +48,7 @@ describe.skipIf(isWindows || process.env.TEST_BUILDER === 'webpack' || process.e
expect(roundToKilobytes(stats.server.totalBytes)).toMatchInlineSnapshot('"62.6k"') expect(roundToKilobytes(stats.server.totalBytes)).toMatchInlineSnapshot('"62.6k"')
const modules = await analyzeSizes('node_modules/**/*', serverDir) const modules = await analyzeSizes('node_modules/**/*', serverDir)
expect(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"2284k"') expect(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"2285k"')
const packages = modules.files const packages = modules.files
.filter(m => m.endsWith('package.json')) .filter(m => m.endsWith('package.json'))

View File

@ -15,7 +15,7 @@ export default defineConfig({
globalSetup: 'test/setup.ts', globalSetup: 'test/setup.ts',
testTimeout: isWindows ? 60000 : 10000, testTimeout: isWindows ? 60000 : 10000,
// Excluded plugin because it should throw an error when accidentally loaded via Nuxt // Excluded plugin because it should throw an error when accidentally loaded via Nuxt
exclude: [...configDefaults.exclude, '**/this-should-not-load.spec.js'], exclude: [...configDefaults.exclude, '**/test.ts', '**/this-should-not-load.spec.js'],
maxThreads: process.env.TEST_ENV === 'dev' ? 1 : undefined, maxThreads: process.env.TEST_ENV === 'dev' ? 1 : undefined,
minThreads: process.env.TEST_ENV === 'dev' ? 1 : undefined minThreads: process.env.TEST_ENV === 'dev' ? 1 : undefined
} }