( files: Record<string, string>, outputs: Record<string, string>, file: ts.SourceFile, precompiled: TransformedModule | undefined, options: ts.CompilerOptions )
| 208 | |
| 209 | // each map tsc emits for a module is mapped through the precompiled one's to its source |
| 210 | const writeOutputs = ( |
| 211 | files: Record<string, string>, |
| 212 | outputs: Record<string, string>, |
| 213 | file: ts.SourceFile, |
| 214 | precompiled: TransformedModule | undefined, |
| 215 | options: ts.CompilerOptions |
| 216 | ) => { |
| 217 | for (const fileName in outputs) { |
| 218 | if (fileName.endsWith(".map")) continue |
| 219 | const code = outputs[fileName] |
| 220 | const tscMap = outputs[`${fileName}.map`] |
| 221 | const map = |
| 222 | tscMap && mapToSource(JSON.parse(tscMap), precompiled?.map, file.text) |
| 223 | if (map && options.inlineSourceMap) { |
| 224 | files[fileName] = appendSourceMap( |
| 225 | code.replace(/\n\/\/# sourceMappingURL=.*$/, ""), |
| 226 | map |
| 227 | ) |
| 228 | } else { |
| 229 | files[fileName] = code |
| 230 | if (map) files[`${fileName}.map`] = JSON.stringify(map) |
| 231 | } |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | // tsc's CommonJS requires where the import was, but a precompiled module reads its imports first |
| 236 | const hoistImportsOf = |
no test coverage detected