Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8e4c498
feat: add hot option for hot module replacement
bjohansebas May 16, 2026
6321925
feat: add browser client runtime for HMR (#2323)
bjohansebas Jun 16, 2026
a6df2c2
feat: implement hot module replacement middleware (#2321)
bjohansebas Jun 16, 2026
a0c2577
docs: add hot module replacement example with Express server and clie…
bjohansebas Jun 16, 2026
895d8a8
feat: enhance error overlay with close button and improved styling
bjohansebas Jun 16, 2026
bfa6ec7
feat: enable reload option for HMR by default and update tests
bjohansebas Jun 16, 2026
c06a6e1
feat: add SSE helper functions and tests for event streaming
bjohansebas Jun 16, 2026
554b8c4
refactor(client): inline ansi stripping and drop the strip-ansi depen…
bjohansebas Jul 20, 2026
0f936c3
refactor(hot): drop the module map from the SSE payload (#2349)
bjohansebas Jul 20, 2026
a1d3027
feat(client): add disconnect() to close the SSE connection (#2351)
bjohansebas Jul 20, 2026
90bdc8f
feat(hot): include the changed file in the building event (#2352)
bjohansebas Jul 20, 2026
e9bfc16
feat(client): bring the error overlay to parity with webpack-dev-serv…
bjohansebas Jul 20, 2026
6f17856
test(client): cover process-update
bjohansebas Jul 21, 2026
3259942
feat(client): collapse the updated-modules list in the console (#2361)
bjohansebas Jul 23, 2026
5b9f332
feat(client): paginate the overlay problems (#2359)
bjohansebas Jul 23, 2026
ec8225a
fix(client): avoid double slash when joining dynamicPublicPath (#2348)
bjohansebas Jul 23, 2026
7756f78
feat(hot): add a building indicator with optional compilation progres…
bjohansebas Jul 23, 2026
fd79873
docs: add HMR notes and troubleshooting section (#2362)
bjohansebas Jul 23, 2026
d9cdc8f
fix(hot): publish sync instead of built for unchanged bundles (#2357)
bjohansebas Jul 23, 2026
92aded0
fix(client): reload when an accept handler errors during apply (#2360)
bjohansebas Jul 23, 2026
8569ddf
fix(hot): scope the catch-up sync and pair bundles by name
bjohansebas Jul 23, 2026
82e6840
fix(hot): end SSE requests that arrive after close()
bjohansebas Jul 23, 2026
0aff5fa
feat(client): share the building indicator and track builds by source…
bjohansebas Jul 24, 2026
833d7a1
feat(client): share the overlay across bundled copies and report by s…
bjohansebas Jul 24, 2026
de5244f
refactor(cspell): consolidate cspell configuration into .cspell.json …
bjohansebas Jul 24, 2026
d926db0
fix(hot): name building events and repair the client reconnect lifecycle
bjohansebas Jul 24, 2026
8999f0a
fix(hot): harden the SSE handshake and defer the overlay's Escape lis…
bjohansebas Jul 24, 2026
492cb8d
fix(hot): align statsOptions and heartbeat validation and pair duplic…
bjohansebas Jul 24, 2026
c733722
fix(hot): require a leading slash in the hot path and serialize publi…
bjohansebas Jul 24, 2026
b2931dc
fix(hono): set headers in the SSE writeHead shim instead of appending
bjohansebas Jul 24, 2026
b94bf31
docs: fix the hot option reference and add a webpack-hot-middleware m…
bjohansebas Jul 24, 2026
da232a4
docs: make the migration guide's entry snippet valid standalone JS
bjohansebas Jul 25, 2026
5b18664
build: compile the client to ES5 and keep dist on the node target
alexander-akait Sep 1, 2026
46d81a7
fix(package): do not add an exports field yet
alexander-akait Sep 1, 2026
86cf535
refactor(client): define everything before it is used and stay on ES5…
alexander-akait Sep 1, 2026
faa0079
fix(hot): never write to a response that already ended
alexander-akait Sep 1, 2026
b15d0f8
ci: do not add a branch to the workflow triggers
alexander-akait Sep 1, 2026
f5f215f
test: keep the js3 array fixture output under test/outputs
alexander-akait Sep 1, 2026
9b6d6bc
docs: list the hot options and note what the client needs in old brow…
alexander-akait Sep 1, 2026
4a75a10
test(client): assert the compiled client is always ES5
alexander-akait Sep 1, 2026
e1a5e29
docs: list the client overlay options in their own table
alexander-akait Sep 1, 2026
70ba234
test(hot): cover the remaining lines of the SSE stream
alexander-akait Sep 1, 2026
c4798c1
fix(hot): address the automated review findings
alexander-akait Sep 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/hot-middleware-migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"webpack-dev-middleware": minor
---

Added a `hot` option that enables hot module replacement, replacing the need for `webpack-hot-middleware`. Pass `hot: true` to enable with defaults, or `hot: { path, heartbeat, progress, statsOptions }` to customize. The client runtime ships with the package and is added as a webpack entry.
17 changes: 15 additions & 2 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@
"finalhandler",
"hono",
"rspack",
"malformed"
"apos",
"malformed",
"Consolas",
"cspellcache",
"CSSOM",
"darkgrey",
"eslintcache",
"esmodules",
"mbold",
"mred",
"noopener",
"noreferrer"
],
"ignorePaths": [
"CHANGELOG.md",
Expand All @@ -36,6 +47,8 @@
"coverage",
"*.log",
"./test/fixtures/**",
"./test/outputs/**"
"./test/outputs/**",
"client/**",
"examples/*/dist/**"
]
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ logs
npm-debug.log*
.eslintcache
.cspellcache
/dist
/client
dist
/local
/reports
/test/outputs
Expand Down
298 changes: 298 additions & 0 deletions README.md

Large diffs are not rendered by default.

33 changes: 23 additions & 10 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
const MIN_BABEL_VERSION = 7;

// The middleware itself runs on the node.js version `engines` requires.
const NODE_TARGETS = { node: "20.9.0" };
// The hot client runs in the browser: it must stay parsable by an ES5 engine,
// so it is compiled down to ES5 (`ie: "11"` is preset-env's ES5 baseline).
// `modules: false` keeps the ESM syntax for webpack to tree-shake.
const CLIENT_TARGETS = { ie: "11" };

module.exports = (api) => {
api.assertVersion(MIN_BABEL_VERSION);
api.cache(true);

// Jest transforms the sources too — there everything, the client included,
// has to be CommonJS for the node.js running the tests.
if (api.env("test")) {
return {
presets: [["@babel/preset-env", { targets: NODE_TARGETS }]],
};
}

return {
presets: [
[
"@babel/preset-env",
{
targets: {
node: "20.9.0",
},
},
],
presets: [["@babel/preset-env", { targets: NODE_TARGETS }]],
overrides: [
{
test: "./client-src",
presets: [
["@babel/preset-env", { modules: false, targets: CLIENT_TARGETS }],
],
},
],
};
};
39 changes: 39 additions & 0 deletions client-src/globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* eslint-disable */

declare module "ansi-html-community" {
function ansiHtmlCommunity(str: string): string;
namespace ansiHtmlCommunity {
function setColors(colors: Record<string, string | string[]>): void;
}
export = ansiHtmlCommunity;
}

interface ClientReporter {
cleanProblemsCache(name: string): void;
problems(
type: "errors" | "warnings",
obj: { errors: string[]; warnings: string[]; name?: string },
): boolean;
success(obj?: { name?: string }): void;
useCustomOverlay(customOverlay: unknown): void;
}

interface EventSourceWrapper {
addMessageListener(fn: (event: { data: string }) => void): void;
close(): void;
}

interface OverlayTrustedTypesPolicy {
createHTML(value: string): string;
}

interface Window {
__wdmEventSourceWrapper?: Record<string, EventSourceWrapper>;
__webpack_dev_middleware_hot_reporter__?: ClientReporter;
trustedTypes?: {
createPolicy(
name: string,
rules: { createHTML(value: string): string },
): OverlayTrustedTypesPolicy;
};
}
Loading
Loading