MCPcopy
hub / github.com/vitejs/vite / getSourceMap

Function getSourceMap

packages/vite/src/node/plugins/forwardConsole.ts:85–110  ·  view source on GitHub ↗
(id)

Source from the content-addressed store, hash-verified

83 return id
84 },
85 getSourceMap(id) {
86 if (sourceMapCache.has(id)) {
87 return sourceMapCache.get(id)
88 }
89
90 const result = environment.moduleGraph.getModuleById(id)?.transformResult
91 // handle non-inline source map such as pre-bundled deps in node_modules/.vite
92 if (result && !result.map) {
93 try {
94 const filePath = id.split('?')[0]
95 const extracted = extractSourcemapFromFile(
96 result.code,
97 filePath,
98 environment.config.logger,
99 )
100 sourceMapCache.set(id, extracted?.map)
101 return extracted?.map
102 } catch {
103 sourceMapCache.set(id, null)
104 return null
105 }
106 }
107
108 sourceMapCache.set(id, result?.map)
109 return result?.map
110 },
111 // override it to empty since vitest uses this option to skip internal files by default.
112 // https://github.com/vitest-dev/vitest/blob/4783137cd8d766cf998bdf2d638890eaa51e08d9/packages/utils/src/source-map.ts#L17
113 ignoreStackEntries: [],

Callers

nothing calls this directly

Calls 5

extractSourcemapFromFileFunction · 0.90
hasMethod · 0.80
getMethod · 0.45
getModuleByIdMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected