feat(@angular/build): add opt-in manual rebuild mode to the dev-server#33330
feat(@angular/build): add opt-in manual rebuild mode to the dev-server#33330fhackenberger wants to merge 1 commit into
Conversation
Add a `manualRebuild` option to the `@angular/build:dev-server` builder that pauses automatic rebuilds while keeping the development server live and serving the last successful build. Previously every file change triggered an immediate rebuild and reload, which is costly when making a series of edits. While paused, file-change events are buffered in memory and coalesced per path so redundant events for the same file collapse to a single net change. Touching the trigger file (`rebuildTrigger`, defaulting to `.ng-rebuild`) flushes the queue to the build system as one incremental rebuild, after which the server performs a single HMR/live-reload cycle.
There was a problem hiding this comment.
Code Review
This pull request introduces a manual rebuild mode for the Angular build watch loop, allowing automatic rebuilds to be paused and buffered until a specific trigger file (defaulting to .ng-rebuild) is touched. The changes include adding manualRebuild and rebuildTrigger options, updating the esbuild build action to buffer and coalesce file changes, and adding comprehensive tests. The review feedback highlights an improvement opportunity: when checking if the trigger file has been touched, the code should check both batch.modified and batch.added to ensure the rebuild is reliably triggered even if the file is newly created or recreated.
| if (manualRebuildTrigger) { | ||
| // While paused, buffer and coalesce incoming changes; only the trigger file's | ||
| // modification flushes the queue and drives a single incremental rebuild. | ||
| const flush = batch.modified.has(manualRebuildTrigger); |
There was a problem hiding this comment.
If the trigger file is created for the first time (or recreated after being deleted), the file watcher might report it as an added event rather than a modified event. To ensure the manual rebuild is reliably triggered in all cases, we should check both batch.modified and batch.added for the trigger file.
| const flush = batch.modified.has(manualRebuildTrigger); | |
| const flush = batch.modified.has(manualRebuildTrigger) || batch.added.has(manualRebuildTrigger); |
Add a
manualRebuildoption to the@angular/build:dev-serverbuilder that pauses automatic rebuilds while keeping the development server live and serving the last successful build. Previously every file change triggered an immediate rebuild and reload, which is costly when making a series of edits.While paused, file-change events are buffered in memory and coalesced per path so redundant events for the same file collapse to a single net change. Touching the trigger file (
rebuildTrigger, defaulting to.ng-rebuild) flushes the queue to the build system as one incremental rebuild, after which the server performs a single HMR/live-reload cycle.PR Checklist
Please check to confirm your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
The current
ng servelistens to all changes to files. Coding with LLM agents often means files are touched at a faster pace than manual coding, so it makes sense to have ahotdev server that is triggered when the agent is done with one task and wants to check the build.Issue Number: N/A
What is the new behavior?
With the two new options, you can have
ng servequeue up modifications to the code base and trigger a build, by touching a configurable trigger file.Does this PR introduce a breaking change?