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

Function fetchModule

packages/vitest/src/integrations/env/loader.ts:32–46  ·  view source on GitHub ↗
(id, importer, options)

Source from the content-addressed store, hash-verified

30 sourcemapInterceptor: 'prepareStackTrace',
31 transport: new VitestTransport({
32 async fetchModule(id, importer, options) {
33 const result = await rpc.fetch(id, importer, '__vitest__', options)
34 if ('cached' in result) {
35 const code = readFileSync(result.tmp, 'utf-8')
36 return { code, ...result }
37 }
38 if (isWindows && 'externalize' in result) {
39 // TODO: vitest returns paths for external modules, but Vite returns file://
40 // https://github.com/vitejs/vite/pull/20449
41 result.externalize = isBuiltin(id) || /^(?:node:|data:|http:|https:|file:)/.test(id)
42 ? result.externalize
43 : pathToFileURL(result.externalize).toString()
44 }
45 return result
46 },
47 async resolveId(id, importer) {
48 return rpc.resolve(id, importer, '__vitest__')
49 },

Callers 1

fetchAndProcessMethod · 0.90

Calls 5

readFileSyncFunction · 0.85
isBuiltinFunction · 0.85
fetchMethod · 0.80
testMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected