Skip to content

Commit 2fb5d4c

Browse files
authored
Rebuilt build mode around fswatch package (#4326)
1 parent 900f95a commit 2fb5d4c

70 files changed

Lines changed: 2359 additions & 413 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

internal/execute/build/buildtask.go

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package build
22

33
import (
44
"fmt"
5-
"slices"
65
"strings"
76
"sync"
87
"sync/atomic"
@@ -19,14 +18,6 @@ import (
1918
"github.com/microsoft/typescript-go/internal/tspath"
2019
)
2120

22-
type updateKind uint
23-
24-
const (
25-
updateKindNone updateKind = iota
26-
updateKindConfig
27-
updateKindUpdate
28-
)
29-
3021
type buildKind uint
3122

3223
const (
@@ -70,11 +61,6 @@ type BuildTask struct {
7061
prevReporter *BuildTask
7162
reportDone chan struct{}
7263

73-
// Watching things
74-
configTime time.Time
75-
extendedConfigTimes []time.Time
76-
inputFiles []time.Time
77-
7864
buildInfoEntry *buildInfoEntry
7965
buildInfoEntryMu sync.Mutex
8066

@@ -710,14 +696,7 @@ func (t *BuildTask) cleanProjectOutput(orchestrator *Orchestrator, outputFile st
710696
}
711697

712698
func (t *BuildTask) updateWatch(orchestrator *Orchestrator, oldCache *collections.SyncMap[tspath.Path, time.Time]) {
713-
t.configTime = orchestrator.host.loadOrStoreMTime(t.config, oldCache, false)
714699
if t.resolved != nil {
715-
t.extendedConfigTimes = core.Map(t.resolved.ExtendedSourceFiles(), func(p string) time.Time {
716-
return orchestrator.host.loadOrStoreMTime(p, oldCache, false)
717-
})
718-
t.inputFiles = core.Map(t.resolved.FileNames(), func(p string) time.Time {
719-
return orchestrator.host.loadOrStoreMTime(p, oldCache, false)
720-
})
721700
if t.canUpdateJsDtsOutputTimestamps() {
722701
for outputFile := range t.resolved.GetOutputFileNames() {
723702
orchestrator.host.storeMTimeFromOldCache(outputFile, oldCache)
@@ -737,45 +716,6 @@ func (t *BuildTask) resetConfig(orchestrator *Orchestrator, path tspath.Path) {
737716
orchestrator.host.resolvedReferences.delete(path)
738717
}
739718

740-
func (t *BuildTask) hasUpdate(orchestrator *Orchestrator, path tspath.Path) updateKind {
741-
var needsConfigUpdate bool
742-
var needsUpdate bool
743-
if configTime := orchestrator.host.GetMTime(t.config); configTime != t.configTime {
744-
t.resetConfig(orchestrator, path)
745-
needsConfigUpdate = true
746-
}
747-
if t.resolved != nil {
748-
for index, file := range t.resolved.ExtendedSourceFiles() {
749-
if orchestrator.host.GetMTime(file) != t.extendedConfigTimes[index] {
750-
t.resetConfig(orchestrator, path)
751-
needsConfigUpdate = true
752-
}
753-
}
754-
for index, file := range t.resolved.FileNames() {
755-
if orchestrator.host.GetMTime(file) != t.inputFiles[index] {
756-
t.resetStatus()
757-
needsUpdate = true
758-
}
759-
}
760-
if !needsConfigUpdate {
761-
configStart := orchestrator.opts.Sys.Now()
762-
newConfig := t.resolved.ReloadFileNamesOfParsedCommandLine(orchestrator.host.FS())
763-
configTime := orchestrator.opts.Sys.Now().Sub(configStart)
764-
// Make new channels if needed later
765-
t.reportDone = make(chan struct{})
766-
t.done = make(chan struct{})
767-
if !slices.Equal(t.resolved.FileNames(), newConfig.FileNames()) {
768-
orchestrator.host.resolvedReferences.store(path, newConfig)
769-
orchestrator.host.configTimes.Store(path, configTime)
770-
t.resolved = newConfig
771-
t.resetStatus()
772-
needsUpdate = true
773-
}
774-
}
775-
}
776-
return core.IfElse(needsConfigUpdate, updateKindConfig, core.IfElse(needsUpdate, updateKindUpdate, updateKindNone))
777-
}
778-
779719
func (t *BuildTask) loadOrStoreBuildInfo(orchestrator *Orchestrator, configPath tspath.Path, buildInfoFileName string) (*incremental.BuildInfo, time.Time) {
780720
path := orchestrator.toPath(buildInfoFileName)
781721
t.buildInfoEntryMu.Lock()

0 commit comments

Comments
 (0)