fix(vite-node): correctly resolve virtual modules (#3544)

This commit is contained in:
Vladimir 2023-06-15 10:12:33 +02:00 committed by GitHub
parent 02196f9d95
commit 0cbb07b404
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 475 additions and 47 deletions

10
examples/sveltekit/.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*

View File

@ -0,0 +1,28 @@
{
"name": "vitest-0.32.0-sveltekit",
"type": "module",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"test:unit": "vitest",
"lint": "prettier --plugin-search-dir . --check .",
"format": "prettier --plugin-search-dir . --write ."
},
"devDependencies": {
"@sveltejs/adapter-auto": "^2.1.0",
"@sveltejs/kit": "^1.20.2",
"prettier": "^2.8.8",
"prettier-plugin-svelte": "^2.10.1",
"svelte": "^3.59.1",
"svelte-check": "^3.4.3",
"tslib": "^2.5.3",
"typescript": "^5.1.3",
"vite": "^4.3.9",
"vitest": "latest"
}
}

12
examples/sveltekit/src/app.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface Platform {}
}
}
export {};

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>

View File

@ -0,0 +1,8 @@
import { describe, expect, it } from 'vitest'
import { add } from './add'
describe('sum test', () => {
it('adds 1 + 2 to equal 3', () => {
expect(add(1, 2)).toBe(3)
})
})

View File

@ -0,0 +1,8 @@
import { dev } from '$app/environment'
export function add(a: number, b: number) {
if (dev)
console.warn(`Adding ${a} and ${b}`)
return a + b
}

View File

@ -0,0 +1,2 @@
<h1>Welcome to SvelteKit</h1>
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,18 @@
import adapter from '@sveltejs/adapter-auto'
import { vitePreprocess } from '@sveltejs/kit/vite'
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: vitePreprocess(),
kit: {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter(),
},
}
export default config

View File

@ -0,0 +1,17 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true
}
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
//
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in
}

View File

@ -0,0 +1,6 @@
import { sveltekit } from '@sveltejs/kit/vite'
import { defineConfig } from 'vitest/config'
export default defineConfig({
plugins: [sveltekit()],
})

View File

@ -234,26 +234,28 @@ export class ViteNodeRunner {
private async _resolveUrl(id: string, importer?: string): Promise<[url: string, fsPath: string]> {
// we don't pass down importee here, because otherwise Vite doesn't resolve it correctly
// should be checked before normalization, because it removes this prefix
// TODO: this is a hack, we should find a better way to handle this
if (importer && id.startsWith(VALID_ID_PREFIX))
importer = undefined
id = normalizeRequestId(id, this.options.base)
if (!this.shouldResolveId(id))
return [id, id]
const { path, exists } = toFilePath(id, this.root)
const dep = normalizeRequestId(id, this.options.base)
if (!this.shouldResolveId(dep))
return [dep, dep]
const { path, exists } = toFilePath(dep, this.root)
if (!this.options.resolveId || exists)
return [id, path]
const resolved = await this.options.resolveId(id, importer)
if (!resolved) {
const error = new Error(
`Cannot find module '${id}'${importer ? ` imported from '${importer}'` : ''}.`
+ '\n\n- If you rely on tsconfig.json to resolve modules, please install "vite-tsconfig-paths" plugin to handle module resolution.'
+ '\n - Make sure you don\'t have relative aliases in your Vitest config. Use absolute paths instead. Read more: https://vitest.dev/guide/common-errors',
)
Object.defineProperty(error, 'code', { value: 'ERR_MODULE_NOT_FOUND', enumerable: true })
Object.defineProperty(error, Symbol.for('vitest.error.not_found.data'), { value: { id, importer }, enumerable: false })
throw error
}
const resolvedId = normalizeRequestId(resolved.id, this.options.base)
return [dep, path]
const resolved = await this.options.resolveId(dep, importer)
// TODO: we need to better handle module resolution when different urls point to the same module
// if (!resolved) {
// const error = new Error(
// `Cannot find module '${id}'${importer ? ` imported from '${importer}'` : ''}.`
// + '\n\n- If you rely on tsconfig.json\'s "paths" to resolve modules, please install "vite-tsconfig-paths" plugin to handle module resolution.'
// + '\n- Make sure you don\'t have relative aliases in your Vitest config. Use absolute paths instead. Read more: https://vitest.dev/guide/common-errors',
// )
// Object.defineProperty(error, 'code', { value: 'ERR_MODULE_NOT_FOUND', enumerable: true })
// Object.defineProperty(error, Symbol.for('vitest.error.not_found.data'), { value: { id: dep, importer }, enumerable: false })
// throw error
// }
const resolvedId = resolved ? normalizeRequestId(resolved.id, this.options.base) : dep
return [resolvedId, resolvedId]
}
@ -282,7 +284,7 @@ export class ViteNodeRunner {
const mod = this.moduleCache.getByModuleId(moduleId)
const request = async (dep: string) => {
const [id, depFsPath] = await this.resolveUrl(`${dep}`, fsPath)
const [id, depFsPath] = await this.resolveUrl(String(dep), fsPath)
const depMod = this.moduleCache.getByModuleId(depFsPath)
depMod.importers.add(moduleId)
mod.imports.add(depFsPath)

353
pnpm-lock.yaml generated
View File

@ -328,7 +328,7 @@ importers:
version: 20.2.5
'@types/react':
specifier: latest
version: 18.2.8
version: 18.2.9
'@vitejs/plugin-react':
specifier: latest
version: 4.0.0(vite@4.3.9)
@ -754,6 +754,39 @@ importers:
specifier: workspace:*
version: link:../../packages/vitest
examples/sveltekit:
devDependencies:
'@sveltejs/adapter-auto':
specifier: ^2.1.0
version: 2.1.0(@sveltejs/kit@1.20.2)
'@sveltejs/kit':
specifier: ^1.20.2
version: 1.20.2(svelte@3.59.1)(vite@4.3.9)
prettier:
specifier: ^2.8.8
version: 2.8.8
prettier-plugin-svelte:
specifier: ^2.10.1
version: 2.10.1(prettier@2.8.8)(svelte@3.59.1)
svelte:
specifier: ^3.59.1
version: 3.59.1
svelte-check:
specifier: ^3.4.3
version: 3.4.3(svelte@3.59.1)
tslib:
specifier: ^2.5.3
version: 2.5.3
typescript:
specifier: ^5.1.3
version: 5.1.3
vite:
specifier: ^4.3.9
version: 4.3.9(@types/node@18.16.3)
vitest:
specifier: workspace:*
version: link:../../packages/vitest
examples/vitesse:
dependencies:
vue:
@ -6532,7 +6565,7 @@ packages:
'@rollup/pluginutils': 3.1.0(rollup@2.79.1)
'@types/resolve': 1.17.1
builtin-modules: 3.3.0
deepmerge: 4.2.2
deepmerge: 4.3.1
is-module: 1.0.0
resolve: 1.22.2
rollup: 2.79.1
@ -7772,7 +7805,7 @@ packages:
flat-cache: 3.0.4
micromatch: 4.0.5
react-docgen-typescript: 2.2.2(typescript@4.8.4)
tslib: 2.4.0
tslib: 2.5.3
typescript: 4.8.4
webpack: 5.74.0(esbuild@0.17.18)
transitivePeerDependencies:
@ -8043,6 +8076,59 @@ packages:
string.prototype.matchall: 4.0.7
dev: true
/@sveltejs/adapter-auto@2.1.0(@sveltejs/kit@1.20.2):
resolution: {integrity: sha512-o2pZCfATFtA/Gw/BB0Xm7k4EYaekXxaPGER3xGSY3FvzFJGTlJlZjBseaXwYSM94lZ0HniOjTokN3cWaLX6fow==}
peerDependencies:
'@sveltejs/kit': ^1.0.0
dependencies:
'@sveltejs/kit': 1.20.2(svelte@3.59.1)(vite@4.3.9)
import-meta-resolve: 3.0.0
dev: true
/@sveltejs/kit@1.20.2(svelte@3.59.1)(vite@4.3.9):
resolution: {integrity: sha512-MtR1i+HtmYWcRgtubw1GQqT/+CWXL/z24PegE0xYAdObbhdr7YtEfmoe705D/JZMtMmoPXrmSk4W0MfL5A3lYw==}
engines: {node: ^16.14 || >=18}
hasBin: true
requiresBuild: true
peerDependencies:
svelte: ^3.54.0 || ^4.0.0-next.0
vite: ^4.0.0
dependencies:
'@sveltejs/vite-plugin-svelte': 2.4.1(svelte@3.59.1)(vite@4.3.9)
'@types/cookie': 0.5.1
cookie: 0.5.0
devalue: 4.3.2
esm-env: 1.0.0
kleur: 4.1.5
magic-string: 0.30.0
mime: 3.0.0
sade: 1.8.1
set-cookie-parser: 2.6.0
sirv: 2.0.3
svelte: 3.59.1
tiny-glob: 0.2.9
undici: 5.22.1
vite: 4.3.9(@types/node@18.16.3)
transitivePeerDependencies:
- supports-color
dev: true
/@sveltejs/vite-plugin-svelte-inspector@1.0.2(@sveltejs/vite-plugin-svelte@2.4.1)(svelte@3.59.1)(vite@4.3.9):
resolution: {integrity: sha512-Cy1dUMcYCnDVV/hPLXa43YZJ2jGKVW5rA0xuNL9dlmYhT0yoS1g7+FOFSRlgk0BXKk/Oc7grs+8BVA5Iz2fr8A==}
engines: {node: ^14.18.0 || >= 16}
peerDependencies:
'@sveltejs/vite-plugin-svelte': ^2.2.0
svelte: ^3.54.0 || ^4.0.0-next.0
vite: ^4.0.0
dependencies:
'@sveltejs/vite-plugin-svelte': 2.4.1(svelte@3.59.1)(vite@4.3.9)
debug: 4.3.4(supports-color@8.1.1)
svelte: 3.59.1
vite: 4.3.9(@types/node@18.16.3)
transitivePeerDependencies:
- supports-color
dev: true
/@sveltejs/vite-plugin-svelte@2.0.0(svelte@3.59.1)(vite@4.3.9):
resolution: {integrity: sha512-oUFrYQarRv4fppmxdrv00qw3wX8Ycdj0uv33MfpRZyR8K67dyxiOcHnqkB0zSy5sDJA8RC/2aNtYhXJ8NINVHQ==}
engines: {node: ^14.18.0 || >= 16}
@ -8062,6 +8148,26 @@ packages:
- supports-color
dev: true
/@sveltejs/vite-plugin-svelte@2.4.1(svelte@3.59.1)(vite@4.3.9):
resolution: {integrity: sha512-bNNKvoRY89ptY7udeBSCmTdCVwkjmMcZ0j/z9J5MuedT8jPjq0zrknAo/jF1sToAza4NVaAgR9AkZoD9oJJmnA==}
engines: {node: ^14.18.0 || >= 16}
peerDependencies:
svelte: ^3.54.0 || ^4.0.0-next.0
vite: ^4.0.0
dependencies:
'@sveltejs/vite-plugin-svelte-inspector': 1.0.2(@sveltejs/vite-plugin-svelte@2.4.1)(svelte@3.59.1)(vite@4.3.9)
debug: 4.3.4(supports-color@8.1.1)
deepmerge: 4.3.1
kleur: 4.1.5
magic-string: 0.30.0
svelte: 3.59.1
svelte-hmr: 0.15.1(svelte@3.59.1)
vite: 4.3.9(@types/node@18.16.3)
vitefu: 0.2.4(vite@4.3.9)
transitivePeerDependencies:
- supports-color
dev: true
/@szmarczak/http-timer@5.0.1:
resolution: {integrity: sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw==}
engines: {node: '>=14.16'}
@ -8311,6 +8417,10 @@ packages:
resolution: {integrity: sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==}
dev: true
/@types/cookie@0.5.1:
resolution: {integrity: sha512-COUnqfB2+ckwXXSFInsFdOAWQzCCx+a5hq2ruyj+Vjund94RJQd4LG2u9hnvJrTgunKAaax7ancBYlDrNYxA0g==}
dev: true
/@types/d3-force@3.0.4:
resolution: {integrity: sha512-q7xbVLrWcXvSBBEoadowIUJ7sRpS1yvgMWnzHJggFy5cUZBq2HZL5k/pBSm0GdYWS1vs5/EDwMjSKF55PDY4Aw==}
dev: true
@ -8333,7 +8443,7 @@ packages:
resolution: {integrity: sha512-xryQlOEIe1TduDWAOphR0ihfebKFSWOXpIsk+70JskCfRfW+xALdnJ0r1ZOTo85F9Qsjk6vtlU7edTYHbls9tA==}
dependencies:
'@types/cheerio': 0.22.31
'@types/react': 18.2.8
'@types/react': 18.2.9
dev: true
/@types/eslint-scope@3.7.4:
@ -8562,6 +8672,10 @@ packages:
/@types/prop-types@15.7.5:
resolution: {integrity: sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==}
/@types/pug@2.0.6:
resolution: {integrity: sha512-SnHmG9wN1UVmagJOnyo/qkk0Z7gejYxOYYmaAwr5u2yFYfsupN3sg10kyzN8Hep/2zbHxCnsumxOoRIRMBwKCg==}
dev: true
/@types/qs@6.9.7:
resolution: {integrity: sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==}
dev: true
@ -8575,19 +8689,19 @@ packages:
/@types/react-dom@18.0.6:
resolution: {integrity: sha512-/5OFZgfIPSwy+YuIBP/FgJnQnsxhZhjjrnxudMddeblOouIodEQ75X14Rr4wGSG/bknL+Omy9iWlLo1u/9GzAA==}
dependencies:
'@types/react': 18.2.8
'@types/react': 18.2.9
dev: true
/@types/react-dom@18.0.8:
resolution: {integrity: sha512-C3GYO0HLaOkk9dDAz3Dl4sbe4AKUGTCfFIZsz3n/82dPNN8Du533HzKatDxeUYWu24wJgMP1xICqkWk1YOLOIw==}
dependencies:
'@types/react': 18.2.8
'@types/react': 18.2.9
dev: true
/@types/react-is@17.0.3:
resolution: {integrity: sha512-aBTIWg1emtu95bLTLx0cpkxwGW3ueZv71nE2YFBpL8k/z5czEW8yYpOo8Dp+UUAFAtKwNaOsh/ioSeQnWlZcfw==}
dependencies:
'@types/react': 18.2.8
'@types/react': 18.2.9
dev: false
/@types/react-test-renderer@17.0.2:
@ -8599,7 +8713,7 @@ packages:
/@types/react-transition-group@4.4.5:
resolution: {integrity: sha512-juKD/eiSM3/xZYzjuzH6ZwpP+/lejltmiS3QEzV/vmb/Q8+HfDmxu+Baga8UEMGBqV88Nbg4l2hY/K2DkyaLLA==}
dependencies:
'@types/react': 18.2.8
'@types/react': 18.2.9
dev: false
/@types/react@17.0.49:
@ -8618,8 +8732,8 @@ packages:
csstype: 3.1.0
dev: true
/@types/react@18.2.8:
resolution: {integrity: sha512-lTyWUNrd8ntVkqycEEplasWy2OxNlShj3zqS0LuB1ENUGis5HodmhM7DtCoUGbxj3VW/WsGA0DUhpG6XrM7gPA==}
/@types/react@18.2.9:
resolution: {integrity: sha512-pL3JAesUkF7PEQGxh5XOwdXGV907te6m1/Qe1ERJLgomojS6Ne790QiA7GUl434JEkFA2aAaB6qJ5z4e1zJn/w==}
dependencies:
'@types/prop-types': 15.7.5
'@types/scheduler': 0.16.2
@ -10111,21 +10225,21 @@ packages:
resolution: {integrity: sha512-LOmVnY1iTU2D8tv4Xf6MVMZZ+juIJ87Kt/plMijjN20NMAXGmH4u8bS1t0uT74cZ5gwpocYueV58YwyI8y+GKw==}
engines: {node: '>=8'}
dependencies:
tslib: 2.4.0
tslib: 2.5.3
dev: false
/@wry/equality@0.5.3:
resolution: {integrity: sha512-avR+UXdSrsF2v8vIqIgmeTY0UR91UT+IyablCyKe/uk22uOJ8fusKZnH9JH9e1/EtLeNJBtagNmL3eJdnOV53g==}
engines: {node: '>=8'}
dependencies:
tslib: 2.4.0
tslib: 2.5.3
dev: false
/@wry/trie@0.3.2:
resolution: {integrity: sha512-yRTyhWSls2OY/pYLfwff867r8ekooZ4UI+/gxot5Wj8EFwSf2rG+n+Mo/6LoLQm1TKA4GRj2+LCpbfS937dClQ==}
engines: {node: '>=8'}
dependencies:
tslib: 2.4.0
tslib: 2.5.3
dev: false
/@xmldom/xmldom@0.8.6:
@ -10716,7 +10830,7 @@ packages:
resolution: {integrity: sha512-O0yuUDnZeQDL+ncNGlJ78BiO4jnYI3bvMsD5prT0/nsgijG/LpNBIr63gTjVTNsiGkgQhiyCShTgxt8oXOrklA==}
engines: {node: '>=4'}
dependencies:
tslib: 2.4.0
tslib: 2.5.3
dev: true
/astral-regex@2.0.0:
@ -11563,7 +11677,7 @@ packages:
resolution: {integrity: sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==}
dependencies:
pascal-case: 3.1.2
tslib: 2.4.0
tslib: 2.5.3
dev: true
/camelcase-css@2.0.1:
@ -12888,6 +13002,11 @@ packages:
engines: {node: '>=0.10.0'}
dev: true
/deepmerge@4.3.1:
resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==}
engines: {node: '>=0.10.0'}
dev: true
/default-browser-id@1.0.4:
resolution: {integrity: sha512-qPy925qewwul9Hifs+3sx1ZYn14obHxpkX+mPD369w4Rzg+YkJBgi3SOvwUq81nWSjqGUegIgEPwD8u+HUnxlw==}
engines: {node: '>=0.10.0'}
@ -12990,6 +13109,11 @@ packages:
repeat-string: 1.6.1
dev: true
/detect-indent@6.1.0:
resolution: {integrity: sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==}
engines: {node: '>=8'}
dev: true
/detect-newline@3.1.0:
resolution: {integrity: sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==}
engines: {node: '>=8'}
@ -13016,6 +13140,10 @@ packages:
- supports-color
dev: true
/devalue@4.3.2:
resolution: {integrity: sha512-KqFl6pOgOW+Y6wJgu80rHpo2/3H07vr8ntR9rkkFIRETewbf5GaYYcakYfiKz89K+sLsuPkQIZaXDMjUObZwWg==}
dev: true
/devtools-protocol@0.0.1107588:
resolution: {integrity: sha512-yIR+pG9x65Xko7bErCUSQaDLrO/P1p3JUzEk7JCU4DowPcGHkTGUGQapcfcLc4qj0UaALwZ+cr0riFgiqpixcg==}
dev: true
@ -13261,7 +13389,7 @@ packages:
resolution: {integrity: sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==}
dependencies:
no-case: 3.0.4
tslib: 2.4.0
tslib: 2.5.3
dev: true
/dotenv-expand@5.1.0:
@ -13543,6 +13671,10 @@ packages:
engines: {node: '>=0.4.0'}
dev: true
/es6-promise@3.3.1:
resolution: {integrity: sha512-SOp9Phqvqn7jtEUxPWdWfWoLmyt2VaJ6MpvP9Comy1MceMXqE6bxvaTu4iaxpYYPzhny28Lc+M87/c2cPK6lDg==}
dev: true
/es6-shim@0.35.6:
resolution: {integrity: sha512-EmTr31wppcaIAgblChZiuN/l9Y7DPyw8Xtbg7fIVngn6zMW+IEBJDJngeKC3x6wr0V/vcA2wqeFnaw1bFJbDdA==}
dev: true
@ -14460,6 +14592,10 @@ packages:
- supports-color
dev: true
/esm-env@1.0.0:
resolution: {integrity: sha512-Cf6VksWPsTuW01vU9Mk/3vRue91Zevka5SjyNf3nEpokFRuqt/KjUQoGAwq9qMmhpLTHmXzSIrFRw8zxWzmFBA==}
dev: true
/esno@0.16.3:
resolution: {integrity: sha512-6slSBEV1lMKcX13DBifvnDFpNno5WXhw4j/ff7RI0y51BZiDqEe5dNhhjhIQ3iCOQuzsm2MbVzmwqbN78BBhPg==}
hasBin: true
@ -15633,6 +15769,10 @@ packages:
define-properties: 1.1.4
dev: true
/globalyzer@0.1.0:
resolution: {integrity: sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==}
dev: true
/globby@11.1.0:
resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==}
engines: {node: '>=10'}
@ -15661,6 +15801,10 @@ packages:
- supports-color
dev: true
/globrex@0.1.2:
resolution: {integrity: sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==}
dev: true
/glur@1.1.2:
resolution: {integrity: sha512-l+8esYHTKOx2G/Aao4lEQ0bnHWg4fWtJbVoZZT9Knxi01pB8C80BR85nONLFwkkQoFRCmXY+BUcGZN3yZ2QsRA==}
dev: true
@ -15703,7 +15847,7 @@ packages:
graphql: ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0
dependencies:
graphql: 16.6.0
tslib: 2.4.0
tslib: 2.5.3
dev: false
/graphql@16.6.0:
@ -17029,7 +17173,7 @@ packages:
babel-jest: 27.5.1(@babel/core@7.21.4)
chalk: 4.1.2
ci-info: 3.7.0
deepmerge: 4.2.2
deepmerge: 4.3.1
glob: 7.2.3
graceful-fs: 4.2.10
jest-circus: 27.5.1
@ -18334,7 +18478,7 @@ packages:
/lower-case@2.0.2:
resolution: {integrity: sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==}
dependencies:
tslib: 2.4.0
tslib: 2.5.3
dev: true
/lowercase-keys@3.0.0:
@ -18691,6 +18835,12 @@ packages:
hasBin: true
dev: true
/mime@3.0.0:
resolution: {integrity: sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==}
engines: {node: '>=10.0.0'}
hasBin: true
dev: true
/mimic-fn@2.1.0:
resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==}
engines: {node: '>=6'}
@ -19157,7 +19307,7 @@ packages:
resolution: {integrity: sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==}
dependencies:
lower-case: 2.0.2
tslib: 2.4.0
tslib: 2.5.3
dev: true
/node-dir@0.1.17:
@ -19765,7 +19915,7 @@ packages:
resolution: {integrity: sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==}
dependencies:
dot-case: 3.0.4
tslib: 2.4.0
tslib: 2.5.3
dev: true
/parent-module@1.0.1:
@ -19863,7 +20013,7 @@ packages:
resolution: {integrity: sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==}
dependencies:
no-case: 3.0.4
tslib: 2.4.0
tslib: 2.5.3
dev: true
/pascalcase@0.1.1:
@ -20342,6 +20492,16 @@ packages:
engines: {node: '>= 0.8.0'}
dev: true
/prettier-plugin-svelte@2.10.1(prettier@2.8.8)(svelte@3.59.1):
resolution: {integrity: sha512-Wlq7Z5v2ueCubWo0TZzKc9XHcm7TDxqcuzRuGd0gcENfzfT4JZ9yDlCbEgxWgiPmLHkBjfOtpAWkcT28MCDpUQ==}
peerDependencies:
prettier: ^1.16.4 || ^2.0.0
svelte: ^3.2.0 || ^4.0.0-next.0
dependencies:
prettier: 2.8.8
svelte: 3.59.1
dev: true
/prettier@2.3.0:
resolution: {integrity: sha512-kXtO4s0Lz/DW/IJ9QdWhAf7/NmPWQXkFr/r/WkR3vyI+0v8amTDxiaQSLzs8NBlytfLWX/7uQUMIW677yLKl4w==}
engines: {node: '>=10.13.0'}
@ -20354,6 +20514,12 @@ packages:
hasBin: true
dev: true
/prettier@2.8.8:
resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==}
engines: {node: '>=10.13.0'}
hasBin: true
dev: true
/pretty-bytes@5.6.0:
resolution: {integrity: sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg==}
engines: {node: '>=6'}
@ -21646,7 +21812,14 @@ packages:
/rxjs@7.8.0:
resolution: {integrity: sha512-F2+gxDshqmIub1KdvZkaEfGDwLNpPvk9Fs6LD/MyQxNgMds/WH9OdDDXOmxUZpME+iSK3rQCctkL0DYyytUqMg==}
dependencies:
tslib: 2.4.0
tslib: 2.5.3
dev: true
/sade@1.8.1:
resolution: {integrity: sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==}
engines: {node: '>=6'}
dependencies:
mri: 1.2.0
dev: true
/safaridriver@0.0.4:
@ -21699,6 +21872,15 @@ packages:
resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==}
dev: true
/sander@0.5.1:
resolution: {integrity: sha512-3lVqBir7WuKDHGrKRDn/1Ye3kwpXaDOMsiRP1wd6wpZW56gJhsbp5RqQpA6JG/P+pkXizygnr1dKR8vzWaVsfA==}
dependencies:
es6-promise: 3.3.1
graceful-fs: 4.2.10
mkdirp: 0.5.6
rimraf: 2.7.1
dev: true
/sane@4.1.0:
resolution: {integrity: sha512-hhbzAgTIX8O7SHfp2c8/kREfEn4qO/9q8C9beyY6+tvZ87EpoZ3i1RIEvp27YBswnNbY9mWd6paKVmKbAgLfZA==}
engines: {node: 6.* || 8.* || >= 10.*}
@ -21902,6 +22084,10 @@ packages:
resolution: {integrity: sha512-1jeBGaKNGdEq4FgIrORu/N570dwoPYio8lSoYLWmX7sQ//0JY08Xh9o5pBcgmHQ/MbsYp/aZnOe1s1lIsbLprQ==}
dev: true
/set-cookie-parser@2.6.0:
resolution: {integrity: sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==}
dev: true
/set-value@2.0.1:
resolution: {integrity: sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==}
engines: {node: '>=0.10.0'}
@ -22117,6 +22303,16 @@ packages:
atomic-sleep: 1.0.0
dev: true
/sorcery@0.11.0:
resolution: {integrity: sha512-J69LQ22xrQB1cIFJhPfgtLuI6BpWRiWu1Y3vSsIwK/eAScqJxd/+CJlUuHQRdX2C9NGFamq+KqNywGgaThwfHw==}
hasBin: true
dependencies:
'@jridgewell/sourcemap-codec': 1.4.14
buffer-crc32: 0.2.13
minimist: 1.2.8
sander: 0.5.1
dev: true
/source-list-map@2.0.1:
resolution: {integrity: sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw==}
dev: true
@ -22705,6 +22901,33 @@ packages:
resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}
engines: {node: '>= 0.4'}
/svelte-check@3.4.3(svelte@3.59.1):
resolution: {integrity: sha512-O07soQFY3X0VDt+bcGc6D5naz0cLtjwnmNP9JsEBPVyMemFEqUhL2OdLqvkl5H/u8Jwm50EiAU4BPRn5iin/kg==}
hasBin: true
peerDependencies:
svelte: ^3.55.0 || ^4.0.0-next.0 || ^4.0.0
dependencies:
'@jridgewell/trace-mapping': 0.3.18
chokidar: 3.5.3
fast-glob: 3.2.12
import-fresh: 3.3.0
picocolors: 1.0.0
sade: 1.8.1
svelte: 3.59.1
svelte-preprocess: 5.0.4(svelte@3.59.1)(typescript@5.1.3)
typescript: 5.1.3
transitivePeerDependencies:
- '@babel/core'
- coffeescript
- less
- postcss
- postcss-load-config
- pug
- sass
- stylus
- sugarss
dev: true
/svelte-hmr@0.15.1(svelte@3.59.1):
resolution: {integrity: sha512-BiKB4RZ8YSwRKCNVdNxK/GfY+r4Kjgp9jCLEy0DuqAKfmQtpL38cQK3afdpjw4sqSs4PLi3jIPJIFp259NkZtA==}
engines: {node: ^12.20 || ^14.13.1 || >= 16}
@ -22714,6 +22937,53 @@ packages:
svelte: 3.59.1
dev: true
/svelte-preprocess@5.0.4(svelte@3.59.1)(typescript@5.1.3):
resolution: {integrity: sha512-ABia2QegosxOGsVlsSBJvoWeXy1wUKSfF7SWJdTjLAbx/Y3SrVevvvbFNQqrSJw89+lNSsM58SipmZJ5SRi5iw==}
engines: {node: '>= 14.10.0'}
requiresBuild: true
peerDependencies:
'@babel/core': ^7.10.2
coffeescript: ^2.5.1
less: ^3.11.3 || ^4.0.0
postcss: ^7 || ^8
postcss-load-config: ^2.1.0 || ^3.0.0 || ^4.0.0
pug: ^3.0.0
sass: ^1.26.8
stylus: ^0.55.0
sugarss: ^2.0.0 || ^3.0.0 || ^4.0.0
svelte: ^3.23.0 || ^4.0.0-next.0 || ^4.0.0
typescript: '>=3.9.5 || ^4.0.0 || ^5.0.0'
peerDependenciesMeta:
'@babel/core':
optional: true
coffeescript:
optional: true
less:
optional: true
postcss:
optional: true
postcss-load-config:
optional: true
pug:
optional: true
sass:
optional: true
stylus:
optional: true
sugarss:
optional: true
typescript:
optional: true
dependencies:
'@types/pug': 2.0.6
detect-indent: 6.1.0
magic-string: 0.27.0
sorcery: 0.11.0
strip-indent: 3.0.0
svelte: 3.59.1
typescript: 5.1.3
dev: true
/svelte@3.59.1:
resolution: {integrity: sha512-pKj8fEBmqf6mq3/NfrB9SLtcJcUvjYSWyePlfCqN9gujLB25RitWK8PvFzlwim6hD/We35KbPlRteuA6rnPGcQ==}
engines: {node: '>= 8'}
@ -22994,6 +23264,13 @@ packages:
setimmediate: 1.0.5
dev: true
/tiny-glob@0.2.9:
resolution: {integrity: sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==}
dependencies:
globalyzer: 0.1.0
globrex: 0.1.2
dev: true
/tiny-lru@8.0.2:
resolution: {integrity: sha512-ApGvZ6vVvTNdsmt676grvCkUCGwzG9IqXma5Z07xJgiC5L7akUMof5U8G2JTI9Rz/ovtVhJBlY6mNhEvtjzOIg==}
engines: {node: '>=6'}
@ -23173,7 +23450,7 @@ packages:
resolution: {integrity: sha512-uivwYcQaxAucv1CzRp2n/QdYPo4ILf9VXgH19zEIjFx2EJufV16P0JtJVpYHy89DItG6Kwj2oIUjrcK5au+4tQ==}
engines: {node: '>=8'}
dependencies:
tslib: 2.4.0
tslib: 2.5.3
dev: false
/ts-node@10.9.1(@types/node@18.16.3)(typescript@5.0.4):
@ -23234,6 +23511,10 @@ packages:
/tslib@2.4.0:
resolution: {integrity: sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==}
dev: false
/tslib@2.5.3:
resolution: {integrity: sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w==}
/tsup@6.7.0(ts-node@10.9.1)(typescript@5.0.4):
resolution: {integrity: sha512-L3o8hGkaHnu5TdJns+mCqFsDBo83bJ44rlK7e6VdanIvpea4ArPcU3swWGsLVbXak1PqQx/V+SSmFPujBK+zEQ==}
@ -23400,6 +23681,12 @@ packages:
hasBin: true
dev: true
/typescript@5.1.3:
resolution: {integrity: sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw==}
engines: {node: '>=14.17'}
hasBin: true
dev: true
/ua-parser-js@1.0.34:
resolution: {integrity: sha512-K9mwJm/DaB6mRLZfw6q8IMXipcrmuT6yfhYmwhAkuh+81sChuYstYA+znlgaflUPaYUa3odxKPKGw6Vw/lANew==}
dev: true
@ -23452,6 +23739,13 @@ packages:
busboy: 1.6.0
dev: true
/undici@5.22.1:
resolution: {integrity: sha512-Ji2IJhFXZY0x/0tVBXeQwgPlLWw13GVzpsWPQ3rV50IFMMof2I55PZZxtm4P6iNq+L5znYN9nSTAq0ZyE6lSJw==}
engines: {node: '>=14.0'}
dependencies:
busboy: 1.6.0
dev: true
/unfetch@4.2.0:
resolution: {integrity: sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA==}
dev: true
@ -24253,6 +24547,17 @@ packages:
vite: 4.3.9(@types/node@18.16.3)
dev: true
/vitefu@0.2.4(vite@4.3.9):
resolution: {integrity: sha512-fanAXjSaf9xXtOOeno8wZXIhgia+CZury481LsDaV++lSvcU2R9Ch2bPh3PYFyoHW+w9LqAeYRISVQjUIew14g==}
peerDependencies:
vite: ^3.0.0 || ^4.0.0
peerDependenciesMeta:
vite:
optional: true
dependencies:
vite: 4.3.9(@types/node@18.16.3)
dev: true
/vitepress@1.0.0-alpha.75(@algolia/client-search@4.14.2)(@types/node@18.16.3):
resolution: {integrity: sha512-twpPZ/6UnDR8X0Nmj767KwKhXlTQQM9V/J1i2BP9ryO29/w4hpxBfEum6nvfpNhJ4H3h+cIhwzAK/e9crZ6HEQ==}
hasBin: true

View File

@ -74,9 +74,9 @@ test('dynamic import has null prototype', async () => {
test('dynamic import throws an error', async () => {
const path = './some-unknown-path'
const imported = import(path)
await expect(imported).rejects.toThrowError(/Cannot find module '\.\/some-unknown-path'/)
await expect(imported).rejects.toThrowError(/Failed to load url \.\/some-unknown-path/)
// @ts-expect-error path does not exist
await expect(() => import('./some-unknown-path')).rejects.toThrowError(/Cannot find module/)
await expect(() => import('./some-unknown-path')).rejects.toThrowError(/Failed to load/)
})
test('can import @vite/client', async () => {

View File

@ -66,7 +66,7 @@ it('worker with invalid url throws an error', async () => {
})
expect(event).toBeInstanceOf(ErrorEvent)
expect(event.error).toBeInstanceOf(Error)
expect(event.error.message).toContain('Cannot find module')
expect(event.error.message).toContain('Failed to load')
})
it('self injected into worker and its deps should be equal', async () => {

View File

@ -50,7 +50,7 @@ it('throws an error on invalid path', async () => {
})
expect(event).toBeInstanceOf(ErrorEvent)
expect(event.error).toBeInstanceOf(Error)
expect(event.error.message).toContain('Cannot find module')
expect(event.error.message).toContain('Failed to load')
})
it('doesn\'t trigger events, if closed', async () => {

View File

@ -12,7 +12,7 @@ export default defineConfig({
],
},
onConsoleLog(log) {
if (log.includes('Cannot find module'))
if (log.includes('Failed to load'))
return false
},
},