feat: add aggregated shutdown hook to MultiCompiler - #21578
Conversation
🦋 Changeset detectedLatest commit: 3936041 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
This PR is packaged and the instant preview is available (8a1e4ab). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@8a1e4ab
yarn add -D webpack@https://pkg.pr.new/webpack@8a1e4ab
pnpm add -D webpack@https://pkg.pr.new/webpack@8a1e4ab |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21578 +/- ##
=======================================
Coverage 94.00% 94.00%
=======================================
Files 623 623
Lines 75771 75772 +1
Branches 22077 22077
=======================================
+ Hits 71229 71232 +3
+ Misses 4542 4540 -2
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:
|
Merging this PR will improve performance by 71.55%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Memory | benchmark "devtool-eval", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' |
875.5 KB | 510.4 KB | +71.55% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing feat/multi-compiler-shutdown-hook (3936041) with main (b53f3fb)
Summary
MultiCompilerhas no aggregatedshutdownhook, so consumers like webpack-dev-server's plugin mode must iteratecompiler.compilersand tap each child'sshutdownto run async teardown oncompiler.close(). This addshooks.shutdownas aMultiHookover the children'sshutdownhooks, matching the existingwatchRun/run/invalidaggregates.What kind of change does this PR introduce?
feat
Did you add tests for your changes?
Yes, in
test/MultiCompiler.test.js(the aggregated hook fires once per child compiler onclose()).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?
Document
multiCompiler.hooks.shutdownin the MultiCompiler/Node API docs.Use of AI
This PR was implemented with AI assistance (Claude Code), directed and reviewed by me.
Note
Low Risk
Additive public hook and types only; no change to existing close/shutdown behavior on child compilers.
Overview
Adds
multiCompiler.hooks.shutdownas aMultiHookover each child compiler’sshutdownhook, in line with existing aggregates likerunandwatchRun. Plugins and tools (e.g. webpack-dev-server in plugin mode) can register async teardown once on the multi compiler instead of loopingcompiler.compilers.Type definitions are updated for the new hook, and a test asserts the aggregated hook runs once per child when
close()is called afterwatch(). A minor changeset documents the API addition.Reviewed by Cursor Bugbot for commit 3936041. Bugbot is set up for automated code reviews on this repo. Configure here.