@@ -71,6 +71,7 @@ type buildTask struct {
71
71
configTime time.Time
72
72
extendedConfigTimes []time.Time
73
73
inputFiles []time.Time
74
+ packageJsonTimes []time.Time
74
75
75
76
buildInfoEntry * buildInfoEntry
76
77
buildInfoEntryMu sync.Mutex
@@ -346,6 +347,9 @@ func (t *buildTask) getUpToDateStatus(orchestrator *Orchestrator, configPath tsp
346
347
347
348
// Check the build info
348
349
buildInfoPath := t .resolved .GetBuildInfoFileName ()
350
+ getBuildInfoDirectory := core .Memoize (func () string {
351
+ return tspath .GetDirectoryPath (tspath .GetNormalizedAbsolutePath (buildInfoPath , orchestrator .comparePathsOptions .CurrentDirectory ))
352
+ })
349
353
buildInfo , buildInfoTime := t .loadOrStoreBuildInfo (orchestrator , configPath , buildInfoPath )
350
354
if buildInfo == nil {
351
355
return & upToDateStatus {kind : upToDateStatusTypeOutputMissing , data : buildInfoPath }
@@ -382,15 +386,17 @@ func (t *buildTask) getUpToDateStatus(orchestrator *Orchestrator, configPath tsp
382
386
}
383
387
384
388
// Some of the emit files like source map or dts etc are not yet done
385
- if buildInfo .IsEmitPending (t .resolved , tspath . GetDirectoryPath ( tspath . GetNormalizedAbsolutePath ( buildInfoPath , orchestrator . comparePathsOptions . CurrentDirectory ) )) {
389
+ if buildInfo .IsEmitPending (t .resolved , getBuildInfoDirectory ( )) {
386
390
return & upToDateStatus {kind : upToDateStatusTypeOutOfDateOptions , data : buildInfoPath }
387
391
}
388
392
}
389
393
var inputTextUnchanged bool
390
394
oldestOutputFileAndTime := fileAndTime {buildInfoPath , buildInfoTime }
391
395
var newestInputFileAndTime fileAndTime
392
396
var seenRoots collections.Set [tspath.Path ]
393
- var buildInfoRootInfoReader * incremental.BuildInfoRootInfoReader
397
+ getBuildInfoRootInfoReader := core .Memoize (func () * incremental.BuildInfoRootInfoReader {
398
+ return buildInfo .GetBuildInfoRootInfoReader (getBuildInfoDirectory (), orchestrator .comparePathsOptions )
399
+ })
394
400
for _ , inputFile := range t .resolved .FileNames () {
395
401
inputTime := orchestrator .host .GetMTime (inputFile )
396
402
if inputTime .IsZero () {
@@ -401,10 +407,7 @@ func (t *buildTask) getUpToDateStatus(orchestrator *Orchestrator, configPath tsp
401
407
var version string
402
408
var currentVersion string
403
409
if buildInfo .IsIncremental () {
404
- if buildInfoRootInfoReader == nil {
405
- buildInfoRootInfoReader = buildInfo .GetBuildInfoRootInfoReader (tspath .GetDirectoryPath (tspath .GetNormalizedAbsolutePath (buildInfoPath , orchestrator .comparePathsOptions .CurrentDirectory )), orchestrator .comparePathsOptions )
406
- }
407
- buildInfoFileInfo , resolvedInputPath := buildInfoRootInfoReader .GetBuildInfoFileInfo (inputPath )
410
+ buildInfoFileInfo , resolvedInputPath := getBuildInfoRootInfoReader ().GetBuildInfoFileInfo (inputPath )
408
411
if fileInfo := buildInfoFileInfo .GetFileInfo (); fileInfo != nil && fileInfo .Version () != "" {
409
412
version = fileInfo .Version ()
410
413
if text , ok := orchestrator .host .FS ().ReadFile (string (resolvedInputPath )); ok {
@@ -426,10 +429,7 @@ func (t *buildTask) getUpToDateStatus(orchestrator *Orchestrator, configPath tsp
426
429
seenRoots .Add (inputPath )
427
430
}
428
431
429
- if buildInfoRootInfoReader == nil {
430
- buildInfoRootInfoReader = buildInfo .GetBuildInfoRootInfoReader (tspath .GetDirectoryPath (tspath .GetNormalizedAbsolutePath (buildInfoPath , orchestrator .comparePathsOptions .CurrentDirectory )), orchestrator .comparePathsOptions )
431
- }
432
- for root := range buildInfoRootInfoReader .Roots () {
432
+ for root := range getBuildInfoRootInfoReader ().Roots () {
433
433
if ! seenRoots .Has (root ) {
434
434
// File was root file when project was built but its not any more
435
435
return & upToDateStatus {kind : upToDateStatusTypeOutOfDateRoots , data : & inputOutputName {string (root ), buildInfoPath }}
@@ -512,14 +512,12 @@ func (t *buildTask) getUpToDateStatus(orchestrator *Orchestrator, configPath tsp
512
512
}
513
513
}
514
514
515
- // !!! sheetal TODO : watch??
516
- // // Check package file time
517
- // const packageJsonLookups = state.lastCachedPackageJsonLookups.get(resolvedPath);
518
- // const dependentPackageFileStatus = packageJsonLookups && forEachKey(
519
- // packageJsonLookups,
520
- // path => checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName),
521
- // );
522
- // if (dependentPackageFileStatus) return dependentPackageFileStatus;
515
+ for packageJson := range buildInfo .GetPackageJsons (getBuildInfoDirectory ()) {
516
+ packageJsonStatus := checkInputFileTime (packageJson )
517
+ if packageJsonStatus != nil {
518
+ return packageJsonStatus
519
+ }
520
+ }
523
521
524
522
return & upToDateStatus {
525
523
kind : core .IfElse (
@@ -729,6 +727,11 @@ func (t *buildTask) updateWatch(orchestrator *Orchestrator, oldCache *collection
729
727
}
730
728
}
731
729
}
730
+ if t .buildInfoEntry != nil && t .buildInfoEntry .buildInfo != nil {
731
+ for file := range t .buildInfoEntry .buildInfo .GetPackageJsons (tspath .GetDirectoryPath (string (t .buildInfoEntry .path ))) {
732
+ t .packageJsonTimes = append (t .packageJsonTimes , orchestrator .host .loadOrStoreMTime (file , oldCache , false ))
733
+ }
734
+ }
732
735
}
733
736
734
737
func (t * buildTask ) resetStatus () {
@@ -778,6 +781,16 @@ func (t *buildTask) hasUpdate(orchestrator *Orchestrator, path tspath.Path) upda
778
781
}
779
782
}
780
783
}
784
+ if t .buildInfoEntry != nil && t .buildInfoEntry .buildInfo != nil {
785
+ index := 0
786
+ for file := range t .buildInfoEntry .buildInfo .GetPackageJsons (tspath .GetDirectoryPath (string (t .buildInfoEntry .path ))) {
787
+ if orchestrator .host .GetMTime (file ) != t .packageJsonTimes [index ] {
788
+ t .resetStatus ()
789
+ needsUpdate = true
790
+ }
791
+ index ++
792
+ }
793
+ }
781
794
return core .IfElse (needsConfigUpdate , updateKindConfig , core .IfElse (needsUpdate , updateKindUpdate , updateKindNone ))
782
795
}
783
796
0 commit comments