Skip to content
  • Sponsor webpack/webpack-dev-server

  • Notifications You must be signed in to change notification settings
  • Fork 1.5k
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: webpack/webpack-dev-server
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v5.0.1
Choose a base ref
...
head repository: webpack/webpack-dev-server
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v5.0.2
Choose a head ref
  • 10 commits
  • 5 files changed
  • 3 contributors

Commits on Feb 14, 2024

  1. chore(deps-dev): bump husky from 9.0.10 to 9.0.11 (#5051)

    Bumps [husky](https://github.com/typicode/husky) from 9.0.10 to 9.0.11.
    - [Release notes](https://github.com/typicode/husky/releases)
    - [Commits](typicode/husky@v9.0.10...v9.0.11)
    
    ---
    updated-dependencies:
    - dependency-name: husky
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Feb 14, 2024
    Copy the full SHA
    ecc895c View commit details
  2. chore(deps-dev): bump memfs from 4.6.1 to 4.7.0 (#5049)

    Bumps [memfs](https://github.com/streamich/memfs) from 4.6.1 to 4.7.0.
    - [Release notes](https://github.com/streamich/memfs/releases)
    - [Changelog](https://github.com/streamich/memfs/blob/master/CHANGELOG.md)
    - [Commits](streamich/memfs@v4.6.1...v4.7.0)
    
    ---
    updated-dependencies:
    - dependency-name: memfs
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Feb 14, 2024
    Copy the full SHA
    41ed83d View commit details
  3. chore(deps-dev): bump @commitlint/cli from 18.6.0 to 18.6.1 (#5050)

    Bumps [@commitlint/cli](https://github.com/conventional-changelog/commitlint/tree/HEAD/@commitlint/cli) from 18.6.0 to 18.6.1.
    - [Release notes](https://github.com/conventional-changelog/commitlint/releases)
    - [Changelog](https://github.com/conventional-changelog/commitlint/blob/master/@commitlint/cli/CHANGELOG.md)
    - [Commits](https://github.com/conventional-changelog/commitlint/commits/v18.6.1/@commitlint/cli)
    
    ---
    updated-dependencies:
    - dependency-name: "@commitlint/cli"
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Feb 14, 2024
    Copy the full SHA
    2fbc87f View commit details
  4. chore(deps-dev): bump @commitlint/config-conventional (#5048)

    Bumps [@commitlint/config-conventional](https://github.com/conventional-changelog/commitlint/tree/HEAD/@commitlint/config-conventional) from 18.6.0 to 18.6.1.
    - [Release notes](https://github.com/conventional-changelog/commitlint/releases)
    - [Changelog](https://github.com/conventional-changelog/commitlint/blob/master/@commitlint/config-conventional/CHANGELOG.md)
    - [Commits](https://github.com/conventional-changelog/commitlint/commits/v18.6.1/@commitlint/config-conventional)
    
    ---
    updated-dependencies:
    - dependency-name: "@commitlint/config-conventional"
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Feb 14, 2024
    Copy the full SHA
    5983156 View commit details

Commits on Feb 15, 2024

  1. chore(deps-dev): bump core-js from 3.35.1 to 3.36.0 (#5053)

    Bumps [core-js](https://github.com/zloirock/core-js/tree/HEAD/packages/core-js) from 3.35.1 to 3.36.0.
    - [Release notes](https://github.com/zloirock/core-js/releases)
    - [Changelog](https://github.com/zloirock/core-js/blob/master/CHANGELOG.md)
    - [Commits](https://github.com/zloirock/core-js/commits/v3.36.0/packages/core-js)
    
    ---
    updated-dependencies:
    - dependency-name: core-js
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Feb 15, 2024
    Copy the full SHA
    d49ab5e View commit details
  2. chore(deps-dev): bump @commitlint/config-conventional (#5052)

    Bumps [@commitlint/config-conventional](https://github.com/conventional-changelog/commitlint/tree/HEAD/@commitlint/config-conventional) from 18.6.0 to 18.6.2.
    - [Release notes](https://github.com/conventional-changelog/commitlint/releases)
    - [Changelog](https://github.com/conventional-changelog/commitlint/blob/master/@commitlint/config-conventional/CHANGELOG.md)
    - [Commits](https://github.com/conventional-changelog/commitlint/commits/v18.6.2/@commitlint/config-conventional)
    
    ---
    updated-dependencies:
    - dependency-name: "@commitlint/config-conventional"
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Feb 15, 2024
    Copy the full SHA
    4322592 View commit details

Commits on Feb 16, 2024

  1. chore(deps-dev): bump webpack from 5.90.1 to 5.90.2 (#5056)

    Bumps [webpack](https://github.com/webpack/webpack) from 5.90.1 to 5.90.2.
    - [Release notes](https://github.com/webpack/webpack/releases)
    - [Commits](webpack/webpack@v5.90.1...v5.90.2)
    
    ---
    updated-dependencies:
    - dependency-name: webpack
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Feb 16, 2024
    Copy the full SHA
    6b31664 View commit details
  2. chore(deps-dev): bump @types/node from 20.11.17 to 20.11.19 (#5055)

    Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 20.11.17 to 20.11.19.
    - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
    - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)
    
    ---
    updated-dependencies:
    - dependency-name: "@types/node"
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Feb 16, 2024
    Copy the full SHA
    0c4c6b7 View commit details
  3. fix: types (#5057)

    alexander-akait authored Feb 16, 2024
    Copy the full SHA
    da2c24d View commit details
  4. chore(release): 5.0.2

    alexander-akait committed Feb 16, 2024
    Copy the full SHA
    507283d View commit details
Showing with 449 additions and 350 deletions.
  1. +7 −0 CHANGELOG.md
  2. +70 −92 lib/Server.js
  3. +99 −98 package-lock.json
  4. +1 −1 package.json
  5. +272 −159 types/lib/Server.d.ts
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [5.0.2](https://github.com/webpack/webpack-dev-server/compare/v5.0.1...v5.0.2) (2024-02-16)


### Bug Fixes

* types ([#5057](https://github.com/webpack/webpack-dev-server/issues/5057)) ([da2c24d](https://github.com/webpack/webpack-dev-server/commit/da2c24ddd92198a1337553457eedcece6af38195))

### [5.0.1](https://github.com/webpack/webpack-dev-server/compare/v5.0.0...v5.0.1) (2024-02-13)


162 changes: 70 additions & 92 deletions lib/Server.js
Original file line number Diff line number Diff line change
@@ -18,8 +18,6 @@ const schema = require("./options.json");
/** @typedef {import("webpack").Stats} Stats */
/** @typedef {import("webpack").MultiStats} MultiStats */
/** @typedef {import("os").NetworkInterfaceInfo} NetworkInterfaceInfo */
/** @typedef {import("express").Request} Request */
/** @typedef {import("express").Response} Response */
/** @typedef {import("express").NextFunction} NextFunction */
/** @typedef {import("express").RequestHandler} ExpressRequestHandler */
/** @typedef {import("express").ErrorRequestHandler} ExpressErrorRequestHandler */
@@ -42,14 +40,19 @@ const schema = require("./options.json");

/** @typedef {import("https").ServerOptions & { spdy?: { plain?: boolean | undefined, ssl?: boolean | undefined, 'x-forwarded-for'?: string | undefined, protocol?: string | undefined, protocols?: string[] | undefined }}} ServerOptions */

/** @typedef {import("express").Request} Request */
/** @typedef {import("express").Response} Response */

/**
* @template Request, Response
* @typedef {import("webpack-dev-middleware").Options<IncomingMessage, ServerResponse>} DevMiddlewareOptions
* @template {Request} T
* @template {Response} U
* @typedef {import("webpack-dev-middleware").Options<T, U>} DevMiddlewareOptions
*/

/**
* @template Request, Response
* @typedef {import("webpack-dev-middleware").Context<IncomingMessage, ServerResponse>} DevMiddlewareContext
* @template {Request} T
* @template {Response} U
* @typedef {import("webpack-dev-middleware").Context<T, U>} DevMiddlewareContext
*/

/**
@@ -1841,36 +1844,20 @@ class Server {
const { app, middleware } = this;

/** @type {import("express").Application} */
(app).get(
"/__webpack_dev_server__/sockjs.bundle.js",
/**
* @param {Request} req
* @param {Response} res
* @returns {void}
*/
(req, res) => {
res.setHeader("Content-Type", "application/javascript");
(app).get("/__webpack_dev_server__/sockjs.bundle.js", (req, res) => {
res.setHeader("Content-Type", "application/javascript");

const clientPath = path.join(__dirname, "..", "client");
const clientPath = path.join(__dirname, "..", "client");

res.sendFile(path.join(clientPath, "modules/sockjs-client/index.js"));
},
);
res.sendFile(path.join(clientPath, "modules/sockjs-client/index.js"));
});

/** @type {import("express").Application} */
(app).get(
"/webpack-dev-server/invalidate",
/**
* @param {Request} _req
* @param {Response} res
* @returns {void}
*/
(_req, res) => {
this.invalidate();
(app).get("/webpack-dev-server/invalidate", (_req, res) => {
this.invalidate();

res.end();
},
);
res.end();
});

/** @type {import("express").Application} */
(app).get("/webpack-dev-server/open-editor", (req, res) => {
@@ -1886,74 +1873,65 @@ class Server {
});

/** @type {import("express").Application} */
(app).get(
"/webpack-dev-server",
/**
* @param {Request} req
* @param {Response} res
* @returns {void}
*/
(req, res) => {
/** @type {import("webpack-dev-middleware").API<Request, Response>}*/
(middleware).waitUntilValid((stats) => {
res.setHeader("Content-Type", "text/html");
// HEAD requests should not return body content
if (req.method === "HEAD") {
res.end();
return;
}
res.write(
'<!DOCTYPE html><html><head><meta charset="utf-8"/></head><body>',
);
(app).get("/webpack-dev-server", (req, res) => {
/** @type {import("webpack-dev-middleware").API<Request, Response>}*/
(middleware).waitUntilValid((stats) => {
res.setHeader("Content-Type", "text/html");
// HEAD requests should not return body content
if (req.method === "HEAD") {
res.end();
return;
}
res.write(
'<!DOCTYPE html><html><head><meta charset="utf-8"/></head><body>',
);

const statsForPrint =
typeof (/** @type {MultiStats} */ (stats).stats) !== "undefined"
? /** @type {MultiStats} */ (stats).toJson().children
: [/** @type {Stats} */ (stats).toJson()];
const statsForPrint =
typeof (/** @type {MultiStats} */ (stats).stats) !== "undefined"
? /** @type {MultiStats} */ (stats).toJson().children
: [/** @type {Stats} */ (stats).toJson()];

res.write(`<h1>Assets Report:</h1>`);
res.write(`<h1>Assets Report:</h1>`);

/**
* @type {StatsCompilation[]}
*/
(statsForPrint).forEach((item, index) => {
res.write("<div>");

const name =
// eslint-disable-next-line no-nested-ternary
typeof item.name !== "undefined"
? item.name
: /** @type {MultiStats} */ (stats).stats
? `unnamed[${index}]`
: "unnamed";

res.write(`<h2>Compilation: ${name}</h2>`);
res.write("<ul>");

const publicPath =
item.publicPath === "auto" ? "" : item.publicPath;

for (const asset of /** @type {NonNullable<StatsCompilation["assets"]>} */ (
item.assets
)) {
const assetName = asset.name;
const assetURL = `${publicPath}${assetName}`;

res.write(
`<li>
/**
* @type {StatsCompilation[]}
*/
(statsForPrint).forEach((item, index) => {
res.write("<div>");

const name =
// eslint-disable-next-line no-nested-ternary
typeof item.name !== "undefined"
? item.name
: /** @type {MultiStats} */ (stats).stats
? `unnamed[${index}]`
: "unnamed";

res.write(`<h2>Compilation: ${name}</h2>`);
res.write("<ul>");

const publicPath = item.publicPath === "auto" ? "" : item.publicPath;

for (const asset of /** @type {NonNullable<StatsCompilation["assets"]>} */ (
item.assets
)) {
const assetName = asset.name;
const assetURL = `${publicPath}${assetName}`;

res.write(
`<li>
<strong><a href="${assetURL}" target="_blank">${assetName}</a></strong>
</li>`,
);
}

res.write("</ul>");
res.write("</div>");
});
);
}

res.end("</body></html>");
res.write("</ul>");
res.write("</div>");
});
},
);

res.end("</body></html>");
});
});
}

/**
Loading