[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

fix(vm): fix external module resolve error with deps optimizer query for encoded URI (#10658)

authored by

Sven Lilienthal and committed by
GitHub
(Jun 25, 2026, 12:24 PM +0200) 90c4ed4c 40cdc7fd

+6 -3
+6 -3
packages/vitest/src/runtime/moduleRunner/cachedResolver.ts
··· 1 1 import type { WorkerGlobalState } from '../../types/worker' 2 2 import { pathToFileURL } from 'node:url' 3 + import { splitFileAndPostfix } from '@vitest/utils/helpers' 3 4 import { join, normalize } from 'pathe' 4 5 import { distDir } from '../../paths' 5 6 ··· 25 26 const root = state().config.root 26 27 const relativeRoot = relativeIds[root] ?? (relativeIds[root] = normalizedDistDir.slice(root.length)) 27 28 if (id.includes(distDir) || id.includes(normalizedDistDir)) { 29 + const { file, postfix } = splitFileAndPostfix(id) 28 30 const externalize = id.startsWith('file://') 29 31 ? id 30 - : pathToFileURL(id).toString() 32 + : `${pathToFileURL(file)}${postfix}` 31 33 externalizeMap.set(id, externalize) 32 34 return { externalize, type: 'module' } 33 35 } ··· 36 38 // /node_modules/.pnpm/vitest/dist 37 39 (relativeRoot && relativeRoot !== '/' && id.startsWith(relativeRoot)) 38 40 ) { 39 - const path = join(root, id) 40 - const externalize = pathToFileURL(path).toString() 41 + const { file, postfix } = splitFileAndPostfix(id) 42 + const path = join(root, file) 43 + const externalize = `${pathToFileURL(path)}${postfix}` 41 44 externalizeMap.set(id, externalize) 42 45 return { externalize, type: 'module' } 43 46 }