Skip to content

feat: run webpack-dev-server as a compiler plugin - #4847

Open
bjohansebas wants to merge 5 commits into
mainfrom
feat/dev-server-plugin-support
Open

bjohansebas wants to merge 5 commits into
mainfrom
feat/dev-server-plugin-support

Conversation

@bjohansebas

@bjohansebas bjohansebas commented Sep 5, 2026 •

Copy link
Copy Markdown
Member

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 existing start()/stop() flow.

The plugin path disables the server's own signal handlers to avoid duplicate shutdown and preserves failure exit codes. Duplicate ports in devServer configurations 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:

  • Build, ESLint, Prettier and CSpell passed.
  • 5 suites passed: 64 tests passed, 1 skipped, and 32 snapshots passed.
npm run test:base -- test/serve/error-handling test/serve/rebuild test/serve/basic test/watch/stdin test/watch/basic --runInBand --roots test/serve test/watch

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: true is 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

  • New Features
    • Added support for running webpack-dev-server 6 as a compiler plugin, including watch builds, build output, graceful shutdown, and automatic port selection for multiple configurations.
  • Bug Fixes
    • Improved handling of build errors, warnings, and startup failures so they report appropriate exit statuses.
    • Corrected build-stat output for development middleware settings.

@changeset-bot

changeset-bot Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 006b502

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
webpack-cli Minor

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

@github-actions

github-actions Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

This PR is packaged and the instant preview is available (006b502).

Install it locally:

  • npm
npm i -D create-webpack-app@https://pkg.pr.new/create-webpack-app@006b502 webpack-cli@https://pkg.pr.new/webpack-cli@006b502
  • yarn
yarn add -D create-webpack-app@https://pkg.pr.new/create-webpack-app@006b502 webpack-cli@https://pkg.pr.new/webpack-cli@006b502
  • pnpm
pnpm add -D create-webpack-app@https://pkg.pr.new/create-webpack-app@006b502 webpack-cli@https://pkg.pr.new/webpack-cli@006b502

@codecov

codecov Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.76536% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.96%. Comparing base (66ef3ef) to head (006b502).

Files with missing lines Patch % Lines
packages/webpack-cli/src/webpack-cli.ts 97.76% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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              
Files with missing lines Coverage Δ
packages/webpack-cli/src/webpack-cli.ts 96.82% <97.76%> (+0.06%) ⬆️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 66ef3ef...006b502. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@evenstensberg

Copy link
Copy Markdown
Member

Big pr, gonna review in depth this weekend

@bpthevenot-hub

Copy link
Copy Markdown

@copilot fix everything

@bjohansebas
bjohansebas force-pushed the feat/dev-server-plugin-support branch from 9d25338 to 006b502 Compare October 17, 2026 16:48
@coderabbitai

coderabbitai Bot commented Oct 17, 2026

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5bc92657-c8e5-43ce-b959-1941315788ee
📥 Commits

Reviewing files that changed from the base of the PR and between 66ef3ef and 006b502.

⛔ Files ignored due to path filters: 1
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing: 23
  • .changeset/dev-server-6-plugin.md
  • .prettierignore
  • eslint.config.mjs
  • packages/webpack-cli/package.json
  • packages/webpack-cli/src/webpack-cli.ts
  • test/serve/automatic-ports/automatic-ports.test.js
  • test/serve/automatic-ports/webpack.config.js
  • test/serve/basic/__snapshots__/serve-basic.test.js.snap.devServer6.webpack5
  • test/serve/error-handling/bad-middleware.config.js
  • test/serve/error-handling/error.config.js
  • test/serve/error-handling/serve-error-handling.test.js
  • test/serve/error-handling/setup-failure.config.js
  • test/serve/error-handling/shutdown.config.js
  • test/serve/error-handling/src/index.js
  • test/serve/error-handling/src/syntax-error.js
  • test/serve/error-handling/warning.config.js
  • test/serve/middleware-stats/middleware-stats.test.js
  • test/serve/middleware-stats/webpack.config.js
  • test/serve/rebuild/multi.config.js
  • test/serve/rebuild/serve-rebuild.test.js
  • test/serve/rebuild/src/index.js
  • test/serve/rebuild/src/worker.js
  • test/serve/rebuild/webpack.config.js

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

The 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 006b5

This change adds webpack-dev-server 6 compiler-plugin support and keeps the older start/stop flow for earlier versions. No concrete merge-blocking risk was identified in the supplied material.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: running webpack-dev-server as a compiler plugin.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 19 files. (4 skipped: 4 unsupported.)

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

🔧 Biome (2.5.14)
test/serve/error-handling/src/syntax-error.js

File contains syntax errors that prevent linting: Line 1: Expected a property, a shorthand property, a getter, a setter, or a method but instead found ';'.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants