Skip to content

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

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix/preserve-symlinks-watch
Open

fix(@angular/build): use chokidar watcher when followSymlinks is enabled#34060
clydin wants to merge 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer 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)

1 participant