Repository navigation
refactor(graph): add ModuleGraph primitives for incremental rebuilds - #21552
Conversation
|
|
This PR is packaged and the instant preview is available (a88b860). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@a88b860
yarn add -D webpack@https://pkg.pr.new/webpack@a88b860
pnpm add -D webpack@https://pkg.pr.new/webpack@a88b860 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #21552 +/- ##
==========================================
+ Coverage 93.83% 93.91% +0.08%
==========================================
Files 620 620
Lines 73729 73803 +74
Branches 21339 21365 +26
==========================================
+ Hits 69180 69313 +133
+ Misses 4549 4490 -59
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Internal connection removal by stale dependency set, module removal with connection detachment, by-origin flush of unassigned connections, and a mutation journal that records and reverses seal-time connection moves. No behavior change; groundwork for incremental rebuilds.
0711398 to
0d5efa3
Compare
Merging this PR will degrade performance by 38.85%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Memory | benchmark "wasm-modules-async", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
195 KB | 816.9 KB | -76.13% |
| ❌ | Memory | benchmark "devtool-eval", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
1.3 MB | 3.1 MB | -57.97% |
| ❌ | Memory | benchmark "many-modules-commonjs", scenario '{"name":"mode-production","mode":"production"}' |
7.6 MB | 10.4 MB | -26.63% |
| ⚡ | Memory | benchmark "asset-modules-resource", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
1,202.6 KB | 633.1 KB | +89.97% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing refactor/module-graph-incremental-primitives (0d5efa3) with main (13c83e6)
Summary
Adds internal
ModuleGraphprimitives (stale-connection removal, module removal with connection detachment, by-origin flush of unassigned connections, and a mutation journal that records and reverses seal-time connection moves) as groundwork for reusing the module graph across watch rebuilds (incremental rebuilds). No behavior change; first PR of a series extracted fromperf/incremental-rebuild.What kind of change does this PR introduce?
refactor
Did you add tests for your changes?
Yes,
test/ModuleGraph.unittest.jscovers all five new methods.Does this PR introduce a breaking change?
No.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a
Use of AI
AI (Claude Code) was used to extract this change from my working branch, adapt it onto current
main, and draft the unit tests; I reviewed and validated everything locally.Note
Medium Risk
Touches core module-graph connection invariants and seal-time move/copy paths, but new APIs are private and unused until follow-up PRs; risk is mainly regression if journal recording diverges from actual mutations.
Overview
Adds private
ModuleGraphAPIs so a module graph can be cleaned up and rolled back between watch rebuilds, without changing current compilation behavior until later PRs wire them in.New helpers cover rebuild hygiene:
_removeStaleOutgoingConnectionsdrops outgoing edges for replaced dependencies (including inactive ones fromupdateModule),_flushUnassignedConnectionsregisters pending connections in the dependency map by origin (barrel re-export case), and_removeModuleremoves a module and detaches its edges.Mutation journal:
_startMutationJournal/_restoreFromMutationJournalrecord seal-time changes from existingmoveModuleConnectionsandcopyOutgoingModuleConnectionsand undo them in reverse order so concatenation-style mutations do not stick on a reused graph.Adds
test/ModuleGraph.unittest.jsfor these methods; only a trivial string-formatting tweak elsewhere inModuleGraph.js.Reviewed by Cursor Bugbot for commit 0d5efa3. Bugbot is set up for automated code reviews on this repo. Configure here.