Skip to content

fix(@angular/build): use chokidar watcher when followSymlinks is enabled - #34060

Merged
clydin merged 1 commit into
angular:mainfrom
clydin:fix/preserve-symlinks-watch
Sep 10, 2026
Merged

fix(@angular/build): use chokidar watcher when followSymlinks is enabled#34060
clydin merged 1 commit into
angular:mainfrom
clydin:fix/preserve-symlinks-watch

Conversation

@clydin

@clydin clydin commented Sep 9, 2026

Copy link
Copy Markdown
Member

When preserveSymlinks is enabled in application build options, followSymlinks: true is passed to createWatcher.

With @parcel/watcher, native OS directory watchers (such as FSEvents, inotify, and ReadDirectoryChangesW) do not follow directory symlinks pointing outside the workspace root. Additionally, esbuild reports watch files under their symlinked workspace paths, preventing external directory watches from attaching and causing file modifications behind the symlink to be missed.

Since chokidar natively traverses directory symlinks and surfaces file change events relative to the watched root, createWatcher now falls back to Chokidar when followSymlinks is enabled. This restores watch rebuild detection for symlinked directories while preserving the performance benefits of @parcel/watcher for standard setups.

Closes #34039

@clydin clydin added the target: minor This PR is targeted for the next minor release label Sep 9, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the createWatcher function to use the Chokidar watcher when followSymlinks is enabled, and adds a corresponding unit test to verify symlink change detection. The review feedback suggests ensuring the watcher is closed in the finally block of the test to prevent resource leaks in case of assertion failures.

Comment thread packages/angular/build/src/tools/esbuild/watcher_spec.ts
When `preserveSymlinks` is enabled in application build options, `followSymlinks: true` is passed to `createWatcher`.

With `@parcel/watcher`, native OS directory watchers (such as FSEvents, inotify, and ReadDirectoryChangesW) do not follow directory symlinks pointing outside the workspace root. Additionally, esbuild reports watch files under their symlinked workspace paths, preventing external directory watches from attaching and causing file modifications behind the symlink to be missed.

Since `chokidar` natively traverses directory symlinks and surfaces file change events relative to the watched root, `createWatcher` now falls back to Chokidar when `followSymlinks` is enabled. This restores watch rebuild detection for symlinked directories while preserving the performance benefits of `@parcel/watcher` for standard setups.

Closes angular#34039
@clydin
clydin force-pushed the fix/preserve-symlinks-watch branch from 4e92a64 to 7ca0a1a Compare September 9, 2026 19:18
@clydin
clydin requested a review from alan-agius4 September 9, 2026 20:04
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Sep 9, 2026
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release target: minor This PR is targeted for the next minor release and removed action: review The PR is still awaiting reviews from at least one requested reviewer target: minor This PR is targeted for the next minor release target: patch This PR is targeted for the next patch release labels Sep 10, 2026
@clydin
clydin merged commit b423bc3 into angular:main Sep 10, 2026
70 of 71 checks passed
@clydin

clydin commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

This PR was merged into the repository. The changes were merged into the following branches:

@clydin
clydin deleted the fix/preserve-symlinks-watch branch September 10, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@angular/build watch does not pick up changes behind a directory symlink when preserveSymlinks is true (22.2.0-next)

2 participants