Skip to content

[bug] watch mode triggers continuously #778

@tmm1

Description

@tmm1
❯ time tsgo tsc -noEmit -w -p src
build triggered due to config change
build starting at 2025-04-08 16:46:43.150158 -0700 PDT m=+0.937383709
build finished in 5.714491375s
build triggered due to config change
build starting at 2025-04-08 16:46:50.457319 -0700 PDT m=+8.244531876
build finished in 5.544717875s
build triggered due to config change
build starting at 2025-04-08 16:46:57.955792 -0700 PDT m=+15.742991834
build finished in 5.286759958s
build triggered due to config change
diff --git i/internal/execute/watcher.go w/internal/execute/watcher.go
index af20829e6..087daf754 100644
--- i/internal/execute/watcher.go
+++ w/internal/execute/watcher.go
@@ -1,6 +1,7 @@
 package execute
 
 import (
+	"fmt"
 	"time"
 
 	"github.com/microsoft/typescript-go/internal/compiler"
@@ -50,6 +51,7 @@ func (w *watcher) hasErrorsInTsConfig() bool {
 			return true
 		}
 		if w.options.CompilerOptions() != configParseResult.CompilerOptions() {
+			fmt.Fprint(w.sys.Writer(), "build triggered due to config change", w.sys.NewLine())
 			w.configModified = true
 		}
 		w.options = configParseResult
@@ -73,12 +75,14 @@ func (w *watcher) hasBeenModified(program *compiler.Program) bool {
 		currState[fileName] = s.ModTime()
 		if !filesModified {
 			if currState[fileName] != w.prevModified[fileName] {
+				fmt.Fprint(w.sys.Writer(), "build triggered from ", fileName, ": ", w.prevModified[fileName], " -> ", currState[fileName], w.sys.NewLine())
 				filesModified = true
 			}
-			delete(w.prevModified, fileName)
 		}
+		delete(w.prevModified, fileName)
 	}
 	if len(w.prevModified) > 0 {
+		fmt.Fprint(w.sys.Writer(), "build triggered due to ", len(w.prevModified), " files deleted", w.sys.NewLine())
 		filesModified = true
 	}
 	w.prevModified = currState

cc @iisaduan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions