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

Function extractSourcemapFromFile

packages/utils/src/source-map/node.ts:11–23  ·  view source on GitHub ↗
(
  code: string,
  filePath: string,
)

Source from the content-addressed store, hash-verified

9// based on vite
10// https://github.com/vitejs/vite/blob/84079a84ad94de4c1ef4f1bdb2ab448ff2c01196/packages/vite/src/node/server/sourcemap.ts#L149
11export function extractSourcemapFromFile(
12 code: string,
13 filePath: string,
14): ExtractedSourceMap | undefined {
15 const map = (
16 convertSourceMap.fromSource(code)
17 || convertSourceMap.fromMapFileSource(
18 code,
19 createConvertSourceMapReadMap(filePath),
20 )
21 )?.toObject()
22 return map ? { map } : undefined
23}
24
25function createConvertSourceMapReadMap(originalFileName: string) {
26 return (filename: string) => {

Callers 3

constructorMethod · 0.90
getBrowserFileSourceMapFunction · 0.90
getSourceMapMethod · 0.90

Calls 1

Tested by

no test coverage detected