Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bae52b5

Browse filesBrowse files
SveLilhi-ogawa
andauthored
fix(vm): fix external module resolve error with deps optimizer query for encoded URI [backport to v4] (#10661)
Co-authored-by: Hiroshi Ogawa <hi.ogawa.zz@gmail.com>
1 parent f911144 commit bae52b5
Copy full SHA for bae52b5

1 file changed

+6-3Lines changed: 6 additions & 3 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/vitest/src/runtime/moduleRunner/cachedResolver.ts‎

Copy file name to clipboardExpand all lines: packages/vitest/src/runtime/moduleRunner/cachedResolver.ts
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { WorkerGlobalState } from '../../types/worker'
22
import { pathToFileURL } from 'node:url'
3+
import { splitFileAndPostfix } from '@vitest/utils/helpers'
34
import { join, normalize } from 'pathe'
45
import { distDir } from '../../paths'
56

@@ -25,9 +26,10 @@ export function getCachedVitestImport(
2526
const root = state().config.root
2627
const relativeRoot = relativeIds[root] ?? (relativeIds[root] = normalizedDistDir.slice(root.length))
2728
if (id.includes(distDir) || id.includes(normalizedDistDir)) {
29+
const { file, postfix } = splitFileAndPostfix(id)
2830
const externalize = id.startsWith('file://')
2931
? id
30-
: pathToFileURL(id).toString()
32+
: `${pathToFileURL(file)}${postfix}`
3133
externalizeMap.set(id, externalize)
3234
return { externalize, type: 'module' }
3335
}
@@ -36,8 +38,9 @@ export function getCachedVitestImport(
3638
// /node_modules/.pnpm/vitest/dist
3739
(relativeRoot && relativeRoot !== '/' && id.startsWith(relativeRoot))
3840
) {
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}`
4144
externalizeMap.set(id, externalize)
4245
return { externalize, type: 'module' }
4346
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.