webpack-dev-server 4.3.1 → 4.7.0
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 +71 -33
- package/bin/cli-flags.js +507 -227
- package/bin/process-arguments.js +87 -7
- package/bin/webpack-dev-server.js +3 -0
- package/client/clients/SockJSClient.js +21 -2
- package/client/clients/WebSocketClient.js +16 -1
- package/client/index.js +39 -4
- package/client/modules/logger/index.js +46 -14
- package/client/modules/sockjs-client/index.js +20 -17
- package/client/socket.js +12 -9
- package/client/utils/log.js +6 -1
- package/client/utils/sendMessage.js +5 -0
- package/lib/Server.js +1935 -839
- package/lib/options.json +279 -21
- package/lib/servers/BaseServer.js +8 -0
- package/lib/servers/SockJSServer.js +42 -9
- package/lib/servers/WebsocketServer.js +66 -35
- package/package.json +28 -18
- package/types/bin/cli-flags.d.ts +934 -0
- package/types/bin/process-arguments.d.ts +50 -0
- package/types/bin/webpack-dev-server.d.ts +27 -0
- package/types/lib/Server.d.ts +3388 -0
- package/types/lib/servers/BaseServer.d.ts +15 -0
- package/types/lib/servers/SockJSServer.d.ts +12 -0
- package/types/lib/servers/WebsocketServer.d.ts +13 -0
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
/* eslint-disable
|
|
4
|
-
class-methods-use-this
|
|
5
|
-
*/
|
|
6
3
|
const WebSocket = require("ws");
|
|
7
4
|
const BaseServer = require("./BaseServer");
|
|
8
5
|
|
|
6
|
+
/** @typedef {import("../Server").WebSocketServerConfiguration} WebSocketServerConfiguration */
|
|
7
|
+
/** @typedef {import("../Server").ClientConnection} ClientConnection */
|
|
8
|
+
|
|
9
9
|
module.exports = class WebsocketServer extends BaseServer {
|
|
10
10
|
static heartbeatInterval = 1000;
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* @param {import("../Server")} server
|
|
14
|
+
*/
|
|
12
15
|
constructor(server) {
|
|
13
16
|
super(server);
|
|
14
17
|
|
|
18
|
+
/** @type {import("ws").ServerOptions} */
|
|
15
19
|
const options = {
|
|
16
|
-
|
|
20
|
+
.../** @type {WebSocketServerConfiguration} */
|
|
21
|
+
(this.server.options.webSocketServer).options,
|
|
17
22
|
clientTracking: false,
|
|
18
23
|
};
|
|
19
24
|
const isNoServerMode =
|
|
@@ -26,46 +31,72 @@ module.exports = class WebsocketServer extends BaseServer {
|
|
|
26
31
|
|
|
27
32
|
this.implementation = new WebSocket.Server(options);
|
|
28
33
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
/** @type {import("http").Server} */
|
|
35
|
+
(this.server.server).on(
|
|
36
|
+
"upgrade",
|
|
37
|
+
/**
|
|
38
|
+
* @param {import("http").IncomingMessage} req
|
|
39
|
+
* @param {import("stream").Duplex} sock
|
|
40
|
+
* @param {Buffer} head
|
|
41
|
+
*/
|
|
42
|
+
(req, sock, head) => {
|
|
43
|
+
if (!this.implementation.shouldHandle(req)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
38
46
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
this.implementation.handleUpgrade(req, sock, head, (connection) => {
|
|
48
|
+
this.implementation.emit("connection", connection, req);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
this.implementation.on(
|
|
54
|
+
"error",
|
|
55
|
+
/**
|
|
56
|
+
* @param {Error} err
|
|
57
|
+
*/
|
|
58
|
+
(err) => {
|
|
59
|
+
this.server.logger.error(err.message);
|
|
60
|
+
}
|
|
61
|
+
);
|
|
42
62
|
|
|
43
63
|
const interval = setInterval(() => {
|
|
44
|
-
this.clients.forEach(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
64
|
+
this.clients.forEach(
|
|
65
|
+
/**
|
|
66
|
+
* @param {ClientConnection} client
|
|
67
|
+
*/
|
|
68
|
+
(client) => {
|
|
69
|
+
if (client.isAlive === false) {
|
|
70
|
+
client.terminate();
|
|
71
|
+
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
client.isAlive = false;
|
|
76
|
+
client.ping(() => {});
|
|
49
77
|
}
|
|
50
|
-
|
|
51
|
-
client.isAlive = false;
|
|
52
|
-
client.ping(() => {});
|
|
53
|
-
});
|
|
78
|
+
);
|
|
54
79
|
}, WebsocketServer.heartbeatInterval);
|
|
55
80
|
|
|
56
|
-
this.implementation.on(
|
|
57
|
-
|
|
81
|
+
this.implementation.on(
|
|
82
|
+
"connection",
|
|
83
|
+
/**
|
|
84
|
+
* @param {ClientConnection} client
|
|
85
|
+
*/
|
|
86
|
+
(client) => {
|
|
87
|
+
this.clients.push(client);
|
|
58
88
|
|
|
59
|
-
client.isAlive = true;
|
|
60
|
-
|
|
61
|
-
client.on("pong", () => {
|
|
62
89
|
client.isAlive = true;
|
|
63
|
-
});
|
|
64
90
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
91
|
+
client.on("pong", () => {
|
|
92
|
+
client.isAlive = true;
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
client.on("close", () => {
|
|
96
|
+
this.clients.splice(this.clients.indexOf(client), 1);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
);
|
|
69
100
|
|
|
70
101
|
this.implementation.on("close", () => {
|
|
71
102
|
clearInterval(interval);
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack-dev-server",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
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",
|
|
7
|
+
"types": "types/lib/Server.d.ts",
|
|
7
8
|
"files": [
|
|
8
9
|
"bin",
|
|
9
10
|
"lib",
|
|
10
|
-
"client"
|
|
11
|
+
"client",
|
|
12
|
+
"types"
|
|
11
13
|
],
|
|
12
14
|
"engines": {
|
|
13
15
|
"node": ">= 12.13.0"
|
|
@@ -15,14 +17,15 @@
|
|
|
15
17
|
"scripts": {
|
|
16
18
|
"fmt:check": "prettier \"{**/*,*}.{js,json,md,yml,css,ts}\" --list-different",
|
|
17
19
|
"lint:js": "eslint . --cache",
|
|
18
|
-
"lint:
|
|
19
|
-
"lint": "npm-run-all
|
|
20
|
+
"lint:types": "tsc --pretty --noEmit",
|
|
21
|
+
"lint": "npm-run-all -p \"fmt:**\" \"lint:**\"",
|
|
20
22
|
"fmt": "npm run fmt:check -- --write",
|
|
21
23
|
"fix:js": "npm run lint:js -- --fix",
|
|
22
24
|
"fix": "npm-run-all fix:js fmt",
|
|
23
25
|
"commitlint": "commitlint --from=master",
|
|
24
|
-
"build": "npm-run-all build:client",
|
|
25
26
|
"build:client": "rimraf ./client/* && babel client-src/ --out-dir client/ --ignore \"client-src/webpack.config.js\" --ignore \"client-src/modules\" && webpack --config client-src/webpack.config.js",
|
|
27
|
+
"build:types": "rimraf ./types/* && tsc --declaration --emitDeclarationOnly --outDir types && node ./scripts/extend-webpack-types.js && prettier \"types/**/*.ts\" --write && prettier \"types/**/*.ts\" --write",
|
|
28
|
+
"build": "npm-run-all -p \"build:**\"",
|
|
26
29
|
"test:only": "jest",
|
|
27
30
|
"test:coverage": "npm run test:only -- --coverage",
|
|
28
31
|
"test:watch": "npm run test:coverage --watch",
|
|
@@ -32,30 +35,35 @@
|
|
|
32
35
|
"release": "standard-version"
|
|
33
36
|
},
|
|
34
37
|
"dependencies": {
|
|
38
|
+
"@types/bonjour": "^3.5.9",
|
|
39
|
+
"@types/connect-history-api-fallback": "^1.3.5",
|
|
40
|
+
"@types/serve-index": "^1.9.1",
|
|
41
|
+
"@types/sockjs": "^0.3.33",
|
|
42
|
+
"@types/ws": "^8.2.2",
|
|
35
43
|
"ansi-html-community": "^0.0.8",
|
|
36
44
|
"bonjour": "^3.5.0",
|
|
37
|
-
"chokidar": "^3.5.
|
|
45
|
+
"chokidar": "^3.5.2",
|
|
38
46
|
"colorette": "^2.0.10",
|
|
39
47
|
"compression": "^1.7.4",
|
|
40
48
|
"connect-history-api-fallback": "^1.6.0",
|
|
49
|
+
"default-gateway": "^6.0.3",
|
|
41
50
|
"del": "^6.0.0",
|
|
42
51
|
"express": "^4.17.1",
|
|
43
52
|
"graceful-fs": "^4.2.6",
|
|
44
53
|
"html-entities": "^2.3.2",
|
|
45
54
|
"http-proxy-middleware": "^2.0.0",
|
|
46
|
-
"internal-ip": "^6.2.0",
|
|
47
55
|
"ipaddr.js": "^2.0.1",
|
|
48
56
|
"open": "^8.0.9",
|
|
49
57
|
"p-retry": "^4.5.0",
|
|
50
58
|
"portfinder": "^1.0.28",
|
|
51
|
-
"schema-utils": "^
|
|
59
|
+
"schema-utils": "^4.0.0",
|
|
52
60
|
"selfsigned": "^1.10.11",
|
|
53
61
|
"serve-index": "^1.9.1",
|
|
54
62
|
"sockjs": "^0.3.21",
|
|
55
63
|
"spdy": "^4.0.2",
|
|
56
64
|
"strip-ansi": "^7.0.0",
|
|
57
65
|
"url": "^0.11.0",
|
|
58
|
-
"webpack-dev-middleware": "^5.
|
|
66
|
+
"webpack-dev-middleware": "^5.3.0",
|
|
59
67
|
"ws": "^8.1.0"
|
|
60
68
|
},
|
|
61
69
|
"devDependencies": {
|
|
@@ -66,15 +74,17 @@
|
|
|
66
74
|
"@babel/plugin-transform-runtime": "^7.14.5",
|
|
67
75
|
"@babel/preset-env": "^7.14.5",
|
|
68
76
|
"@babel/runtime": "^7.14.5",
|
|
69
|
-
"@commitlint/cli": "^
|
|
70
|
-
"@commitlint/config-conventional": "^
|
|
77
|
+
"@commitlint/cli": "^15.0.0",
|
|
78
|
+
"@commitlint/config-conventional": "^15.0.0",
|
|
79
|
+
"@types/compression": "^1.7.2",
|
|
80
|
+
"@types/default-gateway": "^3.0.1",
|
|
71
81
|
"acorn": "^8.2.4",
|
|
72
|
-
"babel-jest": "^27.
|
|
82
|
+
"babel-jest": "^27.4.4",
|
|
73
83
|
"babel-loader": "^8.2.2",
|
|
74
|
-
"body-parser": "^1.19.
|
|
84
|
+
"body-parser": "^1.19.1",
|
|
75
85
|
"core-js": "^3.12.1",
|
|
76
86
|
"css-loader": "^5.2.4",
|
|
77
|
-
"eslint": "^
|
|
87
|
+
"eslint": "^8.0.1",
|
|
78
88
|
"eslint-config-prettier": "^8.3.0",
|
|
79
89
|
"eslint-config-webpack": "^1.2.5",
|
|
80
90
|
"eslint-plugin-import": "^2.23.2",
|
|
@@ -83,16 +93,16 @@
|
|
|
83
93
|
"html-webpack-plugin": "^4.5.2",
|
|
84
94
|
"http-proxy": "^1.18.1",
|
|
85
95
|
"husky": "^7.0.0",
|
|
86
|
-
"jest": "^27.
|
|
96
|
+
"jest": "^27.4.4",
|
|
87
97
|
"klona": "^2.0.4",
|
|
88
98
|
"less": "^4.1.1",
|
|
89
99
|
"less-loader": "^7.3.0",
|
|
90
|
-
"lint-staged": "^
|
|
100
|
+
"lint-staged": "^12.0.2",
|
|
91
101
|
"marked": "^3.0.0",
|
|
92
102
|
"memfs": "^3.2.2",
|
|
93
103
|
"npm-run-all": "^4.1.5",
|
|
94
104
|
"prettier": "^2.3.1",
|
|
95
|
-
"puppeteer": "^
|
|
105
|
+
"puppeteer": "^13.0.0",
|
|
96
106
|
"require-from-string": "^2.0.2",
|
|
97
107
|
"rimraf": "^3.0.2",
|
|
98
108
|
"sockjs-client": "^1.5.1",
|
|
@@ -103,7 +113,7 @@
|
|
|
103
113
|
"tcp-port-used": "^1.0.2",
|
|
104
114
|
"typescript": "^4.2.4",
|
|
105
115
|
"url-loader": "^4.1.1",
|
|
106
|
-
"webpack": "^5.
|
|
116
|
+
"webpack": "^5.64.0",
|
|
107
117
|
"webpack-cli": "^4.7.2",
|
|
108
118
|
"webpack-merge": "^5.8.0"
|
|
109
119
|
},
|