Skip to content

feat(@angular/compiler): add on-demand incremental rebuild mode (HTTP API & MCP tool) for ng serve #34743

Closed as not planned

Description

@DingWeizhe

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:

  1. 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.
  2. Disabling Watch (ng serve --watch=false) or Cold Restart: Running ng serve --watch=false prevents automatic rebuilds, but provides no mechanism to trigger an incremental rebuild afterward. Developers are forced to restart ng 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:

  1. Start the dev server in on-demand mode:
    ng serve --on-demand-build
  2. The server performs the initial build, caches the dependency graph in memory, and remains idle without reacting to file system events.
  3. 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_rebuild or rebuild_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.
  4. Angular CLI executes a fast incremental rebuild (reusing the existing ngtsc and 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 poll interval / 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 serve after 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

  1. added this to the needsTriage milestone on Nov 18, 2026
  2. modified the milestone: needsTriage on Nov 18, 2026
  3. added this to the needsTriage milestone on Nov 18, 2026
  4. alan-agius4 commented on Nov 18, 2026

    @alan-agius4
    Collaborator

    Closing as not planned. Please see #34742 (and previously #33330) for context and recommended alternatives, such as throttling watch frequency via the poll option, using devserver_wait_for_build, or running ng build after batch edits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions