GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: plugin support by bjohansebas · Pull Request #5650 · webpack/webpack-dev-server

Conversation

@bjohansebas

@bjohansebas bjohansebas commented Feb 21, 2026

Copy link
Copy Markdown
Member

Summary

What kind of change does this PR introduce?

Did you add tests for your changes?

Does this PR introduce a breaking change?

If relevant, what needs to be documented once your changes are merged or what have you already documented?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@codecov

codecov Bot commented Feb 21, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.79412% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.23%. Comparing base (168f08a) to head (cda0912).
⚠️ Report is 1 commits behind head on next.

Files with missing lines Patch % Lines
lib/Server.js 97.79% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next    #5650      +/-   ##
==========================================
+ Coverage   88.95%   89.23%   +0.28%     
==========================================
  Files          13       13              
  Lines        5964     6082     +118     
==========================================
+ Hits         5305     5427     +122     
+ Misses        659      655       -4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait

alexander-akait commented Feb 21, 2026

Copy link
Copy Markdown
Member

We should start it in webpack-dev-middleware, currently webpack-dev-middleware uses console.log to output stats, it means we will spam logs, we need an options or another function wrapper - require("webpack-dev-middleware").plugin(options)

bjohansebas reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bjohansebas
bjohansebas force-pushed the plugin-support branch from 0d79407 to 8664549 Compare March 30, 2026 19:43
alexander-akait
alexander-akait reviewed Mar 31, 2026
View reviewed changes
Comment thread lib/Server.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

alexander-akait
alexander-akait reviewed Mar 31, 2026
View reviewed changes
Comment thread lib/Server.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bjohansebas
bjohansebas force-pushed the plugin-support branch from d8084a7 to 9890a76 Compare April 1, 2026 23:07
alexander-akait
alexander-akait reviewed Apr 2, 2026
View reviewed changes
Comment thread test/e2e/api.test.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bjohansebas
bjohansebas force-pushed the plugin-support branch from 9890a76 to 616b803 Compare April 26, 2026 18:50
@bjohansebas
bjohansebas marked this pull request as ready for review May 1, 2026 20:49
@bjohansebas
bjohansebas requested a review from alexander-akait May 1, 2026 21:07
bjohansebas
bjohansebas commented May 1, 2026
View reviewed changes

@bjohansebas bjohansebas left a comment

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes should work without requiring any changes to webpack-cli yet. Once this is merged, we can work on a patch for webpack-cli to use the plugin support, but it is independent of changes to webpack-cli.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

alexander-akait reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@bjohansebas

bjohansebas commented May 7, 2026

Copy link
Copy Markdown
Member Author

cc: @alexander-akait friendly ping for feedback

alexander-akait reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait

alexander-akait commented May 8, 2026

Copy link
Copy Markdown
Member

Will look soon, I little bit busy, we should make the new major release the next week, I will help you to finish remains tasks

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait

alexander-akait commented May 11, 2026

Copy link
Copy Markdown
Member

@bjohansebas let's rebase

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bjohansebas
bjohansebas force-pushed the plugin-support branch 2 times, most recently from 1060a9c to 4591762 Compare May 16, 2026 17:54
@alexander-akait

alexander-akait commented May 18, 2026

Copy link
Copy Markdown
Member

@bjohansebas can take a look at our failed tests, a lot of PRs without green, we need to resolve it, thanks

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bjohansebas
bjohansebas force-pushed the plugin-support branch from bb3626c to 9912722 Compare May 22, 2026 05:07
@bjohansebas

bjohansebas commented May 22, 2026

Copy link
Copy Markdown
Member Author

@bjohansebas can take a look at our failed tests, a lot of PRs without green, we need to resolve it, thanks

Those are just flaky tests, like before. You just need to rerun them and that's it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait

alexander-akait commented May 22, 2026

Copy link
Copy Markdown
Member

Looks like problem with lint here

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bjohansebas
bjohansebas force-pushed the next branch from cd007a3 to 6550a05 Compare May 23, 2026 16:22
@bjohansebas
bjohansebas force-pushed the plugin-support branch 2 times, most recently from 0102816 to 2d6d746 Compare May 23, 2026 18:52
alexander-akait
alexander-akait reviewed Jun 4, 2026
View reviewed changes
Comment thread lib/Server.js Outdated
// the user is not in control of the plugin lifecycle here, so we stay
// silent rather than logging a warning.
const isBuildMode = () =>
childCompilers.every((child) => !child.watching && !child.options.watch);

@alexander-akait alexander-akait Jun 4, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each compiler have watching when it is watching, no need to check on watch, at least I can see situation when watch will be true, but watching undefined

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
alexander-akait
alexander-akait reviewed Jun 4, 2026
View reviewed changes
Comment thread lib/Server.js Outdated
if (seenFirstDone.has(childCompiler)) return;
seenFirstDone.add(childCompiler);
firstDoneCount++;
if (firstDoneCount < childCompilers.length) return;

@alexander-akait alexander-akait Jun 4, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify when we need firstDoneCount?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
alexander-akait
alexander-akait reviewed Jun 4, 2026
View reviewed changes
Comment thread lib/Server.js Outdated
childCompiler.hooks.done.tapPromise(pluginName, () =>
onChildDone(childCompiler),
);
childCompiler.hooks.shutdown.tapPromise(pluginName, onChildShutdown);

@alexander-akait alexander-akait Jun 4, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we should have the same hooks for multi compiler, and so don't use for/of, but we can postpone it and improve later

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
alexander-akait
alexander-akait reviewed Jun 4, 2026
View reviewed changes
Comment thread lib/Server.js Outdated
};

for (const childCompiler of childCompilers) {
childCompiler.hooks.beforeCompile.tapPromise(pluginName, ensureSetup);

@alexander-akait alexander-akait Jun 4, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we avoid beforeCompile at all, it is unsafe in some cases, ideally we should use only done and shutdown

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@alexander-akait alexander-akait Jun 4, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can done everything on done, also please add a test case what we really change outputFileSystem and use it, not webpack built-in the real fs

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bjohansebas reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@bjohansebas bjohansebas Jun 15, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing it only through done is complicated because there are processes that need to be initialized much earlier. That's why beforeCompile is used.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bjohansebas

bjohansebas commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

okay tomorrow i will continue with this

alexander-akait reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bjohansebas
bjohansebas force-pushed the next branch 2 times, most recently from c2dd24b to 4810909 Compare June 12, 2026 22:46
@bjohansebas
bjohansebas force-pushed the plugin-support branch from b2914df to 5be7251 Compare June 15, 2026 14:42
@changeset-bot

changeset-bot Bot commented Jun 15, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cda0912

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

This PR includes changesets to release 1 package
Name Type
webpack-dev-server 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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bjohansebas
bjohansebas force-pushed the plugin-support branch from 5be7251 to 07b85dc Compare June 15, 2026 14:51
@bjohansebas

bjohansebas commented Jun 15, 2026

Copy link
Copy Markdown
Member Author

watchRun vs beforeCompile

setup() must run before the first compilation writes assets, because webpack-dev-middleware replaces outputFileSystem with an in-memory filesystem. Running only on done is too late—the first build has already written to disk.

Both watchRun and beforeCompile run before emit, but watchRun is a better fit because it is watch-only (no build-mode guard required) and, on a MultiCompiler, a single top-level tap covers all child compilers.

Why not do everything on done?

done fires after emit, so it's too late for setup that needs to affect the compilation output. The only thing that belongs on done is listen(), since the HTTP server should start after the first successful build.

Why use shutdown?

Teardown needs to work when compiler.close() is called. On a MultiCompiler, the aggregate watchClose does not fire for compiler.close(), while child shutdown hooks do.

shutdown is also async, allowing compiler.close() to wait for the server to fully stop and release its port before returning.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bjohansebas
bjohansebas requested a review from alexander-akait June 21, 2026 05:40
bjohansebas added 10 commits July 1, 2026 11:59
@bjohansebas
feat: add plugin support
b5238d5
Allow webpack-dev-server to run as a webpack plugin. The server can now
be created without explicitly passing a compiler, integrates with the
compiler lifecycle to prevent multiple starts on recompilation, ensures
clean shutdown, and supports MultiCompiler setups with multiple
independent plugin servers.
@bjohansebas
test: add tests for plugin support
3f2f870
Add e2e coverage for the plugin API (api-plugin.test.js), MultiCompiler
and multiple independent plugin servers, build-mode behavior, and
related logging snapshots. Add the compile helper and port mappings used
by these tests.
@bjohansebas
docs: add example for using webpack-dev-server as a plugin
1577696
Add a runnable example (app, webpack config and README) showing how to
configure and use webpack-dev-server as a webpack plugin.
@bjohansebas
chore: add changeset for plugin support
c26715c
@bjohansebas
test: add test for in-memory file system behavior in plugin
b2a7608
@bjohansebas
refactor: update hooks to use watchRun instead of beforeCompile for b…
92b48a7
…etter handling of compiler events
@bjohansebas
test: add hot module replacement tests for plugin API
ee43ac1
@bjohansebas
test: enhance output.clean behavior test for in-memory asset serving
a605afb
@bjohansebas
test: log listen() failure instead of throwing in server setup
018b485
@bjohansebas
refactor: update constructor to make compiler parameter optional for …
cda0912
…plugin usage
@bjohansebas
bjohansebas force-pushed the plugin-support branch from 6efe969 to cda0912 Compare July 1, 2026 17:21
@bjohansebas
bjohansebas merged commit 8a554b5 into next Jul 1, 2026
40 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bjohansebas
bjohansebas deleted the plugin-support branch July 1, 2026 18:19
@bjohansebas bjohansebas mentioned this pull request Jul 1, 2026
chore: convert dev server to webpack plugin #3850
Closed
1 of 6 tasks
bjohansebas added a commit that referenced this pull request Jul 1, 2026
@bjohansebas
feat: plugin support (#5650)
e90221c
* feat: add plugin support

Allow webpack-dev-server to run as a webpack plugin. The server can now
be created without explicitly passing a compiler, integrates with the
compiler lifecycle to prevent multiple starts on recompilation, ensures
clean shutdown, and supports MultiCompiler setups with multiple
independent plugin servers.

* test: add tests for plugin support

Add e2e coverage for the plugin API (api-plugin.test.js), MultiCompiler
and multiple independent plugin servers, build-mode behavior, and
related logging snapshots. Add the compile helper and port mappings used
by these tests.

* docs: add example for using webpack-dev-server as a plugin

Add a runnable example (app, webpack config and README) showing how to
configure and use webpack-dev-server as a webpack plugin.

* chore: add changeset for plugin support

* test: add test for in-memory file system behavior in plugin

* refactor: update hooks to use watchRun instead of beforeCompile for better handling of compiler events

* test: add hot module replacement tests for plugin API

* test: enhance output.clean behavior test for in-memory asset serving

* test: log listen() failure instead of throwing in server setup

* refactor: update constructor to make compiler parameter optional for plugin usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@alexander-akait alexander-akait Awaiting requested review from alexander-akait

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@bjohansebas @alexander-akait
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.