Repository navigation
Prevent emitted files from retriggering native watch builds - #65475
Open
Jake Bailey (jakebailey) wants to merge 1 commit into
Open
Jake Bailey (jakebailey) wants to merge 1 commit into
Jake Bailey (jakebailey) wants to merge 1 commit into
Conversation
Recursive wildcard roots describe directories, not arbitrary event paths. Treating every descendant as a directory lets emitted outputs and unrelated files retrigger compilation indefinitely. Filter individual events by dependency membership, supported extensions, and expected output paths. Retain structural events using filesystem checks and cached dependency ancestors, so moved-in and removed source directories still refresh the program without scanning dependencies per delete event. Cover ignored creates/deletes and genuine source/directory changes with command-line watch integration tests.
Jake Bailey (jakebailey)
requested review from
John Favret (johnfav03)
and
a balanced review from Copilot
November 13, 2026 04:53
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Watch mode can miss valid new inputs due to inconsistent extension casing and suppression of files never emitted, while regression tests do not cover same-directory output loops.
3 open issues
What changed in this PR
Updates the native compiler’s single-project watch mode to prevent emitted files from triggering repeated builds, addressing #64037.
Changes:
- Filters file events using tracked dependencies, supported extensions, and predicted output paths.
- Tracks dependency directories so directory deletions invalidate the build.
- Adds tests for output filtering, new source discovery, and directory events.
| File | Description |
|---|---|
tsc/internal/execute/watcher.go |
Adds output-aware event filtering and dependency-directory tracking. |
tsc/internal/execute/tsctests/watch_shallow_test.go |
Tests ignored file events and relevant source and directory changes. |
Review effort: Balanced
| "gotest.tools/v3/assert" | ||
| ) | ||
|
|
||
| func TestWatchWildcardFiltersFiles(t *testing.T) { |
| if w.config.ConfigFile != nil && w.config.PossiblyMatchesFileName(tspath.RootedFilePathFromPath(eventPath)) { | ||
| return true | ||
| if !w.emittedFiles.Has(p) && | ||
| slices.ContainsFunc(supportedExtensions, p.ExtensionIsOneOf) && |
| if w.sys.FS().DirectoryExists(tspath.RootedDirectoryPathFromPath(eventPath)) { | ||
| if w.wm.IsPathUnderWatch(eventPath) { | ||
| return true | ||
| paths := outputpaths.GetOutputPathsFor(file, program.Options(), program, outputpaths.ForceEmitPaths{}) |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Caught this in an audit.
Fixes #64037 (which I did not realize before making this fix)