(code: string, rawMap: RawSourceMap)
| 25 | // Independent oracle for the actual bundler output: walk code points, advance |
| 26 | // columns in UTF-16, and count UTF-8 bytes using the public consumer lookup. |
| 27 | const referenceSizes = (code: string, rawMap: RawSourceMap) => |
| 28 | SourceMapConsumer.with(rawMap, null, (map) => { |
| 29 | const result: Record<string, number> = {}; |
| 30 | let line = 1; |
| 31 | let column = 0; |
| 32 | for (const char of code) { |
| 33 | const { source } = map.originalPositionFor({ line, column }); |
| 34 | if (source != null) { |
| 35 | const id = toReportId(path.resolve(dir, source)); |
| 36 | result[id] = (result[id] ?? 0) + Buffer.byteLength(char); |
| 37 | } |
| 38 | if (char === "\n") { |
| 39 | line++; |
| 40 | column = 0; |
| 41 | } else { |
| 42 | column += char.length; |
| 43 | } |
| 44 | } |
| 45 | return result; |
| 46 | }); |
| 47 | |
| 48 | const files: Record<string, string> = { |
| 49 | "/src/index.js": |
no test coverage detected