Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3ad3795
chore: remove colorette dependency and update minimum webpack version…
bjohansebas Jan 19, 2026
bf4167d
feat!: drop support for node <20.9 (#2248)
bjohansebas Jan 20, 2026
327d5bf
feat: enable cacheImmutable by default (#2247)
bjohansebas Jan 26, 2026
cced490
refactor: logic for cacheControl and cacheImmutable (#2254)
alexander-akait Jan 27, 2026
d4e1118
feat!: update `getFilenameFromUrl` to throw errors and return `undefi…
bjohansebas Jan 27, 2026
055687c
chore: update dependencies for memfs and mime-types (#2258)
bjohansebas Jan 29, 2026
1fccf27
feat: add `forwardError` option to enable error forwarding to next mi…
bjohansebas Feb 22, 2026
2146256
feat: added support for plugin usage
bjohansebas Mar 11, 2026
9f3ceed
refactor: rebase
alexander-akait Mar 11, 2026
f991e2a
ci: update
alexander-akait Mar 11, 2026
3049ea5
refactor: safe stream for hono
alexander-akait Mar 11, 2026
48a021b
test: fix
alexander-akait Mar 11, 2026
6cfc4f1
test: debug
alexander-akait Mar 11, 2026
5f7adc4
test: debug
alexander-akait Mar 17, 2026
d754291
test: debug
alexander-akait Mar 17, 2026
fa79731
test: debug
alexander-akait Mar 17, 2026
c76003c
refactor: use internal validate when avaliable
alexander-akait Mar 17, 2026
8a7d83f
refactor: merge common utils into one file
alexander-akait Mar 17, 2026
374d386
refactor: merge more utils
alexander-akait Mar 17, 2026
91ccf6f
refactor: merge all utils
alexander-akait Mar 17, 2026
8e0521a
refactor: code
alexander-akait Mar 17, 2026
ddc7d93
test: fix
alexander-akait Mar 18, 2026
27f763c
refactor: code
alexander-akait Mar 18, 2026
4bd5d82
refactor: improve perf
alexander-akait Mar 18, 2026
469f201
refactor: reuse output file system from compilation
alexander-akait Mar 18, 2026
5b8d001
refactor: code
alexander-akait Mar 18, 2026
a5b039b
refactor: remove outdated code
alexander-akait Mar 18, 2026
8e273d1
test: trace deprecation
alexander-akait Mar 18, 2026
17b50da
test: stability
alexander-akait Mar 18, 2026
060bb9a
chore: added trusted publisher
alexander-akait Mar 18, 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
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets).

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md).
5 changes: 5 additions & 0 deletions .changeset/better-peaches-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"webpack-dev-middleware": patch
---

Improved initial loading module time.
133 changes: 133 additions & 0 deletions .changeset/changelog-generator.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import { getInfo, getInfoFromPullRequest } from "@changesets/get-github-info";

/** @typedef {import("@changesets/types").ChangelogFunctions} ChangelogFunctions */

/**
* @returns {{ GITHUB_SERVER_URL: string }} value
*/
function readEnv() {
const GITHUB_SERVER_URL =
process.env.GITHUB_SERVER_URL || "https://github.com";
return { GITHUB_SERVER_URL };
}

/** @type {ChangelogFunctions} */
const changelogFunctions = {
getDependencyReleaseLine: async (
changesets,
dependenciesUpdated,
options,
) => {
if (!options.repo) {
throw new Error(
'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]',
);
}
if (dependenciesUpdated.length === 0) return "";

const changesetLink = `- Updated dependencies [${(
await Promise.all(
changesets.map(async (cs) => {
if (cs.commit) {
const { links } = await getInfo({
repo: options.repo,
commit: cs.commit,
});
return links.commit;
}
}),
)
)
.filter(Boolean)
.join(", ")}]:`;

const updatedDependenciesList = dependenciesUpdated.map(
(dependency) => ` - ${dependency.name}@${dependency.newVersion}`,
);

return [changesetLink, ...updatedDependenciesList].join("\n");
},
getReleaseLine: async (changeset, type, options) => {
const { GITHUB_SERVER_URL } = readEnv();
if (!options || !options.repo) {
throw new Error(
'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]',
);
}

/** @type {number | undefined} */
let prFromSummary;
/** @type {string | undefined} */
let commitFromSummary;
/** @type {string[]} */
const usersFromSummary = [];

const replacedChangelog = changeset.summary
.replace(/^\s*(?:pr|pull|pull\s+request):\s*#?(\d+)/im, (_, pr) => {
const num = Number(pr);
if (!Number.isNaN(num)) prFromSummary = num;
return "";
})
.replace(/^\s*commit:\s*([^\s]+)/im, (_, commit) => {
commitFromSummary = commit;
return "";
})
.replaceAll(/^\s*(?:author|user):\s*@?([^\s]+)/gim, (_, user) => {
usersFromSummary.push(user);
return "";
})
.trim();

const [firstLine, ...futureLines] = replacedChangelog
.split("\n")
.map((l) => l.trimEnd());

const links = await (async () => {
if (prFromSummary !== undefined) {
let { links } = await getInfoFromPullRequest({
repo: options.repo,
pull: prFromSummary,
});
if (commitFromSummary) {
const shortCommitId = commitFromSummary.slice(0, 7);
links = {
...links,
commit: `[\`${shortCommitId}\`](${GITHUB_SERVER_URL}/${options.repo}/commit/${commitFromSummary})`,
};
}
return links;
}
const commitToFetchFrom = commitFromSummary || changeset.commit;
if (commitToFetchFrom) {
const { links } = await getInfo({
repo: options.repo,
commit: commitToFetchFrom,
});
return links;
}
return {
commit: null,
pull: null,
user: null,
};
})();

const users = usersFromSummary.length
? usersFromSummary
.map(
(userFromSummary) =>
`[@${userFromSummary}](${GITHUB_SERVER_URL}/${userFromSummary})`,
)
.join(", ")
: links.user;

let suffix = "";
if (links.pull || links.commit || users) {
suffix = `(${users ? `by ${users} ` : ""}in ${links.pull || links.commit})`;
}

return `\n\n- ${firstLine} ${suffix}\n${futureLines.map((l) => ` ${l}`).join("\n")}`;
},
};

export default changelogFunctions;
13 changes: 13 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.1.2/schema.json",
"changelog": [
"./changelog-generator.mjs",
{ "repo": "webpack/webpack-dev-middleware" }
],
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
5 changes: 5 additions & 0 deletions .changeset/early-rocks-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"webpack-dev-middleware": patch
---

Removed outdated code and improved performance by avoiding extra loops.
5 changes: 5 additions & 0 deletions .changeset/famous-steaks-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"webpack-dev-middleware": minor
---

Added support for plugin usage, useful when the middleware will be used as a webpack plugin (no stats output, no extra actions).
5 changes: 5 additions & 0 deletions .changeset/great-meals-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"webpack-dev-middleware": minor
---

Added the `forwardError` option to enable error forwarding to next middleware.
5 changes: 5 additions & 0 deletions .changeset/late-snails-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"webpack-dev-middleware": major
---

The `getFilenameFromUrl` function now returns an object with the found `filename` (or `undefined` if the file was not found) and throws an error if the URL cannot be processed. Additionally, the object contains the `extra` property with `stats` (file system stats) and `outputFileSystem` (output file system where file was found) properties.
5 changes: 5 additions & 0 deletions .changeset/moody-flowers-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"webpack-dev-middleware": minor
---

Enable `cacheImmutable` by default for immutable assets.
5 changes: 5 additions & 0 deletions .changeset/strict-drinks-stay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"webpack-dev-middleware": major
---

Minimum supported `Node.js` version is `20.9.0`.
5 changes: 5 additions & 0 deletions .changeset/upset-planes-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"webpack-dev-middleware": major
---

Minimum supported `webpack` version is `5.101.0`.
4 changes: 2 additions & 2 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"language": "en,en-gb",
"words": [
"memfs",
"colorette",
"noextension",
"fullhash",
"execa",
Expand All @@ -24,7 +23,8 @@
"cachable",
"finalhandler",
"hono",
"rspack"
"rspack",
"malformed"
],
"ignorePaths": [
"CHANGELOG.md",
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: "Checkout Repository"
uses: actions/checkout@v6
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: "Dependency Review"
uses: actions/dependency-review-action@v4
uses: actions/dependency-review-action@2031cfc080254a8a887f58cffee85186f0e49e48 # v4.9.0
20 changes: 7 additions & 13 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ jobs:
group: lint-${{ matrix.os }}-v${{ matrix.node-version }}-${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
Expand All @@ -53,20 +53,14 @@ jobs:
- name: Check types
run: if [ -n "$(git status types --porcelain)" ]; then echo "Missing types. Update types by running 'npm run build:types'"; exit 1; else echo "All types are valid"; fi

- name: Security audit
run: npm run security

- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose

test:
name: Test - ${{ matrix.os }} - Node v${{ matrix.node-version }}, Webpack ${{ matrix.webpack-version }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [18.x, 20.x, 22.x, 24.x]
node-version: [20.x, 22.x, 24.x, 25.x]
webpack-version: [latest]

runs-on: ${{ matrix.os }}
Expand All @@ -76,10 +70,10 @@ jobs:
cancel-in-progress: true

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
Expand All @@ -91,6 +85,6 @@ jobs:
run: npm run test:coverage -- --ci

- name: Submit coverage data to codecov
uses: codecov/codecov-action@v5
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Release

on:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

permissions:
id-token: write # Required for OIDC
contents: write
pull-requests: write

jobs:
release:
if: github.repository == 'webpack/webpack-dev-middleware'
name: Release
runs-on: ubuntu-latest
outputs:
published: ${{ steps.changesets.outputs.published }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Use Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: lts/*
cache: npm

- run: npm ci

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@6a0a831ff30acef54f2c6aa1cbbc1096b066edaf # v1.7.0
with:
version: npm run version
publish: npm run release
commit: "chore(release): new release"
title: "chore(release): new release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: "" # https://github.com/changesets/changesets/issues/1152#issuecomment-3190884868
Loading
Loading