Skip to content

Watcher build mode efficiency updates#3670

Open
johnfav03 wants to merge 16 commits intomicrosoft:mainfrom
johnfav03:watch-build-efficiency
Open

Watcher build mode efficiency updates#3670
johnfav03 wants to merge 16 commits intomicrosoft:mainfrom
johnfav03:watch-build-efficiency

Conversation

@johnfav03
Copy link
Copy Markdown
Contributor

Refactors the tsc --build --watch functionality to use the new shared FileWatcher and trackingvfs structure from the CLI and LSP watchers, reducing code duplication and patching inefficiencies like redundant scanning of shared dependencies.

Note: this PR is built on the watcher-lsp-integration branch so only review commits from 0655dba onward

Fixes #2666

Copilot AI review requested due to automatic review settings April 30, 2026 17:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Refactors watch/build-mode change detection to use a shared polling FileWatcher + trackingvfs approach (aligned with CLI/LSP), reducing redundant scanning and improving dependency change tracking (incl. package.json-driven resolution).

Changes:

  • Reworked internal/vfs/vfswatch to watch directory sets (recursive + shallow), emit structured WatchEvents, and support context-aware settling.
  • Updated build/watch orchestration to compute watched directories from SeenFiles + wildcard dirs and to use ScanForChanges() instead of per-file watch state.
  • Added polling-watcher integration for LSP sessions plus new tests; updated baselines to reflect revised incremental out-of-date reasoning/log output.

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
testdata/baselines/reference/tsbuildWatch/sample/reportErrors-when-stopBuildOnErrors-is-passed-on-command-line.js Updated expected watch output/error counts under new watcher behavior
testdata/baselines/reference/tsbuildWatch/sample/reportErrors-when-preserveWatchOutput-is-passed-on-command-line.js Baseline update for watched buildinfo timestamp behavior
testdata/baselines/reference/tsbuildWatch/sample/reportErrors-when-preserveWatchOutput-is-not-used.js Baseline update for watched buildinfo timestamp behavior
testdata/baselines/reference/tsbuildWatch/sample/incremental-updates-in-verbose-mode.js Baseline update for “out of date because …” reasoning
testdata/baselines/reference/tsbuildWatch/reexport/Reports-errors-correctly.js Baseline update for verbose out-of-date messaging
testdata/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js Baseline updates adding incremental “file change detected” sections and revised reasons
testdata/baselines/reference/tsbuildWatch/moduleResolution/build-mode-watches-for-changes-to-package-json-main-fields.js Baseline updates to reflect package.json watch behavior
testdata/baselines/reference/tsbuildWatch/demo/updates-with-bad-reference.js Baseline update for error out-of-date messaging + buildinfo timestamps
testdata/baselines/reference/tsbuild/sample/sample.js Baseline update for referenced-project input selection message
testdata/baselines/reference/tsbuild/sample/explainFiles.js Baseline update for referenced-project input selection message
testdata/baselines/reference/tsbuild/commandLine/emitDeclarationOnly-on-commandline.js Baseline update for referenced-project input selection message
internal/vfs/vfswatch/vfswatch_race_test.go Updated race/fuzz tests for directory-based watcher + ScanForChanges()
internal/vfs/vfswatch/vfswatch_event_test.go New tests validating WatchEvent create/change/delete behavior
internal/vfs/vfswatch/vfswatch.go Major refactor: directory watchers, WatchEvent, logging, ctx-aware run/settle
internal/tspath/pathcomponents_watching_test.go New tests for exported watch-specific path component logic
internal/tspath/path.go Exported GetPathComponentsForWatching for common-parent watch coarsening
internal/project/watch_test.go Moved watch-path-component tests out of project package
internal/project/watch.go Added WatchedDirectories() extraction for polling watcher directory computation
internal/project/session.go Added optional in-process polling watcher + directory updates per snapshot
internal/project/polling_watcher_test.go New integration test for LSP polling watcher triggering diagnostics refresh
internal/project/configfileregistrybuilder.go Switched GetCommonParents callback to tspath.GetPathComponentsForWatching
internal/lsp/server.go Default polling enablement when client watching is unavailable + user opt-in
internal/ls/lsutil/userpreferences.go Added usePollingWatcher user preference plumbing
internal/execute/watcher.go Watch-mode now computes watched dirs + filters builds via WatchEvent relevance
internal/execute/tsctests/tscbuild_test.go Updated expected diffs for new behavior (removed stopBuildOnErrors diff text)
internal/execute/build/orchestrator.go Build-mode watcher now uses shared FileWatcher + directory computation
internal/execute/build/compilerHost.go Added trackingvfs support to collect SeenFiles during compile
internal/execute/build/buildtask.go Uses trackingvfs + watch-state update + package.json dependency checks
_extension/package.json Added experimental setting typescript.native-preview.usePollingWatcher

Comment thread internal/vfs/vfswatch/vfswatch.go
Comment thread internal/vfs/vfswatch/vfswatch.go Outdated
Comment thread internal/execute/build/orchestrator.go Outdated
Comment thread internal/project/watch.go Outdated
Comment thread internal/vfs/vfswatch/vfswatch_event_test.go Outdated
Comment thread internal/vfs/vfswatch/vfswatch.go
Comment thread internal/tspath/path.go
Comment thread internal/execute/build/orchestrator.go Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tsgo --build fails to invalidate incremental cache after dependency update

2 participants