MCPcopy
hub / github.com/vitest-dev/vitest / resolve

Function resolve

packages/vitest/src/node/pools/rpc.ts:59–85  ·  view source on GitHub ↗
(id, importer, environmentName)

Source from the content-addressed store, hash-verified

57 })
58 },
59 async resolve(id, importer, environmentName) {
60 const environment = project.vite.environments[environmentName]
61 if (!environment) {
62 throw new Error(`The environment ${environmentName} was not defined in the Vite config.`)
63 }
64 const resolved = await environment.pluginContainer.resolveId(id, importer)
65 if (!resolved) {
66 return null
67 }
68 const file = cleanUrl(resolved.id)
69 if (resolved.external) {
70 return {
71 file,
72 // this is only used by the module mocker and it always
73 // standardizes the id to mock "node:url" and "url" at the same time
74 url: isBuiltin(resolved.id)
75 ? toBuiltin(resolved.id)
76 : resolved.id,
77 id: resolved.id,
78 }
79 }
80 return {
81 file: cleanUrl(resolved.id),
82 url: normalizeResolvedIdToUrl(environment, resolved.id),
83 id: resolved.id,
84 }
85 },
86
87 snapshotSaved(snapshot) {
88 vitest.snapshot.add(snapshot)

Callers 15

onStopMethod · 0.70
onStartMethod · 0.70
thirdPartyFunction · 0.50
paths.tsFile · 0.50
importMethod · 0.50
parseTscLikeOutputMethod · 0.50
spawnMethod · 0.50
onResolveFunction · 0.50
loadNativeEnvironmentFunction · 0.50
loadEnvironmentFunction · 0.50
createFunction · 0.50
generateExampleFilesFunction · 0.50

Calls 5

cleanUrlFunction · 0.90
isBuiltinFunction · 0.90
toBuiltinFunction · 0.90
normalizeResolvedIdToUrlFunction · 0.90
resolveIdMethod · 0.45

Tested by

no test coverage detected