From 6525a7b1c7d47e710dd82aa7cb8caefb525d3124 Mon Sep 17 00:00:00 2001 From: Gerrit Birkeland Date: Tue, 8 Dec 2020 20:07:53 -0700 Subject: [PATCH] fix(perf): Only create extra programs when dealing with solution style tsconfigs --- src/lib/application.ts | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/lib/application.ts b/src/lib/application.ts index 0771db607..437aa052c 100644 --- a/src/lib/application.ts +++ b/src/lib/application.ts @@ -212,17 +212,22 @@ export class Application extends ChildableComponent< // This might be a solution style tsconfig, in which case we need to add a program for each // reference so that the converter can look through each of these. - const resolvedReferences = programs[0].getResolvedProjectReferences(); - for (const ref of resolvedReferences ?? []) { - if (!ref) continue; // This indicates bad configuration... will be reported later. - - programs.push( - ts.createProgram({ - options: ref.commandLine.options, - rootNames: ref.commandLine.fileNames, - projectReferences: ref.commandLine.projectReferences, - }) + if (programs[0].getRootFileNames().length === 0) { + this.logger.verbose( + "tsconfig appears to be a solution style tsconfig - creating programs for references" ); + const resolvedReferences = programs[0].getResolvedProjectReferences(); + for (const ref of resolvedReferences ?? []) { + if (!ref) continue; // This indicates bad configuration... will be reported later. + + programs.push( + ts.createProgram({ + options: ref.commandLine.options, + rootNames: ref.commandLine.fileNames, + projectReferences: ref.commandLine.projectReferences, + }) + ); + } } this.logger.verbose(`Converting with ${programs.length} programs`);