MCPcopy Create free account
hub / github.com/arktypeio/arktype / writeOutputs

Function writeOutputs

ark/aot/emit.ts:210–233  ·  view source on GitHub ↗
(
	files: Record<string, string>,
	outputs: Record<string, string>,
	file: ts.SourceFile,
	precompiled: TransformedModule | undefined,
	options: ts.CompilerOptions
)

Source from the content-addressed store, hash-verified

208
209// each map tsc emits for a module is mapped through the precompiled one's to its source
210const 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
236const hoistImportsOf =

Callers 1

emitProjectFunction · 0.85

Calls 4

mapToSourceFunction · 0.90
appendSourceMapFunction · 0.90
replaceMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected