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

@clydinclydin 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.

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

@gemini-code-assistgemini-code-assistBot 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 threadpackages/angular/build/src/tools/esbuild/watcher.ts
Comment threadpackages/angular/build/src/tools/esbuild/watcher.ts
Comment threadpackages/angular/build/src/tools/esbuild/watcher.ts
Comment threadpackages/angular/build/src/tools/esbuild/watcher.ts
Comment threadpackages/angular/build/src/tools/esbuild/watcher.ts
@clydin
clydinforce-pushed the feat/replace-watchpack branch from 160848a to a1fed21CompareAugust 4, 2026 21:32
…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
clydinforce-pushed the feat/replace-watchpack branch from a1fed21 to 37f97d1CompareAugust 4, 2026 21:55
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: @angular/buildarea: performanceIssues related to performancetarget: minorThis PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@clydin