MCPcopy Index your code
hub / github.com/nodejs/node / emitFiles

Function emitFiles

test/fixtures/snapshot/typescript.js:110229–110525  ·  view source on GitHub ↗
(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit)

Source from the content-addressed store, hash-verified

110227 /*@internal*/
110228 // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature
110229 function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) {
110230 var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers;
110231 var compilerOptions = host.getCompilerOptions();
110232 var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined;
110233 var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined;
110234 var emitterDiagnostics = ts.createDiagnosticCollection();
110235 var newLine = ts.getNewLineCharacter(compilerOptions, function () { return host.getNewLine(); });
110236 var writer = ts.createTextWriter(newLine);
110237 var _b = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _b.enter, exit = _b.exit;
110238 var bundleBuildInfo;
110239 var emitSkipped = false;
110240 var exportedModulesFromDeclarationEmit;
110241 // Emit each output file
110242 enter();
110243 forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile);
110244 exit();
110245 return {
110246 emitSkipped: emitSkipped,
110247 diagnostics: emitterDiagnostics.getDiagnostics(),
110248 emittedFiles: emittedFilesList,
110249 sourceMaps: sourceMapDataList,
110250 exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit
110251 };
110252 function emitSourceFileOrBundle(_a, sourceFileOrBundle) {
110253 var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
110254 var buildInfoDirectory;
110255 if (buildInfoPath && sourceFileOrBundle && ts.isBundle(sourceFileOrBundle)) {
110256 buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
110257 bundleBuildInfo = {
110258 commonSourceDirectory: relativeToBuildInfo(host.getCommonSourceDirectory()),
110259 sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); })
110260 };
110261 }
110262 ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath });
110263 emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo);
110264 ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
110265 ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath });
110266 emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo);
110267 ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
110268 ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath });
110269 emitBuildInfo(bundleBuildInfo, buildInfoPath);
110270 ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
110271 if (!emitSkipped && emittedFilesList) {
110272 if (!emitOnlyDtsFiles) {
110273 if (jsFilePath) {
110274 emittedFilesList.push(jsFilePath);
110275 }
110276 if (sourceMapFilePath) {
110277 emittedFilesList.push(sourceMapFilePath);
110278 }
110279 if (buildInfoPath) {
110280 emittedFilesList.push(buildInfoPath);
110281 }
110282 }
110283 if (declarationFilePath) {
110284 emittedFilesList.push(declarationFilePath);
110285 }
110286 if (declarationMapPath) {

Callers 1

emitUsingBuildInfoFunction · 0.85

Calls 3

forEachEmittedFileFunction · 0.85
enterFunction · 0.70
exitFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…