webpack-dev-server 5.0.0 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/client/modules/logger/index.js +15 -2906
- package/client/overlay.js +1 -1
- package/lib/Server.js +70 -92
- package/lib/getPort.js +1 -1
- package/package.json +8 -5
- package/types/lib/Server.d.ts +272 -159
package/client/overlay.js
CHANGED
|
@@ -151,7 +151,7 @@ var createOverlay = function createOverlay(options) {
|
|
|
151
151
|
*/
|
|
152
152
|
function ensureOverlayExists(callback, trustedTypesPolicyName) {
|
|
153
153
|
if (containerElement) {
|
|
154
|
-
containerElement.innerHTML = "";
|
|
154
|
+
containerElement.innerHTML = overlayTrustedTypesPolicy ? overlayTrustedTypesPolicy.createHTML("") : "";
|
|
155
155
|
// Everything is ready, call the callback right away.
|
|
156
156
|
callback(containerElement);
|
|
157
157
|
return;
|
package/lib/Server.js
CHANGED
|
@@ -18,8 +18,6 @@ const schema = require("./options.json");
|
|
|
18
18
|
/** @typedef {import("webpack").Stats} Stats */
|
|
19
19
|
/** @typedef {import("webpack").MultiStats} MultiStats */
|
|
20
20
|
/** @typedef {import("os").NetworkInterfaceInfo} NetworkInterfaceInfo */
|
|
21
|
-
/** @typedef {import("express").Request} Request */
|
|
22
|
-
/** @typedef {import("express").Response} Response */
|
|
23
21
|
/** @typedef {import("express").NextFunction} NextFunction */
|
|
24
22
|
/** @typedef {import("express").RequestHandler} ExpressRequestHandler */
|
|
25
23
|
/** @typedef {import("express").ErrorRequestHandler} ExpressErrorRequestHandler */
|
|
@@ -42,14 +40,19 @@ const schema = require("./options.json");
|
|
|
42
40
|
|
|
43
41
|
/** @typedef {import("https").ServerOptions & { spdy?: { plain?: boolean | undefined, ssl?: boolean | undefined, 'x-forwarded-for'?: string | undefined, protocol?: string | undefined, protocols?: string[] | undefined }}} ServerOptions */
|
|
44
42
|
|
|
43
|
+
/** @typedef {import("express").Request} Request */
|
|
44
|
+
/** @typedef {import("express").Response} Response */
|
|
45
|
+
|
|
45
46
|
/**
|
|
46
|
-
* @template Request
|
|
47
|
-
* @
|
|
47
|
+
* @template {Request} T
|
|
48
|
+
* @template {Response} U
|
|
49
|
+
* @typedef {import("webpack-dev-middleware").Options<T, U>} DevMiddlewareOptions
|
|
48
50
|
*/
|
|
49
51
|
|
|
50
52
|
/**
|
|
51
|
-
* @template Request
|
|
52
|
-
* @
|
|
53
|
+
* @template {Request} T
|
|
54
|
+
* @template {Response} U
|
|
55
|
+
* @typedef {import("webpack-dev-middleware").Context<T, U>} DevMiddlewareContext
|
|
53
56
|
*/
|
|
54
57
|
|
|
55
58
|
/**
|
|
@@ -1841,36 +1844,20 @@ class Server {
|
|
|
1841
1844
|
const { app, middleware } = this;
|
|
1842
1845
|
|
|
1843
1846
|
/** @type {import("express").Application} */
|
|
1844
|
-
(app).get(
|
|
1845
|
-
"/
|
|
1846
|
-
/**
|
|
1847
|
-
* @param {Request} req
|
|
1848
|
-
* @param {Response} res
|
|
1849
|
-
* @returns {void}
|
|
1850
|
-
*/
|
|
1851
|
-
(req, res) => {
|
|
1852
|
-
res.setHeader("Content-Type", "application/javascript");
|
|
1847
|
+
(app).get("/__webpack_dev_server__/sockjs.bundle.js", (req, res) => {
|
|
1848
|
+
res.setHeader("Content-Type", "application/javascript");
|
|
1853
1849
|
|
|
1854
|
-
|
|
1850
|
+
const clientPath = path.join(__dirname, "..", "client");
|
|
1855
1851
|
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
);
|
|
1852
|
+
res.sendFile(path.join(clientPath, "modules/sockjs-client/index.js"));
|
|
1853
|
+
});
|
|
1859
1854
|
|
|
1860
1855
|
/** @type {import("express").Application} */
|
|
1861
|
-
(app).get(
|
|
1862
|
-
|
|
1863
|
-
/**
|
|
1864
|
-
* @param {Request} _req
|
|
1865
|
-
* @param {Response} res
|
|
1866
|
-
* @returns {void}
|
|
1867
|
-
*/
|
|
1868
|
-
(_req, res) => {
|
|
1869
|
-
this.invalidate();
|
|
1856
|
+
(app).get("/webpack-dev-server/invalidate", (_req, res) => {
|
|
1857
|
+
this.invalidate();
|
|
1870
1858
|
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
);
|
|
1859
|
+
res.end();
|
|
1860
|
+
});
|
|
1874
1861
|
|
|
1875
1862
|
/** @type {import("express").Application} */
|
|
1876
1863
|
(app).get("/webpack-dev-server/open-editor", (req, res) => {
|
|
@@ -1886,74 +1873,65 @@ class Server {
|
|
|
1886
1873
|
});
|
|
1887
1874
|
|
|
1888
1875
|
/** @type {import("express").Application} */
|
|
1889
|
-
(app).get(
|
|
1890
|
-
"
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
if (req.method === "HEAD") {
|
|
1902
|
-
res.end();
|
|
1903
|
-
return;
|
|
1904
|
-
}
|
|
1905
|
-
res.write(
|
|
1906
|
-
'<!DOCTYPE html><html><head><meta charset="utf-8"/></head><body>',
|
|
1907
|
-
);
|
|
1876
|
+
(app).get("/webpack-dev-server", (req, res) => {
|
|
1877
|
+
/** @type {import("webpack-dev-middleware").API<Request, Response>}*/
|
|
1878
|
+
(middleware).waitUntilValid((stats) => {
|
|
1879
|
+
res.setHeader("Content-Type", "text/html");
|
|
1880
|
+
// HEAD requests should not return body content
|
|
1881
|
+
if (req.method === "HEAD") {
|
|
1882
|
+
res.end();
|
|
1883
|
+
return;
|
|
1884
|
+
}
|
|
1885
|
+
res.write(
|
|
1886
|
+
'<!DOCTYPE html><html><head><meta charset="utf-8"/></head><body>',
|
|
1887
|
+
);
|
|
1908
1888
|
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1889
|
+
const statsForPrint =
|
|
1890
|
+
typeof (/** @type {MultiStats} */ (stats).stats) !== "undefined"
|
|
1891
|
+
? /** @type {MultiStats} */ (stats).toJson().children
|
|
1892
|
+
: [/** @type {Stats} */ (stats).toJson()];
|
|
1913
1893
|
|
|
1914
|
-
|
|
1894
|
+
res.write(`<h1>Assets Report:</h1>`);
|
|
1915
1895
|
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
`<li>
|
|
1896
|
+
/**
|
|
1897
|
+
* @type {StatsCompilation[]}
|
|
1898
|
+
*/
|
|
1899
|
+
(statsForPrint).forEach((item, index) => {
|
|
1900
|
+
res.write("<div>");
|
|
1901
|
+
|
|
1902
|
+
const name =
|
|
1903
|
+
// eslint-disable-next-line no-nested-ternary
|
|
1904
|
+
typeof item.name !== "undefined"
|
|
1905
|
+
? item.name
|
|
1906
|
+
: /** @type {MultiStats} */ (stats).stats
|
|
1907
|
+
? `unnamed[${index}]`
|
|
1908
|
+
: "unnamed";
|
|
1909
|
+
|
|
1910
|
+
res.write(`<h2>Compilation: ${name}</h2>`);
|
|
1911
|
+
res.write("<ul>");
|
|
1912
|
+
|
|
1913
|
+
const publicPath = item.publicPath === "auto" ? "" : item.publicPath;
|
|
1914
|
+
|
|
1915
|
+
for (const asset of /** @type {NonNullable<StatsCompilation["assets"]>} */ (
|
|
1916
|
+
item.assets
|
|
1917
|
+
)) {
|
|
1918
|
+
const assetName = asset.name;
|
|
1919
|
+
const assetURL = `${publicPath}${assetName}`;
|
|
1920
|
+
|
|
1921
|
+
res.write(
|
|
1922
|
+
`<li>
|
|
1944
1923
|
<strong><a href="${assetURL}" target="_blank">${assetName}</a></strong>
|
|
1945
1924
|
</li>`,
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
res.write("</ul>");
|
|
1950
|
-
res.write("</div>");
|
|
1951
|
-
});
|
|
1925
|
+
);
|
|
1926
|
+
}
|
|
1952
1927
|
|
|
1953
|
-
res.
|
|
1928
|
+
res.write("</ul>");
|
|
1929
|
+
res.write("</div>");
|
|
1954
1930
|
});
|
|
1955
|
-
|
|
1956
|
-
|
|
1931
|
+
|
|
1932
|
+
res.end("</body></html>");
|
|
1933
|
+
});
|
|
1934
|
+
});
|
|
1957
1935
|
}
|
|
1958
1936
|
|
|
1959
1937
|
/**
|
package/lib/getPort.js
CHANGED
|
@@ -46,7 +46,7 @@ const checkAvailablePort = (basePort, host) =>
|
|
|
46
46
|
server.on("error", reject);
|
|
47
47
|
|
|
48
48
|
server.listen(basePort, host, () => {
|
|
49
|
-
// Next line should return
|
|
49
|
+
// Next line should return AddressInfo because we're calling it after listen() and before close()
|
|
50
50
|
const { port } = /** @type {import("net").AddressInfo} */ (
|
|
51
51
|
server.address()
|
|
52
52
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack-dev-server",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "Serves a webpack app. Updates the browser on changes.",
|
|
5
5
|
"bin": "bin/webpack-dev-server.js",
|
|
6
6
|
"main": "lib/Server.js",
|
|
@@ -25,12 +25,14 @@
|
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"fmt:check": "prettier \"{**/*,*}.{js,json,md,yml,css,ts}\" --list-different",
|
|
28
|
-
"lint:
|
|
28
|
+
"lint:prettier": "prettier --cache --list-different .",
|
|
29
|
+
"lint:js": "eslint --cache .",
|
|
29
30
|
"lint:types": "tsc --pretty --noEmit",
|
|
30
|
-
"lint": "
|
|
31
|
-
"
|
|
31
|
+
"lint:spelling": "cspell --cache --no-must-find-files --quiet \"**/*.*\"",
|
|
32
|
+
"lint": "npm-run-all -l -p \"lint:**\"",
|
|
32
33
|
"fix:js": "npm run lint:js -- --fix",
|
|
33
|
-
"fix": "npm
|
|
34
|
+
"fix:prettier": "npm run lint:prettier -- --write",
|
|
35
|
+
"fix": "npm-run-all -l fix:js fix:prettier",
|
|
34
36
|
"commitlint": "commitlint --from=master",
|
|
35
37
|
"build:client": "rimraf -g ./client/* && babel client-src/ --out-dir client/ --ignore \"client-src/webpack.config.js\" --ignore \"client-src/modules\" && webpack --config client-src/webpack.config.js",
|
|
36
38
|
"build:types": "rimraf -g ./types/* && tsc --declaration --emitDeclarationOnly --outDir types && node ./scripts/extend-webpack-types.js && prettier \"types/**/*.ts\" --write && prettier \"types/**/*.ts\" --write",
|
|
@@ -96,6 +98,7 @@
|
|
|
96
98
|
"babel-loader": "^9.1.0",
|
|
97
99
|
"body-parser": "^1.19.2",
|
|
98
100
|
"core-js": "^3.31.0",
|
|
101
|
+
"cspell": "^8.3.2",
|
|
99
102
|
"css-loader": "^6.8.1",
|
|
100
103
|
"eslint": "^8.43.0",
|
|
101
104
|
"eslint-config-prettier": "^9.1.0",
|