Repository navigation
feat: run webpack-dev-server as a compiler plugin - #4847
bjohansebas wants to merge 5 commits into
Conversation
🦋 Changeset detectedLatest commit: 006b502 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 (006b502). Install it locally:
npm i -D create-webpack-app@https://pkg.pr.new/create-webpack-app@006b502 webpack-cli@https://pkg.pr.new/webpack-cli@006b502
yarn add -D create-webpack-app@https://pkg.pr.new/create-webpack-app@006b502 webpack-cli@https://pkg.pr.new/webpack-cli@006b502
pnpm add -D create-webpack-app@https://pkg.pr.new/create-webpack-app@006b502 webpack-cli@https://pkg.pr.new/webpack-cli@006b502 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4847 +/- ##
==========================================
+ Coverage 94.87% 94.96% +0.08%
==========================================
Files 14 14
Lines 5637 5776 +139
Branches 846 887 +41
==========================================
+ Hits 5348 5485 +137
- Misses 288 290 +2
Partials 1 1
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
|
Big pr, gonna review in depth this weekend |
|
@copilot fix everything |
9d25338 to
006b502
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe CLI now supports webpack-dev-server 6 as a compiler plugin while retaining the existing startup path for older servers. The plugin path handles port selection, watch compilation, stats output, and graceful compiler shutdown. New tests cover automatic ports, watch errors and shutdown, middleware stats, and rebuilds. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
Summary
Run webpack-dev-server as a compiler plugin when it exposes
apply(). The CLI starts watch compilation, prints build stats, and closes the compiler on signals or stdin EOF so the server stops through its shutdown hooks. Older dev servers keep their existingstart()/stop()flow.The plugin path disables the server's own signal handlers to avoid duplicate shutdown and preserves failure exit codes. Duplicate ports in
devServerconfigurations are detected before listening starts.Known limitation: webpack-dev-server currently logs errors from the plugin's asynchronous
listen()phase without propagating them to the CLI. That requires a follow-up in webpack-dev-server; setup errors reaching the watch callback exit with code 2.What kind of change does this PR introduce?
Feature, with shutdown fixes and regression tests.
Did you add tests for your changes?
Yes. Tests cover compilation errors and warnings, middleware setup failures, exit status and shutdown through SIGINT/SIGTERM/stdin, duplicate signal handlers, serving rebuilt bundles, and independent multi-compiler rebuilds with distinct watch options and shutdown hooks. The duplicate-port snapshot is updated for validation before startup.
Validation with webpack-dev-server 6:
Does this PR introduce a breaking change?
No intended breaking change. Existing webpack-dev-server 5 integration remains on the imperative path. In plugin mode, the CLI owns signal handling even when
setupExitSignals: trueis configured, and shutdown preserves compilation failure status.If relevant, what needs to be documented once your changes are merged or what have you already documented?
Added a minor changeset describing compiler plugin support. The serve documentation should explain CLI ownership of watch compilation, stats output, and shutdown with webpack-dev-server 6.
Use of AI
Codex assisted with implementation, regression tests, code review, and this PR description. The changes were developed interactively with contributor feedback, and the validation results above were checked during that process.
Summary by CodeRabbit