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

Function extractSourcemap

playground/test-utils.ts:391–408  ·  view source on GitHub ↗
(
  content: string,
  read?: (filename: string) => Promise<string>,
)

Source from the content-addressed store, hash-verified

389 read: (filename: string) => Promise<string>,
390): Promise<any>
391export function extractSourcemap(
392 content: string,
393 read?: (filename: string) => Promise<string>,
394): any {
395 const lines = content.trim().split('\n')
396 const lastLine = lines[lines.length - 1]
397 if (read) {
398 const result = fromMapFileComment(lastLine, async (url) => {
399 if (url.startsWith('data:')) {
400 throw new Error(`Omit read argument when sourcemap is inline`)
401 }
402 const content = await read(url)
403 return content
404 })
405 return result.then((r) => r.toObject())
406 }
407 return fromComment(lastLine).toObject()
408}
409
410export const formatSourcemapForSnapshot = (
411 map: any,

Calls 1

readFunction · 0.50

Tested by 1