( id: string, originalCode: string, originalSourcemap: ExistingDecodedSourceMap | null, sourcemapChain: readonly DecodedSourceMapOrMissing[], linkMap: (source: Source | Link, map: DecodedSourceMapOrMissing) => Link )
| 175 | } |
| 176 | |
| 177 | function getCollapsedSourcemap( |
| 178 | id: string, |
| 179 | originalCode: string, |
| 180 | originalSourcemap: ExistingDecodedSourceMap | null, |
| 181 | sourcemapChain: readonly DecodedSourceMapOrMissing[], |
| 182 | linkMap: (source: Source | Link, map: DecodedSourceMapOrMissing) => Link |
| 183 | ): Source | Link { |
| 184 | let source: Source | Link; |
| 185 | |
| 186 | if (originalSourcemap) { |
| 187 | const sources = originalSourcemap.sources; |
| 188 | const sourcesContent = originalSourcemap.sourcesContent || []; |
| 189 | const directory = dirname(id) || '.'; |
| 190 | const sourceRoot = originalSourcemap.sourceRoot || '.'; |
| 191 | |
| 192 | const baseSources = sources.map( |
| 193 | (source, index) => new Source(resolve(directory, sourceRoot, source), sourcesContent[index]) |
| 194 | ); |
| 195 | source = new Link(originalSourcemap, baseSources); |
| 196 | } else { |
| 197 | source = new Source(id, originalCode); |
| 198 | } |
| 199 | return sourcemapChain.reduce(linkMap, source); |
| 200 | } |
| 201 | |
| 202 | export function collapseSourcemaps( |
| 203 | file: string, |
no test coverage detected
searching dependent graphs…