webpack-dev-server 5.0.2 → 5.0.3
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/Server.js +35 -42
- package/package.json +4 -4
- package/types/lib/Server.d.ts +40 -84
package/lib/Server.js
CHANGED
|
@@ -126,10 +126,6 @@ const schema = require("./options.json");
|
|
|
126
126
|
* @typedef {(ProxyConfigArrayItem | ((req?: Request | undefined, res?: Response | undefined, next?: NextFunction | undefined) => ProxyConfigArrayItem))[]} ProxyConfigArray
|
|
127
127
|
*/
|
|
128
128
|
|
|
129
|
-
/**
|
|
130
|
-
* @typedef {{ [url: string]: string | ProxyConfigArrayItem }} ProxyConfigMap
|
|
131
|
-
*/
|
|
132
|
-
|
|
133
129
|
/**
|
|
134
130
|
* @typedef {Object} OpenApp
|
|
135
131
|
* @property {string} [name]
|
|
@@ -198,7 +194,7 @@ const schema = require("./options.json");
|
|
|
198
194
|
* @property {boolean} [http2]
|
|
199
195
|
* @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server]
|
|
200
196
|
* @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer]
|
|
201
|
-
* @property {
|
|
197
|
+
* @property {ProxyConfigArray} [proxy]
|
|
202
198
|
* @property {boolean | string | Open | Array<string | Open>} [open]
|
|
203
199
|
* @property {boolean} [setupExitSignals]
|
|
204
200
|
* @property {boolean | ClientConfiguration} [client]
|
|
@@ -1317,48 +1313,45 @@ class Server {
|
|
|
1317
1313
|
* }
|
|
1318
1314
|
*/
|
|
1319
1315
|
if (typeof options.proxy !== "undefined") {
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
if (typeof item === "function") {
|
|
1325
|
-
return item;
|
|
1326
|
-
}
|
|
1316
|
+
options.proxy = options.proxy.map((item) => {
|
|
1317
|
+
if (typeof item === "function") {
|
|
1318
|
+
return item;
|
|
1319
|
+
}
|
|
1327
1320
|
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1321
|
+
/**
|
|
1322
|
+
* @param {"info" | "warn" | "error" | "debug" | "silent" | undefined | "none" | "log" | "verbose"} level
|
|
1323
|
+
* @returns {"info" | "warn" | "error" | "debug" | "silent" | undefined}
|
|
1324
|
+
*/
|
|
1325
|
+
const getLogLevelForProxy = (level) => {
|
|
1326
|
+
if (level === "none") {
|
|
1327
|
+
return "silent";
|
|
1328
|
+
}
|
|
1336
1329
|
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1330
|
+
if (level === "log") {
|
|
1331
|
+
return "info";
|
|
1332
|
+
}
|
|
1340
1333
|
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1334
|
+
if (level === "verbose") {
|
|
1335
|
+
return "debug";
|
|
1336
|
+
}
|
|
1344
1337
|
|
|
1345
|
-
|
|
1346
|
-
|
|
1338
|
+
return level;
|
|
1339
|
+
};
|
|
1347
1340
|
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1341
|
+
if (typeof item.logLevel === "undefined") {
|
|
1342
|
+
item.logLevel = getLogLevelForProxy(
|
|
1343
|
+
compilerOptions.infrastructureLogging
|
|
1344
|
+
? compilerOptions.infrastructureLogging.level
|
|
1345
|
+
: "info",
|
|
1346
|
+
);
|
|
1347
|
+
}
|
|
1355
1348
|
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1349
|
+
if (typeof item.logProvider === "undefined") {
|
|
1350
|
+
item.logProvider = () => this.logger;
|
|
1351
|
+
}
|
|
1359
1352
|
|
|
1360
|
-
|
|
1361
|
-
|
|
1353
|
+
return item;
|
|
1354
|
+
});
|
|
1362
1355
|
}
|
|
1363
1356
|
|
|
1364
1357
|
if (typeof options.setupExitSignals === "undefined") {
|
|
@@ -2045,8 +2038,7 @@ class Server {
|
|
|
2045
2038
|
* }
|
|
2046
2039
|
* ]
|
|
2047
2040
|
*/
|
|
2048
|
-
|
|
2049
|
-
(this.options.proxy).forEach((proxyConfigOrCallback) => {
|
|
2041
|
+
this.options.proxy.forEach((proxyConfigOrCallback) => {
|
|
2050
2042
|
/**
|
|
2051
2043
|
* @type {RequestHandler}
|
|
2052
2044
|
*/
|
|
@@ -2896,6 +2888,7 @@ class Server {
|
|
|
2896
2888
|
// allow if hostname is in allowedHosts
|
|
2897
2889
|
if (Array.isArray(allowedHosts) && allowedHosts.length > 0) {
|
|
2898
2890
|
for (let hostIdx = 0; hostIdx < allowedHosts.length; hostIdx++) {
|
|
2891
|
+
/** @type {string} */
|
|
2899
2892
|
const allowedHost = allowedHosts[hostIdx];
|
|
2900
2893
|
|
|
2901
2894
|
if (allowedHost === hostname) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack-dev-server",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
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",
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
"@babel/plugin-transform-runtime": "^7.22.5",
|
|
86
86
|
"@babel/preset-env": "^7.22.5",
|
|
87
87
|
"@babel/runtime": "^7.22.5",
|
|
88
|
-
"@commitlint/cli": "^
|
|
89
|
-
"@commitlint/config-conventional": "^
|
|
88
|
+
"@commitlint/cli": "^19.0.3",
|
|
89
|
+
"@commitlint/config-conventional": "^19.0.3",
|
|
90
90
|
"@types/compression": "^1.7.2",
|
|
91
91
|
"@types/default-gateway": "^3.0.1",
|
|
92
92
|
"@types/node": "^20.11.16",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"memfs": "^4.6.0",
|
|
119
119
|
"npm-run-all": "^4.1.5",
|
|
120
120
|
"prettier": "^3.2.4",
|
|
121
|
-
"puppeteer": "^22.
|
|
121
|
+
"puppeteer": "^22.1.0",
|
|
122
122
|
"readable-stream": "^4.5.2",
|
|
123
123
|
"require-from-string": "^2.0.2",
|
|
124
124
|
"sockjs-client": "^1.6.1",
|
package/types/lib/Server.d.ts
CHANGED
|
@@ -153,9 +153,6 @@ declare class Server {
|
|
|
153
153
|
/**
|
|
154
154
|
* @typedef {(ProxyConfigArrayItem | ((req?: Request | undefined, res?: Response | undefined, next?: NextFunction | undefined) => ProxyConfigArrayItem))[]} ProxyConfigArray
|
|
155
155
|
*/
|
|
156
|
-
/**
|
|
157
|
-
* @typedef {{ [url: string]: string | ProxyConfigArrayItem }} ProxyConfigMap
|
|
158
|
-
*/
|
|
159
156
|
/**
|
|
160
157
|
* @typedef {Object} OpenApp
|
|
161
158
|
* @property {string} [name]
|
|
@@ -216,7 +213,7 @@ declare class Server {
|
|
|
216
213
|
* @property {boolean} [http2]
|
|
217
214
|
* @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server]
|
|
218
215
|
* @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer]
|
|
219
|
-
* @property {
|
|
216
|
+
* @property {ProxyConfigArray} [proxy]
|
|
220
217
|
* @property {boolean | string | Open | Array<string | Open>} [open]
|
|
221
218
|
* @property {boolean} [setupExitSignals]
|
|
222
219
|
* @property {boolean | ClientConfiguration} [client]
|
|
@@ -323,69 +320,6 @@ declare class Server {
|
|
|
323
320
|
)[];
|
|
324
321
|
};
|
|
325
322
|
trustedTypesPolicyName: {
|
|
326
|
-
/**
|
|
327
|
-
* @typedef {Object} Open
|
|
328
|
-
* @property {string | string[] | OpenApp} [app]
|
|
329
|
-
* @property {string | string[]} [target]
|
|
330
|
-
*/
|
|
331
|
-
/**
|
|
332
|
-
* @typedef {Object} NormalizedOpen
|
|
333
|
-
* @property {string} target
|
|
334
|
-
* @property {import("open").Options} options
|
|
335
|
-
*/
|
|
336
|
-
/**
|
|
337
|
-
* @typedef {Object} WebSocketURL
|
|
338
|
-
* @property {string} [hostname]
|
|
339
|
-
* @property {string} [password]
|
|
340
|
-
* @property {string} [pathname]
|
|
341
|
-
* @property {number | string} [port]
|
|
342
|
-
* @property {string} [protocol]
|
|
343
|
-
* @property {string} [username]
|
|
344
|
-
*/
|
|
345
|
-
/**
|
|
346
|
-
* @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions
|
|
347
|
-
*/
|
|
348
|
-
/**
|
|
349
|
-
* @typedef {Object} ClientConfiguration
|
|
350
|
-
* @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging]
|
|
351
|
-
* @property {boolean | { warnings?: OverlayMessageOptions, errors?: OverlayMessageOptions, runtimeErrors?: OverlayMessageOptions }} [overlay]
|
|
352
|
-
* @property {boolean} [progress]
|
|
353
|
-
* @property {boolean | number} [reconnect]
|
|
354
|
-
* @property {"ws" | "sockjs" | string} [webSocketTransport]
|
|
355
|
-
* @property {string | WebSocketURL} [webSocketURL]
|
|
356
|
-
*/
|
|
357
|
-
/**
|
|
358
|
-
* @typedef {Array<{ key: string; value: string }> | Record<string, string | string[]>} Headers
|
|
359
|
-
*/
|
|
360
|
-
/**
|
|
361
|
-
* @typedef {{ name?: string, path?: string, middleware: ExpressRequestHandler | ExpressErrorRequestHandler } | ExpressRequestHandler | ExpressErrorRequestHandler} Middleware
|
|
362
|
-
*/
|
|
363
|
-
/**
|
|
364
|
-
* @typedef {Object} Configuration
|
|
365
|
-
* @property {boolean | string} [ipc]
|
|
366
|
-
* @property {Host} [host]
|
|
367
|
-
* @property {Port} [port]
|
|
368
|
-
* @property {boolean | "only"} [hot]
|
|
369
|
-
* @property {boolean} [liveReload]
|
|
370
|
-
* @property {DevMiddlewareOptions<Request, Response>} [devMiddleware]
|
|
371
|
-
* @property {boolean} [compress]
|
|
372
|
-
* @property {"auto" | "all" | string | string[]} [allowedHosts]
|
|
373
|
-
* @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback]
|
|
374
|
-
* @property {boolean | Record<string, never> | BonjourOptions} [bonjour]
|
|
375
|
-
* @property {string | string[] | WatchFiles | Array<string | WatchFiles>} [watchFiles]
|
|
376
|
-
* @property {boolean | string | Static | Array<string | Static>} [static]
|
|
377
|
-
* @property {boolean | ServerOptions} [https]
|
|
378
|
-
* @property {boolean} [http2]
|
|
379
|
-
* @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server]
|
|
380
|
-
* @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer]
|
|
381
|
-
* @property {ProxyConfigMap | ProxyConfigArrayItem | ProxyConfigArray} [proxy]
|
|
382
|
-
* @property {boolean | string | Open | Array<string | Open>} [open]
|
|
383
|
-
* @property {boolean} [setupExitSignals]
|
|
384
|
-
* @property {boolean | ClientConfiguration} [client]
|
|
385
|
-
* @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response>) => Headers)} [headers]
|
|
386
|
-
* @property {(devServer: Server) => void} [onListening]
|
|
387
|
-
* @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares]
|
|
388
|
-
*/
|
|
389
323
|
description: string;
|
|
390
324
|
type: string;
|
|
391
325
|
};
|
|
@@ -423,6 +357,35 @@ declare class Server {
|
|
|
423
357
|
)[];
|
|
424
358
|
};
|
|
425
359
|
ClientWebSocketTransport: {
|
|
360
|
+
/**
|
|
361
|
+
* @typedef {{ name?: string, path?: string, middleware: ExpressRequestHandler | ExpressErrorRequestHandler } | ExpressRequestHandler | ExpressErrorRequestHandler} Middleware
|
|
362
|
+
*/
|
|
363
|
+
/**
|
|
364
|
+
* @typedef {Object} Configuration
|
|
365
|
+
* @property {boolean | string} [ipc]
|
|
366
|
+
* @property {Host} [host]
|
|
367
|
+
* @property {Port} [port]
|
|
368
|
+
* @property {boolean | "only"} [hot]
|
|
369
|
+
* @property {boolean} [liveReload]
|
|
370
|
+
* @property {DevMiddlewareOptions<Request, Response>} [devMiddleware]
|
|
371
|
+
* @property {boolean} [compress]
|
|
372
|
+
* @property {"auto" | "all" | string | string[]} [allowedHosts]
|
|
373
|
+
* @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback]
|
|
374
|
+
* @property {boolean | Record<string, never> | BonjourOptions} [bonjour]
|
|
375
|
+
* @property {string | string[] | WatchFiles | Array<string | WatchFiles>} [watchFiles]
|
|
376
|
+
* @property {boolean | string | Static | Array<string | Static>} [static]
|
|
377
|
+
* @property {boolean | ServerOptions} [https]
|
|
378
|
+
* @property {boolean} [http2]
|
|
379
|
+
* @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server]
|
|
380
|
+
* @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer]
|
|
381
|
+
* @property {ProxyConfigArray} [proxy]
|
|
382
|
+
* @property {boolean | string | Open | Array<string | Open>} [open]
|
|
383
|
+
* @property {boolean} [setupExitSignals]
|
|
384
|
+
* @property {boolean | ClientConfiguration} [client]
|
|
385
|
+
* @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response>) => Headers)} [headers]
|
|
386
|
+
* @property {(devServer: Server) => void} [onListening]
|
|
387
|
+
* @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares]
|
|
388
|
+
*/
|
|
426
389
|
anyOf: {
|
|
427
390
|
$ref: string;
|
|
428
391
|
}[];
|
|
@@ -516,6 +479,9 @@ declare class Server {
|
|
|
516
479
|
};
|
|
517
480
|
HeaderObject: {
|
|
518
481
|
type: string;
|
|
482
|
+
/**
|
|
483
|
+
* @type {FSWatcher[]}
|
|
484
|
+
*/
|
|
519
485
|
additionalProperties: boolean;
|
|
520
486
|
properties: {
|
|
521
487
|
key: {
|
|
@@ -539,9 +505,6 @@ declare class Server {
|
|
|
539
505
|
$ref: string;
|
|
540
506
|
};
|
|
541
507
|
minItems: number;
|
|
542
|
-
/**
|
|
543
|
-
* @type {Socket[]}
|
|
544
|
-
*/
|
|
545
508
|
instanceof?: undefined;
|
|
546
509
|
}
|
|
547
510
|
| {
|
|
@@ -641,11 +604,6 @@ declare class Server {
|
|
|
641
604
|
OnListening: {
|
|
642
605
|
instanceof: string;
|
|
643
606
|
description: string;
|
|
644
|
-
/**
|
|
645
|
-
* @param {Port} port
|
|
646
|
-
* @param {string} host
|
|
647
|
-
* @returns {Promise<number | string>}
|
|
648
|
-
*/
|
|
649
607
|
link: string;
|
|
650
608
|
};
|
|
651
609
|
Open: {
|
|
@@ -773,7 +731,7 @@ declare class Server {
|
|
|
773
731
|
}
|
|
774
732
|
)[];
|
|
775
733
|
description: string;
|
|
776
|
-
link: string
|
|
734
|
+
link: string /** @type {WebSocketURL} */;
|
|
777
735
|
};
|
|
778
736
|
Proxy: {
|
|
779
737
|
type: string;
|
|
@@ -781,11 +739,12 @@ declare class Server {
|
|
|
781
739
|
anyOf: (
|
|
782
740
|
| {
|
|
783
741
|
type: string;
|
|
784
|
-
|
|
742
|
+
instanceof?: undefined;
|
|
785
743
|
}
|
|
786
744
|
| {
|
|
787
745
|
instanceof: string;
|
|
788
|
-
/** @type {
|
|
746
|
+
/** @type {{ type: WebSocketServerConfiguration["type"], options: NonNullable<WebSocketServerConfiguration["options"]> }} */
|
|
747
|
+
type?: undefined;
|
|
789
748
|
}
|
|
790
749
|
)[];
|
|
791
750
|
};
|
|
@@ -811,6 +770,7 @@ declare class Server {
|
|
|
811
770
|
ServerString: {
|
|
812
771
|
type: string;
|
|
813
772
|
minLength: number;
|
|
773
|
+
/** @type {string} */
|
|
814
774
|
cli: {
|
|
815
775
|
exclude: boolean;
|
|
816
776
|
};
|
|
@@ -1190,7 +1150,7 @@ declare class Server {
|
|
|
1190
1150
|
};
|
|
1191
1151
|
WatchFilesString: {
|
|
1192
1152
|
type: string;
|
|
1193
|
-
|
|
1153
|
+
minLength: number;
|
|
1194
1154
|
};
|
|
1195
1155
|
WebSocketServer: {
|
|
1196
1156
|
anyOf: {
|
|
@@ -1652,7 +1612,6 @@ declare namespace Server {
|
|
|
1652
1612
|
ByPass,
|
|
1653
1613
|
ProxyConfigArrayItem,
|
|
1654
1614
|
ProxyConfigArray,
|
|
1655
|
-
ProxyConfigMap,
|
|
1656
1615
|
OpenApp,
|
|
1657
1616
|
Open,
|
|
1658
1617
|
NormalizedOpen,
|
|
@@ -1810,9 +1769,6 @@ type ProxyConfigArray = (
|
|
|
1810
1769
|
next?: NextFunction | undefined,
|
|
1811
1770
|
) => ProxyConfigArrayItem)
|
|
1812
1771
|
)[];
|
|
1813
|
-
type ProxyConfigMap = {
|
|
1814
|
-
[url: string]: string | ProxyConfigArrayItem;
|
|
1815
|
-
};
|
|
1816
1772
|
type OpenApp = {
|
|
1817
1773
|
name?: string | undefined;
|
|
1818
1774
|
arguments?: string[] | undefined;
|
|
@@ -1903,7 +1859,7 @@ type Configuration = {
|
|
|
1903
1859
|
http2?: boolean | undefined;
|
|
1904
1860
|
server?: string | ServerConfiguration | undefined;
|
|
1905
1861
|
webSocketServer?: string | boolean | WebSocketServerConfiguration | undefined;
|
|
1906
|
-
proxy?:
|
|
1862
|
+
proxy?: ProxyConfigArray | undefined;
|
|
1907
1863
|
open?: string | boolean | Open | (string | Open)[] | undefined;
|
|
1908
1864
|
setupExitSignals?: boolean | undefined;
|
|
1909
1865
|
client?: boolean | ClientConfiguration | undefined;
|