Repository navigation
Description
Which @angular/* package(s) are relevant/related to the feature request?
compiler
Description
With the rapid adoption of AI coding agents (e.g., Cursor, Claude Code, Copilot, Antigravity), the frontend development workflow is shifting. Instead of developers manually editing single files and immediately inspecting changes via HMR/Live Reload, AI agents now perform rapid, multi-file edits in batches before the developer reviews the final result.
Currently, this creates a major bottleneck with ng serve:
- Default Watch Mode (
ng serve): As an AI agent rapidly generates and modifies dozens of files, the dev server continuously triggers incremental rebuilds. This spikes CPU/RAM usage, slows down the entire machine, and causes unnecessary build thrashing mid-generation. - Disabling Watch (
ng serve --watch=false) or Cold Restart: Runningng serve --watch=falseprevents automatic rebuilds, but provides no mechanism to trigger an incremental rebuild afterward. Developers are forced to restartng serve, discarding the in-memory build graph/cache and waiting 3–5 minutes for a full cold build on large enterprise projects.
Proposed solution
Introduce an on-demand rebuild mode for ng serve (e.g., --on-demand-build or --manual-rebuild) that keeps the dev server and its in-memory incremental build graph alive, pauses automatic file-system watchers, and allows external tools/AI agents to explicitly trigger an incremental rebuild once a batch of edits is completed.
Proposed Workflow:
- Start the dev server in on-demand mode:
ng serve --on-demand-build
- The server performs the initial build, caches the dependency graph in memory, and remains idle without reacting to file system events.
- Once an AI agent finishes its task (or via an agent post-task hook), it triggers an incremental rebuild using either:
- Local HTTP Endpoint:
curl -X POST http://localhost:4200/__ng_rebuild
- Angular CLI MCP Server (
ng mcp) Integration:
Expose a built-in MCP tool (e.g.,trigger_rebuildorrebuild_dev_server) in@angular/cli's MCP server so AI agents can natively signal the active dev server to compile modified files upon task completion.
- Local HTTP Endpoint:
- Angular CLI executes a fast incremental rebuild (reusing the existing
ngtscand esbuild/Vite in-memory cache) for only the changed files and pushes the update to the browser.
Alternatives considered
- Using
ng serve --watch=false: Only disables watching after the initial build; lacks any API or signal to trigger subsequent incremental builds without restarting the process. - Increasing
pollinterval / debounce time: Still relies on arbitrary timers rather than deterministic completion signals from AI agents, resulting in premature builds mid-generation or unnecessary waiting afterward. - Restarting
ng serveafter AI edits: Discards the in-memory build cache, incurring a 3–5 minute cold build penalty every time.
Additional context
Under the hood, esbuild already supports manual incremental rebuilds via context.rebuild(), and Vite supports disabling server.watch. Decoupling file change detection from incremental compilation triggers in @angular/build—especially when paired with the official Angular CLI MCP server (ng mcp)—would fit cleanly into the current architecture and significantly improve hardware efficiency and developer experience (DX) for AI-assisted workflows on large Angular codebases.
Activity
alan-agius4 commentedon Nov 18, 2026
Closing as not planned. Please see #34742 (and previously #33330) for context and recommended alternatives, such as throttling watch frequency via the
polloption, usingdevserver_wait_for_build, or runningng buildafter batch edits.