Skip to content

perf(@angular/build): replace watchpack with @parcel/watcher and chokidar - #33656

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:feat/replace-watchpack
Open

perf(@angular/build): replace watchpack with @parcel/watcher and chokidar#33656
clydin wants to merge 1 commit into
angular:mainfrom
clydin:feat/replace-watchpack

Conversation

@clydin

@clydin clydin commented Jul 24, 2026

Copy link
Copy Markdown
Member

This change replaces the watchpack file watching dependency in @angular/build with @parcel/watcher as the primary native file watcher, while falling back to chokidar for polling or unsupported environments.

By leveraging @parcel/watcher's native C++ bindings (FSEvents, ReadDirectoryChangesW, inotify), file system watching is offloaded directly to OS kernel APIs, significantly reducing CPU and memory footprint during watch mode. Additionally, external directory watches are dynamically subsumed to minimize active native file handles, while early path filtering and event coalescing prevent redundant incremental rebuild triggers.

@clydin clydin added the target: minor This PR is targeted for the next minor release label Jul 24, 2026
@angular-robot angular-robot Bot added area: performance Issues related to performance area: @angular/build labels Jul 24, 2026
@clydin
clydin force-pushed the feat/replace-watchpack branch 5 times, most recently from a757036 to 9ed830d Compare July 28, 2026 10:56
@clydin
clydin force-pushed the feat/replace-watchpack branch 10 times, most recently from afa5b29 to 160848a Compare August 4, 2026 00:08
@clydin
clydin marked this pull request as ready for review August 4, 2026 01:29

@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 replaces watchpack with a custom file watcher implementation that utilizes @parcel/watcher with a chokidar fallback, updating the build action and adding unit tests. The review feedback identifies several critical issues in the new watcher implementation: path traversal bugs on Windows drive roots when using path.posix.dirname, incorrect case-sensitivity detection for non-existent directories, potential unhandled promise rejections from floating unsubscribe promises, and early termination of the cleanup loop if an unsubscription fails.

Comment thread packages/angular/build/src/tools/esbuild/watcher.ts
Comment thread packages/angular/build/src/tools/esbuild/watcher.ts
Comment thread packages/angular/build/src/tools/esbuild/watcher.ts
Comment thread packages/angular/build/src/tools/esbuild/watcher.ts
Comment thread packages/angular/build/src/tools/esbuild/watcher.ts
@clydin
clydin force-pushed the feat/replace-watchpack branch 2 times, most recently from a1fed21 to 37f97d1 Compare August 4, 2026 21:55
@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Aug 7, 2026
@angular angular deleted a comment from ngbot Bot Aug 7, 2026
@alan-agius4 alan-agius4 added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: merge The PR is ready for merge by the caretaker labels Aug 7, 2026
@clydin
clydin force-pushed the feat/replace-watchpack branch from 37f97d1 to 48364f8 Compare August 7, 2026 14:52
…idar

This change replaces the watchpack file watching dependency in @angular/build with @parcel/watcher as the primary native file watcher, while falling back to chokidar for polling or unsupported environments.

By leveraging @parcel/watcher's native C++ bindings (FSEvents, ReadDirectoryChangesW, inotify), file system watching is offloaded directly to OS kernel APIs, significantly reducing CPU and memory footprint during watch mode. Additionally, external directory watches are dynamically subsumed to minimize active native file handles, while early path filtering and event coalescing prevent redundant incremental rebuild triggers.
@clydin
clydin force-pushed the feat/replace-watchpack branch from 48364f8 to 7ab7e51 Compare August 7, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews area: @angular/build area: performance Issues related to performance target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants