( bundleId: string, code: string, map: SourceMapConsumer, dir: string, )
| 10 | } |
| 11 | |
| 12 | const getBytesPerFileUsingSourceMap = ( |
| 13 | bundleId: string, |
| 14 | code: string, |
| 15 | map: SourceMapConsumer, |
| 16 | dir: string, |
| 17 | ) => { |
| 18 | const modules: Record<string, SourceMapModuleRenderInfo> = {}; |
| 19 | |
| 20 | let line = 1; |
| 21 | let column = 0; |
| 22 | const codeChars = [...code]; |
| 23 | for (let i = 0; i < codeChars.length; i++, column++) { |
| 24 | const { source } = map.originalPositionFor({ |
| 25 | line, |
| 26 | column, |
| 27 | }); |
| 28 | if (source != null) { |
| 29 | const id = path.resolve(path.dirname(path.join(dir, bundleId)), source); |
| 30 | |
| 31 | const char = codeChars[i]; |
| 32 | |
| 33 | modules[id] = modules[id] || { id, renderedLength: 0, code: [] }; |
| 34 | modules[id].renderedLength += Buffer.byteLength(char); |
| 35 | modules[id].code.push(char); |
| 36 | } |
| 37 | |
| 38 | if (code[i] === "\n") { |
| 39 | line += 1; |
| 40 | column = -1; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | return modules; |
| 45 | }; |
| 46 | |
| 47 | export const getSourcemapModules = ( |
| 48 | id: string, |
no outgoing calls
no test coverage detected