@@ -404,6 +404,7 @@ namespace ts {
404
404
/** Map from config file name to up-to-date status */
405
405
const projectStatus = createFileMap < UpToDateStatus > ( toPath ) ;
406
406
const missingRoots = createMap < true > ( ) ;
407
+ let globalDependencyGraph : DependencyGraph | false | undefined ;
407
408
408
409
// Watch state
409
410
// TODO(shkamat): this should be really be diagnostics but thats for later time
@@ -446,6 +447,7 @@ namespace ts {
446
447
unchangedOutputs . clear ( ) ;
447
448
projectStatus . clear ( ) ;
448
449
missingRoots . clear ( ) ;
450
+ globalDependencyGraph = undefined ;
449
451
450
452
diagnostics . clear ( ) ;
451
453
projectPendingBuild . clear ( ) ;
@@ -527,7 +529,6 @@ namespace ts {
527
529
function watchConfigFile ( resolved : ResolvedConfigFileName ) {
528
530
if ( ! allWatchedConfigFiles . hasKey ( resolved ) ) {
529
531
allWatchedConfigFiles . setValue ( resolved , hostWithWatch . watchFile ( resolved , ( ) => {
530
- configFileCache . removeKey ( resolved ) ;
531
532
invalidateProjectAndScheduleBuilds ( resolved , ConfigFileProgramReloadLevel . Full ) ;
532
533
} ) ) ;
533
534
}
@@ -626,7 +627,10 @@ namespace ts {
626
627
}
627
628
628
629
function getGlobalDependencyGraph ( ) {
629
- return getBuildGraph ( rootNames ) ;
630
+ if ( globalDependencyGraph === undefined ) {
631
+ globalDependencyGraph = getBuildGraph ( rootNames ) || false ;
632
+ }
633
+ return globalDependencyGraph || undefined ;
630
634
}
631
635
632
636
function getUpToDateStatus ( project : ParsedCommandLine | undefined ) : UpToDateStatus {
@@ -811,12 +815,17 @@ namespace ts {
811
815
}
812
816
813
817
function invalidateResolvedProject ( resolved : ResolvedConfigFileName , reloadLevel ?: ConfigFileProgramReloadLevel ) {
818
+ if ( reloadLevel === ConfigFileProgramReloadLevel . Full ) {
819
+ configFileCache . removeKey ( resolved ) ;
820
+ globalDependencyGraph = undefined ;
821
+ }
814
822
projectStatus . removeKey ( resolved ) ;
815
823
if ( options . watch ) {
816
824
diagnostics . removeKey ( resolved ) ;
817
825
}
818
826
819
827
if ( addProjToQueue ( resolved , reloadLevel ) ) {
828
+ // TODO: instead of adding the dependent project to queue right away postpone this
820
829
const dependencyGraph = getGlobalDependencyGraph ( ) ;
821
830
if ( dependencyGraph ) {
822
831
queueBuildForDownstreamReferences ( resolved , dependencyGraph ) ;
@@ -1126,9 +1135,9 @@ namespace ts {
1126
1135
projectStatus . setValue ( proj . options . configFilePath as ResolvedConfigFilePath , { type : UpToDateStatusType . UpToDate , newestDeclarationFileContentChangedTime : priorNewestUpdateTime } as UpToDateStatus ) ;
1127
1136
}
1128
1137
1129
- function getFilesToClean ( configFileNames : ReadonlyArray < string > ) : string [ ] | undefined {
1138
+ function getFilesToClean ( ) : string [ ] | undefined {
1130
1139
// Get the same graph for cleaning we'd use for building
1131
- const graph = getBuildGraph ( configFileNames ) ;
1140
+ const graph = getGlobalDependencyGraph ( ) ;
1132
1141
if ( graph === undefined ) return undefined ;
1133
1142
1134
1143
const filesToDelete : string [ ] = [ ] ;
@@ -1149,7 +1158,7 @@ namespace ts {
1149
1158
}
1150
1159
1151
1160
function cleanAllProjects ( ) {
1152
- const filesToDelete = getFilesToClean ( rootNames ) ;
1161
+ const filesToDelete = getFilesToClean ( ) ;
1153
1162
if ( filesToDelete === undefined ) {
1154
1163
reportStatus ( Diagnostics . Skipping_clean_because_not_all_projects_could_be_located ) ;
1155
1164
return ExitStatus . DiagnosticsPresent_OutputsSkipped ;
0 commit comments