| 389 | read: (filename: string) => Promise<string>, |
| 390 | ): Promise<any> |
| 391 | export 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 | |
| 410 | export const formatSourcemapForSnapshot = ( |
| 411 | map: any, |