webpack-dev-server 4.15.1 → 5.0.1

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/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 AdressInfo because we're calling it after listen() and before close()
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
  );
@@ -75,7 +75,7 @@ const getAvailablePort = async (port, hosts) => {
75
75
  /* We throw an error only if the interface exists */
76
76
  if (
77
77
  !nonExistentInterfaceErrors.has(
78
- /** @type {NodeJS.ErrnoException} */ (error).code
78
+ /** @type {NodeJS.ErrnoException} */ (error).code,
79
79
  )
80
80
  ) {
81
81
  throw error;
@@ -118,7 +118,7 @@ async function getPorts(basePort, host) {
118
118
  /* Try next port if port is busy; throw for any other error */
119
119
  if (
120
120
  !portUnavailableErrors.has(
121
- /** @type {NodeJS.ErrnoException} */ (error).code
121
+ /** @type {NodeJS.ErrnoException} */ (error).code,
122
122
  )
123
123
  ) {
124
124
  throw error;
package/lib/options.json CHANGED
@@ -264,195 +264,6 @@
264
264
  "type": "object",
265
265
  "additionalProperties": true
266
266
  },
267
- "HTTP2": {
268
- "type": "boolean",
269
- "description": "Allows to serve over HTTP/2 using SPDY. Deprecated, use the `server` option.",
270
- "link": "https://webpack.js.org/configuration/dev-server/#devserverhttp2",
271
- "cli": {
272
- "negatedDescription": "Does not serve over HTTP/2 using SPDY."
273
- }
274
- },
275
- "HTTPS": {
276
- "anyOf": [
277
- {
278
- "type": "boolean",
279
- "cli": {
280
- "negatedDescription": "Disallows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP)."
281
- }
282
- },
283
- {
284
- "type": "object",
285
- "additionalProperties": true,
286
- "properties": {
287
- "passphrase": {
288
- "type": "string",
289
- "description": "Passphrase for a pfx file. Deprecated, use the `server.options.passphrase` option."
290
- },
291
- "requestCert": {
292
- "type": "boolean",
293
- "description": "Request for an SSL certificate. Deprecated, use the `server.options.requestCert` option.",
294
- "cli": {
295
- "negatedDescription": "Does not request for an SSL certificate."
296
- }
297
- },
298
- "ca": {
299
- "anyOf": [
300
- {
301
- "type": "array",
302
- "items": {
303
- "anyOf": [
304
- {
305
- "type": "string"
306
- },
307
- {
308
- "instanceof": "Buffer"
309
- }
310
- ]
311
- }
312
- },
313
- {
314
- "type": "string"
315
- },
316
- {
317
- "instanceof": "Buffer"
318
- }
319
- ],
320
- "description": "Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option."
321
- },
322
- "cacert": {
323
- "anyOf": [
324
- {
325
- "type": "array",
326
- "items": {
327
- "anyOf": [
328
- {
329
- "type": "string"
330
- },
331
- {
332
- "instanceof": "Buffer"
333
- }
334
- ]
335
- }
336
- },
337
- {
338
- "type": "string"
339
- },
340
- {
341
- "instanceof": "Buffer"
342
- }
343
- ],
344
- "description": "Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option."
345
- },
346
- "cert": {
347
- "anyOf": [
348
- {
349
- "type": "array",
350
- "items": {
351
- "anyOf": [
352
- {
353
- "type": "string"
354
- },
355
- {
356
- "instanceof": "Buffer"
357
- }
358
- ]
359
- }
360
- },
361
- {
362
- "type": "string"
363
- },
364
- {
365
- "instanceof": "Buffer"
366
- }
367
- ],
368
- "description": "Path to an SSL certificate or content of an SSL certificate. Deprecated, use the `server.options.cert` option."
369
- },
370
- "crl": {
371
- "anyOf": [
372
- {
373
- "type": "array",
374
- "items": {
375
- "anyOf": [
376
- {
377
- "type": "string"
378
- },
379
- {
380
- "instanceof": "Buffer"
381
- }
382
- ]
383
- }
384
- },
385
- {
386
- "type": "string"
387
- },
388
- {
389
- "instanceof": "Buffer"
390
- }
391
- ],
392
- "description": "Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, use the `server.options.crl` option."
393
- },
394
- "key": {
395
- "anyOf": [
396
- {
397
- "type": "array",
398
- "items": {
399
- "anyOf": [
400
- {
401
- "type": "string"
402
- },
403
- {
404
- "instanceof": "Buffer"
405
- },
406
- {
407
- "type": "object",
408
- "additionalProperties": true
409
- }
410
- ]
411
- }
412
- },
413
- {
414
- "type": "string"
415
- },
416
- {
417
- "instanceof": "Buffer"
418
- }
419
- ],
420
- "description": "Path to an SSL key or content of an SSL key. Deprecated, use the `server.options.key` option."
421
- },
422
- "pfx": {
423
- "anyOf": [
424
- {
425
- "type": "array",
426
- "items": {
427
- "anyOf": [
428
- {
429
- "type": "string"
430
- },
431
- {
432
- "instanceof": "Buffer"
433
- },
434
- {
435
- "type": "object",
436
- "additionalProperties": true
437
- }
438
- ]
439
- }
440
- },
441
- {
442
- "type": "string"
443
- },
444
- {
445
- "instanceof": "Buffer"
446
- }
447
- ],
448
- "description": "Path to an SSL pfx file or content of an SSL pfx file. Deprecated, use the `server.options.pfx` option."
449
- }
450
- }
451
- }
452
- ],
453
- "description": "Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). Deprecated, use the `server` option.",
454
- "link": "https://webpack.js.org/configuration/dev-server/#devserverhttps"
455
- },
456
267
  "HeaderObject": {
457
268
  "type": "object",
458
269
  "additionalProperties": false,
@@ -556,24 +367,6 @@
556
367
  },
557
368
  "link": "https://webpack.js.org/configuration/dev-server/#devserverlivereload"
558
369
  },
559
- "MagicHTML": {
560
- "type": "boolean",
561
- "description": "Tells dev-server whether to enable magic HTML routes (routes corresponding to your webpack output, for example '/main' for 'main.js').",
562
- "cli": {
563
- "negatedDescription": "Disables magic HTML routes (routes corresponding to your webpack output, for example '/main' for 'main.js')."
564
- },
565
- "link": "https://webpack.js.org/configuration/dev-server/#devservermagichtml"
566
- },
567
- "OnAfterSetupMiddleware": {
568
- "instanceof": "Function",
569
- "description": "Provides the ability to execute a custom function and apply custom middleware(s) after all other middlewares. Deprecated: please use the 'setupMiddlewares' option.",
570
- "link": "https://webpack.js.org/configuration/dev-server/#devserveronaftersetupmiddleware"
571
- },
572
- "OnBeforeSetupMiddleware": {
573
- "instanceof": "Function",
574
- "description": "Provides the ability to execute a custom function and apply custom middleware(s) prior to all other middlewares. Deprecated: please use the 'setupMiddlewares' option.",
575
- "link": "https://webpack.js.org/configuration/dev-server/#devserveronbeforesetupmiddleware"
576
- },
577
370
  "OnListening": {
578
371
  "instanceof": "Function",
579
372
  "description": "Provides the ability to execute a custom function when dev server starts listening.",
@@ -666,7 +459,7 @@
666
459
  "minLength": 1,
667
460
  "description": "Open specified browser.",
668
461
  "cli": {
669
- "description": "Open specified browser. Deprecated: please use '--open-app-name'."
462
+ "exclude": true
670
463
  }
671
464
  }
672
465
  ],
@@ -697,24 +490,17 @@
697
490
  "link": "https://webpack.js.org/configuration/dev-server/#devserverport"
698
491
  },
699
492
  "Proxy": {
700
- "anyOf": [
701
- {
702
- "type": "object"
703
- },
704
- {
705
- "type": "array",
706
- "items": {
707
- "anyOf": [
708
- {
709
- "type": "object"
710
- },
711
- {
712
- "instanceof": "Function"
713
- }
714
- ]
493
+ "type": "array",
494
+ "items": {
495
+ "anyOf": [
496
+ {
497
+ "type": "object"
498
+ },
499
+ {
500
+ "instanceof": "Function"
715
501
  }
716
- }
717
- ],
502
+ ]
503
+ },
718
504
  "description": "Allows to proxy requests, can be useful when you have a separate API backend development server and you want to send API requests on the same domain.",
719
505
  "link": "https://webpack.js.org/configuration/dev-server/#devserverproxy"
720
506
  },
@@ -807,30 +593,6 @@
807
593
  ],
808
594
  "description": "Path to an SSL CA certificate or content of an SSL CA certificate."
809
595
  },
810
- "cacert": {
811
- "anyOf": [
812
- {
813
- "type": "array",
814
- "items": {
815
- "anyOf": [
816
- {
817
- "type": "string"
818
- },
819
- {
820
- "instanceof": "Buffer"
821
- }
822
- ]
823
- }
824
- },
825
- {
826
- "type": "string"
827
- },
828
- {
829
- "instanceof": "Buffer"
830
- }
831
- ],
832
- "description": "Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option."
833
- },
834
596
  "cert": {
835
597
  "anyOf": [
836
598
  {
@@ -1141,12 +903,12 @@
1141
903
  }
1142
904
  },
1143
905
  {
1144
- "$ref": "#/definitions/WebSocketServerType"
906
+ "enum": ["sockjs", "ws"],
907
+ "cli": {
908
+ "exclude": true
909
+ }
1145
910
  }
1146
- ],
1147
- "cli": {
1148
- "description": "Deprecated: please use '--web-socket-server-type' option."
1149
- }
911
+ ]
1150
912
  },
1151
913
  "WebSocketServerFunction": {
1152
914
  "instanceof": "Function"
@@ -1179,7 +941,10 @@
1179
941
  },
1180
942
  "WebSocketServerString": {
1181
943
  "type": "string",
1182
- "minLength": 1
944
+ "minLength": 1,
945
+ "cli": {
946
+ "exclude": true
947
+ }
1183
948
  }
1184
949
  },
1185
950
  "additionalProperties": false,
@@ -1211,27 +976,12 @@
1211
976
  "hot": {
1212
977
  "$ref": "#/definitions/Hot"
1213
978
  },
1214
- "http2": {
1215
- "$ref": "#/definitions/HTTP2"
1216
- },
1217
- "https": {
1218
- "$ref": "#/definitions/HTTPS"
1219
- },
1220
979
  "ipc": {
1221
980
  "$ref": "#/definitions/IPC"
1222
981
  },
1223
982
  "liveReload": {
1224
983
  "$ref": "#/definitions/LiveReload"
1225
984
  },
1226
- "magicHtml": {
1227
- "$ref": "#/definitions/MagicHTML"
1228
- },
1229
- "onAfterSetupMiddleware": {
1230
- "$ref": "#/definitions/OnAfterSetupMiddleware"
1231
- },
1232
- "onBeforeSetupMiddleware": {
1233
- "$ref": "#/definitions/OnBeforeSetupMiddleware"
1234
- },
1235
985
  "onListening": {
1236
986
  "$ref": "#/definitions/OnListening"
1237
987
  },
@@ -98,7 +98,7 @@ module.exports = class SockJSServer extends BaseServer {
98
98
 
99
99
  this.implementation.installHandlers(
100
100
  /** @type {import("http").Server} */ (this.server.server),
101
- options
101
+ options,
102
102
  );
103
103
 
104
104
  this.implementation.on("connection", (client) => {
@@ -113,7 +113,7 @@ module.exports = class SockJSServer extends BaseServer {
113
113
  client.on("close", () => {
114
114
  this.clients.splice(
115
115
  this.clients.indexOf(/** @type {ClientConnection} */ (client)),
116
- 1
116
+ 1,
117
117
  );
118
118
  });
119
119
  });
@@ -47,7 +47,7 @@ module.exports = class WebsocketServer extends BaseServer {
47
47
  this.implementation.handleUpgrade(req, sock, head, (connection) => {
48
48
  this.implementation.emit("connection", connection, req);
49
49
  });
50
- }
50
+ },
51
51
  );
52
52
 
53
53
  this.implementation.on(
@@ -57,7 +57,7 @@ module.exports = class WebsocketServer extends BaseServer {
57
57
  */
58
58
  (err) => {
59
59
  this.server.logger.error(err.message);
60
- }
60
+ },
61
61
  );
62
62
 
63
63
  const interval = setInterval(() => {
@@ -74,7 +74,7 @@ module.exports = class WebsocketServer extends BaseServer {
74
74
 
75
75
  client.isAlive = false;
76
76
  client.ping(() => {});
77
- }
77
+ },
78
78
  );
79
79
  }, WebsocketServer.heartbeatInterval);
80
80
 
@@ -95,7 +95,18 @@ module.exports = class WebsocketServer extends BaseServer {
95
95
  client.on("close", () => {
96
96
  this.clients.splice(this.clients.indexOf(client), 1);
97
97
  });
98
- }
98
+
99
+ // TODO: add a test case for this - https://github.com/webpack/webpack-dev-server/issues/5018
100
+ client.on(
101
+ "error",
102
+ /**
103
+ * @param {Error} err
104
+ */
105
+ (err) => {
106
+ this.server.logger.error(err.message);
107
+ },
108
+ );
109
+ },
99
110
  );
100
111
 
101
112
  this.implementation.on("close", () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack-dev-server",
3
- "version": "4.15.1",
3
+ "version": "5.0.1",
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",
@@ -21,120 +21,120 @@
21
21
  "types"
22
22
  ],
23
23
  "engines": {
24
- "node": ">= 12.13.0"
24
+ "node": ">= 18.12.0"
25
25
  },
26
26
  "scripts": {
27
27
  "fmt:check": "prettier \"{**/*,*}.{js,json,md,yml,css,ts}\" --list-different",
28
- "lint:js": "eslint . --cache",
28
+ "lint:prettier": "prettier --cache --list-different .",
29
+ "lint:js": "eslint --cache .",
29
30
  "lint:types": "tsc --pretty --noEmit",
30
- "lint": "npm-run-all -p \"fmt:**\" \"lint:**\"",
31
- "fmt": "npm run fmt:check -- --write",
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-run-all fix:js fmt",
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
- "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",
36
- "build:types": "rimraf ./types/* && tsc --declaration --emitDeclarationOnly --outDir types && node ./scripts/extend-webpack-types.js && prettier \"types/**/*.ts\" --write && prettier \"types/**/*.ts\" --write",
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",
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",
37
39
  "build": "npm-run-all -p \"build:**\"",
38
- "test:only": "jest",
40
+ "test:only": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
39
41
  "test:coverage": "npm run test:only -- --coverage",
40
42
  "test:watch": "npm run test:coverage --watch",
41
43
  "test": "npm run test:coverage",
42
44
  "pretest": "npm run lint",
43
- "prepare": "husky install && npm run build",
45
+ "prepare": "husky && npm run build",
44
46
  "release": "standard-version"
45
47
  },
46
48
  "dependencies": {
47
- "@types/bonjour": "^3.5.9",
48
- "@types/connect-history-api-fallback": "^1.3.5",
49
- "@types/express": "^4.17.13",
50
- "@types/serve-index": "^1.9.1",
51
- "@types/serve-static": "^1.13.10",
52
- "@types/sockjs": "^0.3.33",
53
- "@types/ws": "^8.5.5",
49
+ "@types/bonjour": "^3.5.13",
50
+ "@types/connect-history-api-fallback": "^1.5.4",
51
+ "@types/express": "^4.17.21",
52
+ "@types/serve-index": "^1.9.4",
53
+ "@types/serve-static": "^1.15.5",
54
+ "@types/sockjs": "^0.3.36",
55
+ "@types/ws": "^8.5.10",
54
56
  "ansi-html-community": "^0.0.8",
55
- "bonjour-service": "^1.0.11",
56
- "chokidar": "^3.5.3",
57
+ "bonjour-service": "^1.2.1",
58
+ "chokidar": "^3.6.0",
57
59
  "colorette": "^2.0.10",
58
60
  "compression": "^1.7.4",
59
61
  "connect-history-api-fallback": "^2.0.0",
60
62
  "default-gateway": "^6.0.3",
61
63
  "express": "^4.17.3",
62
64
  "graceful-fs": "^4.2.6",
63
- "html-entities": "^2.3.2",
65
+ "html-entities": "^2.4.0",
64
66
  "http-proxy-middleware": "^2.0.3",
65
- "ipaddr.js": "^2.0.1",
66
- "launch-editor": "^2.6.0",
67
- "open": "^8.0.9",
68
- "p-retry": "^4.5.0",
69
- "rimraf": "^3.0.2",
70
- "schema-utils": "^4.0.0",
71
- "selfsigned": "^2.1.1",
67
+ "ipaddr.js": "^2.1.0",
68
+ "launch-editor": "^2.6.1",
69
+ "open": "^10.0.3",
70
+ "p-retry": "^6.2.0",
71
+ "rimraf": "^5.0.5",
72
+ "schema-utils": "^4.2.0",
73
+ "selfsigned": "^2.4.1",
72
74
  "serve-index": "^1.9.1",
73
75
  "sockjs": "^0.3.24",
74
76
  "spdy": "^4.0.2",
75
- "webpack-dev-middleware": "^5.3.1",
76
- "ws": "^8.13.0"
77
+ "webpack-dev-middleware": "^7.0.0",
78
+ "ws": "^8.16.0"
77
79
  },
78
80
  "devDependencies": {
79
- "@babel/cli": "^7.17.3",
80
- "@babel/core": "^7.20.2",
81
- "@babel/eslint-parser": "^7.17.0",
82
- "@babel/plugin-transform-object-assign": "^7.14.5",
83
- "@babel/plugin-transform-runtime": "^7.17.0",
84
- "@babel/preset-env": "^7.20.2",
85
- "@babel/runtime": "^7.20.1",
86
- "@commitlint/cli": "^16.2.3",
87
- "@commitlint/config-conventional": "^16.2.1",
81
+ "@babel/cli": "^7.22.5",
82
+ "@babel/core": "^7.22.5",
83
+ "@babel/eslint-parser": "^7.22.5",
84
+ "@babel/plugin-transform-object-assign": "^7.22.5",
85
+ "@babel/plugin-transform-runtime": "^7.22.5",
86
+ "@babel/preset-env": "^7.22.5",
87
+ "@babel/runtime": "^7.22.5",
88
+ "@commitlint/cli": "^18.5.0",
89
+ "@commitlint/config-conventional": "^18.5.0",
88
90
  "@types/compression": "^1.7.2",
89
91
  "@types/default-gateway": "^3.0.1",
90
- "@types/node": "^18.11.9",
92
+ "@types/node": "^20.11.16",
91
93
  "@types/node-forge": "^1.3.1",
92
- "@types/rimraf": "^3.0.2",
93
94
  "@types/sockjs-client": "^1.5.1",
94
95
  "@types/trusted-types": "^2.0.2",
95
- "acorn": "^8.2.4",
96
- "babel-jest": "^28.1.3",
97
- "babel-loader": "^8.2.4",
96
+ "acorn": "^8.9.0",
97
+ "babel-jest": "^29.5.0",
98
+ "babel-loader": "^9.1.0",
98
99
  "body-parser": "^1.19.2",
99
- "core-js": "^3.21.1",
100
- "css-loader": "^5.2.4",
101
- "eslint": "^8.28.0",
102
- "eslint-config-prettier": "^8.4.0",
100
+ "core-js": "^3.31.0",
101
+ "cspell": "^8.3.2",
102
+ "css-loader": "^6.8.1",
103
+ "eslint": "^8.43.0",
104
+ "eslint-config-prettier": "^9.1.0",
103
105
  "eslint-config-webpack": "^1.2.5",
104
106
  "eslint-plugin-import": "^2.23.2",
105
107
  "execa": "^5.1.1",
106
- "file-loader": "^6.2.0",
107
- "html-webpack-plugin": "^4.5.2",
108
+ "html-webpack-plugin": "^5.5.3",
108
109
  "http-proxy": "^1.18.1",
109
- "husky": "^7.0.0",
110
- "jest": "^28.1.3",
111
- "jest-environment-jsdom": "^28.1.3",
110
+ "husky": "^9.0.10",
111
+ "jest": "^29.5.0",
112
+ "jest-environment-jsdom": "^29.5.0",
112
113
  "klona": "^2.0.4",
113
114
  "less": "^4.1.1",
114
- "less-loader": "^7.3.0",
115
- "lint-staged": "^12.3.4",
116
- "marked": "^4.2.3",
117
- "memfs": "^3.4.12",
115
+ "less-loader": "^12.1.0",
116
+ "lint-staged": "^15.2.0",
117
+ "marked": "^12.0.0",
118
+ "memfs": "^4.6.0",
118
119
  "npm-run-all": "^4.1.5",
119
- "prettier": "^2.8.0",
120
- "puppeteer": "^13.4.1",
120
+ "prettier": "^3.2.4",
121
+ "puppeteer": "^22.0.0",
122
+ "readable-stream": "^4.5.2",
121
123
  "require-from-string": "^2.0.2",
122
- "rimraf": "^3.0.2",
123
124
  "sockjs-client": "^1.6.1",
124
125
  "standard-version": "^9.3.0",
125
126
  "strip-ansi-v6": "npm:strip-ansi@^6.0.0",
126
- "style-loader": "^2.0.0",
127
+ "style-loader": "^3.3.1",
127
128
  "supertest": "^6.1.3",
128
129
  "tcp-port-used": "^1.0.2",
129
- "typescript": "^4.9.3",
130
- "url-loader": "^4.1.1",
130
+ "typescript": "^5.3.3",
131
131
  "wait-for-expect": "^3.0.2",
132
- "webpack": "^5.81.0",
133
- "webpack-cli": "^4.7.2",
134
- "webpack-merge": "^5.8.0"
132
+ "webpack": "^5.89.0",
133
+ "webpack-cli": "^5.0.1",
134
+ "webpack-merge": "^5.9.0"
135
135
  },
136
136
  "peerDependencies": {
137
- "webpack": "^4.37.0 || ^5.0.0"
137
+ "webpack": "^5.0.0"
138
138
  },
139
139
  "peerDependenciesMeta": {
140
140
  "webpack-cli": {