webpack-dev-server 5.0.1 → 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 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, Response
47
- * @typedef {import("webpack-dev-middleware").Options<IncomingMessage, ServerResponse>} DevMiddlewareOptions
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, Response
52
- * @typedef {import("webpack-dev-middleware").Context<IncomingMessage, ServerResponse>} DevMiddlewareContext
53
+ * @template {Request} T
54
+ * @template {Response} U
55
+ * @typedef {import("webpack-dev-middleware").Context<T, U>} DevMiddlewareContext
53
56
  */
54
57
 
55
58
  /**
@@ -123,10 +126,6 @@ const schema = require("./options.json");
123
126
  * @typedef {(ProxyConfigArrayItem | ((req?: Request | undefined, res?: Response | undefined, next?: NextFunction | undefined) => ProxyConfigArrayItem))[]} ProxyConfigArray
124
127
  */
125
128
 
126
- /**
127
- * @typedef {{ [url: string]: string | ProxyConfigArrayItem }} ProxyConfigMap
128
- */
129
-
130
129
  /**
131
130
  * @typedef {Object} OpenApp
132
131
  * @property {string} [name]
@@ -195,7 +194,7 @@ const schema = require("./options.json");
195
194
  * @property {boolean} [http2]
196
195
  * @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server]
197
196
  * @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer]
198
- * @property {ProxyConfigMap | ProxyConfigArrayItem | ProxyConfigArray} [proxy]
197
+ * @property {ProxyConfigArray} [proxy]
199
198
  * @property {boolean | string | Open | Array<string | Open>} [open]
200
199
  * @property {boolean} [setupExitSignals]
201
200
  * @property {boolean | ClientConfiguration} [client]
@@ -1314,48 +1313,45 @@ class Server {
1314
1313
  * }
1315
1314
  */
1316
1315
  if (typeof options.proxy !== "undefined") {
1317
- /** @type {ProxyConfigArray} */
1318
- (options.proxy) =
1319
- /** @type {ProxyConfigArray} */
1320
- (options.proxy).map((item) => {
1321
- if (typeof item === "function") {
1322
- return item;
1323
- }
1316
+ options.proxy = options.proxy.map((item) => {
1317
+ if (typeof item === "function") {
1318
+ return item;
1319
+ }
1324
1320
 
1325
- /**
1326
- * @param {"info" | "warn" | "error" | "debug" | "silent" | undefined | "none" | "log" | "verbose"} level
1327
- * @returns {"info" | "warn" | "error" | "debug" | "silent" | undefined}
1328
- */
1329
- const getLogLevelForProxy = (level) => {
1330
- if (level === "none") {
1331
- return "silent";
1332
- }
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
+ }
1333
1329
 
1334
- if (level === "log") {
1335
- return "info";
1336
- }
1330
+ if (level === "log") {
1331
+ return "info";
1332
+ }
1337
1333
 
1338
- if (level === "verbose") {
1339
- return "debug";
1340
- }
1334
+ if (level === "verbose") {
1335
+ return "debug";
1336
+ }
1341
1337
 
1342
- return level;
1343
- };
1338
+ return level;
1339
+ };
1344
1340
 
1345
- if (typeof item.logLevel === "undefined") {
1346
- item.logLevel = getLogLevelForProxy(
1347
- compilerOptions.infrastructureLogging
1348
- ? compilerOptions.infrastructureLogging.level
1349
- : "info",
1350
- );
1351
- }
1341
+ if (typeof item.logLevel === "undefined") {
1342
+ item.logLevel = getLogLevelForProxy(
1343
+ compilerOptions.infrastructureLogging
1344
+ ? compilerOptions.infrastructureLogging.level
1345
+ : "info",
1346
+ );
1347
+ }
1352
1348
 
1353
- if (typeof item.logProvider === "undefined") {
1354
- item.logProvider = () => this.logger;
1355
- }
1349
+ if (typeof item.logProvider === "undefined") {
1350
+ item.logProvider = () => this.logger;
1351
+ }
1356
1352
 
1357
- return item;
1358
- });
1353
+ return item;
1354
+ });
1359
1355
  }
1360
1356
 
1361
1357
  if (typeof options.setupExitSignals === "undefined") {
@@ -1841,36 +1837,20 @@ class Server {
1841
1837
  const { app, middleware } = this;
1842
1838
 
1843
1839
  /** @type {import("express").Application} */
1844
- (app).get(
1845
- "/__webpack_dev_server__/sockjs.bundle.js",
1846
- /**
1847
- * @param {Request} req
1848
- * @param {Response} res
1849
- * @returns {void}
1850
- */
1851
- (req, res) => {
1852
- res.setHeader("Content-Type", "application/javascript");
1840
+ (app).get("/__webpack_dev_server__/sockjs.bundle.js", (req, res) => {
1841
+ res.setHeader("Content-Type", "application/javascript");
1853
1842
 
1854
- const clientPath = path.join(__dirname, "..", "client");
1843
+ const clientPath = path.join(__dirname, "..", "client");
1855
1844
 
1856
- res.sendFile(path.join(clientPath, "modules/sockjs-client/index.js"));
1857
- },
1858
- );
1845
+ res.sendFile(path.join(clientPath, "modules/sockjs-client/index.js"));
1846
+ });
1859
1847
 
1860
1848
  /** @type {import("express").Application} */
1861
- (app).get(
1862
- "/webpack-dev-server/invalidate",
1863
- /**
1864
- * @param {Request} _req
1865
- * @param {Response} res
1866
- * @returns {void}
1867
- */
1868
- (_req, res) => {
1869
- this.invalidate();
1849
+ (app).get("/webpack-dev-server/invalidate", (_req, res) => {
1850
+ this.invalidate();
1870
1851
 
1871
- res.end();
1872
- },
1873
- );
1852
+ res.end();
1853
+ });
1874
1854
 
1875
1855
  /** @type {import("express").Application} */
1876
1856
  (app).get("/webpack-dev-server/open-editor", (req, res) => {
@@ -1886,74 +1866,65 @@ class Server {
1886
1866
  });
1887
1867
 
1888
1868
  /** @type {import("express").Application} */
1889
- (app).get(
1890
- "/webpack-dev-server",
1891
- /**
1892
- * @param {Request} req
1893
- * @param {Response} res
1894
- * @returns {void}
1895
- */
1896
- (req, res) => {
1897
- /** @type {import("webpack-dev-middleware").API<Request, Response>}*/
1898
- (middleware).waitUntilValid((stats) => {
1899
- res.setHeader("Content-Type", "text/html");
1900
- // HEAD requests should not return body content
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
- );
1869
+ (app).get("/webpack-dev-server", (req, res) => {
1870
+ /** @type {import("webpack-dev-middleware").API<Request, Response>}*/
1871
+ (middleware).waitUntilValid((stats) => {
1872
+ res.setHeader("Content-Type", "text/html");
1873
+ // HEAD requests should not return body content
1874
+ if (req.method === "HEAD") {
1875
+ res.end();
1876
+ return;
1877
+ }
1878
+ res.write(
1879
+ '<!DOCTYPE html><html><head><meta charset="utf-8"/></head><body>',
1880
+ );
1881
+
1882
+ const statsForPrint =
1883
+ typeof (/** @type {MultiStats} */ (stats).stats) !== "undefined"
1884
+ ? /** @type {MultiStats} */ (stats).toJson().children
1885
+ : [/** @type {Stats} */ (stats).toJson()];
1886
+
1887
+ res.write(`<h1>Assets Report:</h1>`);
1908
1888
 
1909
- const statsForPrint =
1910
- typeof (/** @type {MultiStats} */ (stats).stats) !== "undefined"
1911
- ? /** @type {MultiStats} */ (stats).toJson().children
1912
- : [/** @type {Stats} */ (stats).toJson()];
1913
-
1914
- res.write(`<h1>Assets Report:</h1>`);
1915
-
1916
- /**
1917
- * @type {StatsCompilation[]}
1918
- */
1919
- (statsForPrint).forEach((item, index) => {
1920
- res.write("<div>");
1921
-
1922
- const name =
1923
- // eslint-disable-next-line no-nested-ternary
1924
- typeof item.name !== "undefined"
1925
- ? item.name
1926
- : /** @type {MultiStats} */ (stats).stats
1927
- ? `unnamed[${index}]`
1928
- : "unnamed";
1929
-
1930
- res.write(`<h2>Compilation: ${name}</h2>`);
1931
- res.write("<ul>");
1932
-
1933
- const publicPath =
1934
- item.publicPath === "auto" ? "" : item.publicPath;
1935
-
1936
- for (const asset of /** @type {NonNullable<StatsCompilation["assets"]>} */ (
1937
- item.assets
1938
- )) {
1939
- const assetName = asset.name;
1940
- const assetURL = `${publicPath}${assetName}`;
1941
-
1942
- res.write(
1943
- `<li>
1889
+ /**
1890
+ * @type {StatsCompilation[]}
1891
+ */
1892
+ (statsForPrint).forEach((item, index) => {
1893
+ res.write("<div>");
1894
+
1895
+ const name =
1896
+ // eslint-disable-next-line no-nested-ternary
1897
+ typeof item.name !== "undefined"
1898
+ ? item.name
1899
+ : /** @type {MultiStats} */ (stats).stats
1900
+ ? `unnamed[${index}]`
1901
+ : "unnamed";
1902
+
1903
+ res.write(`<h2>Compilation: ${name}</h2>`);
1904
+ res.write("<ul>");
1905
+
1906
+ const publicPath = item.publicPath === "auto" ? "" : item.publicPath;
1907
+
1908
+ for (const asset of /** @type {NonNullable<StatsCompilation["assets"]>} */ (
1909
+ item.assets
1910
+ )) {
1911
+ const assetName = asset.name;
1912
+ const assetURL = `${publicPath}${assetName}`;
1913
+
1914
+ res.write(
1915
+ `<li>
1944
1916
  <strong><a href="${assetURL}" target="_blank">${assetName}</a></strong>
1945
1917
  </li>`,
1946
- );
1947
- }
1948
-
1949
- res.write("</ul>");
1950
- res.write("</div>");
1951
- });
1918
+ );
1919
+ }
1952
1920
 
1953
- res.end("</body></html>");
1921
+ res.write("</ul>");
1922
+ res.write("</div>");
1954
1923
  });
1955
- },
1956
- );
1924
+
1925
+ res.end("</body></html>");
1926
+ });
1927
+ });
1957
1928
  }
1958
1929
 
1959
1930
  /**
@@ -2067,8 +2038,7 @@ class Server {
2067
2038
  * }
2068
2039
  * ]
2069
2040
  */
2070
- /** @type {ProxyConfigArray} */
2071
- (this.options.proxy).forEach((proxyConfigOrCallback) => {
2041
+ this.options.proxy.forEach((proxyConfigOrCallback) => {
2072
2042
  /**
2073
2043
  * @type {RequestHandler}
2074
2044
  */
@@ -2918,6 +2888,7 @@ class Server {
2918
2888
  // allow if hostname is in allowedHosts
2919
2889
  if (Array.isArray(allowedHosts) && allowedHosts.length > 0) {
2920
2890
  for (let hostIdx = 0; hostIdx < allowedHosts.length; hostIdx++) {
2891
+ /** @type {string} */
2921
2892
  const allowedHost = allowedHosts[hostIdx];
2922
2893
 
2923
2894
  if (allowedHost === hostname) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack-dev-server",
3
- "version": "5.0.1",
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": "^18.5.0",
89
- "@commitlint/config-conventional": "^18.5.0",
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.0.0",
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",
@@ -49,14 +49,14 @@ declare class Server {
49
49
  link?: undefined;
50
50
  }
51
51
  | {
52
- type: string;
52
+ type: string /** @typedef {import("express").ErrorRequestHandler} ExpressErrorRequestHandler */;
53
53
  description: string;
54
54
  link: string;
55
55
  cli?: undefined;
56
56
  }
57
57
  )[];
58
58
  description: string;
59
- link: string /** @typedef {import("connect-history-api-fallback").Options} ConnectHistoryApiFallbackOptions */;
59
+ link: string;
60
60
  };
61
61
  Client: {
62
62
  description: string;
@@ -78,6 +78,149 @@ declare class Server {
78
78
  logging: {
79
79
  $ref: string;
80
80
  };
81
+ /** @typedef {import("net").Socket} Socket */
82
+ /** @typedef {import("http").IncomingMessage} IncomingMessage */
83
+ /** @typedef {import("http").ServerResponse} ServerResponse */
84
+ /** @typedef {import("open").Options} OpenOptions */
85
+ /** @typedef {import("https").ServerOptions & { spdy?: { plain?: boolean | undefined, ssl?: boolean | undefined, 'x-forwarded-for'?: string | undefined, protocol?: string | undefined, protocols?: string[] | undefined }}} ServerOptions */
86
+ /** @typedef {import("express").Request} Request */
87
+ /** @typedef {import("express").Response} Response */
88
+ /**
89
+ * @template {Request} T
90
+ * @template {Response} U
91
+ * @typedef {import("webpack-dev-middleware").Options<T, U>} DevMiddlewareOptions
92
+ */
93
+ /**
94
+ * @template {Request} T
95
+ * @template {Response} U
96
+ * @typedef {import("webpack-dev-middleware").Context<T, U>} DevMiddlewareContext
97
+ */
98
+ /**
99
+ * @typedef {"local-ip" | "local-ipv4" | "local-ipv6" | string} Host
100
+ */
101
+ /**
102
+ * @typedef {number | string | "auto"} Port
103
+ */
104
+ /**
105
+ * @typedef {Object} WatchFiles
106
+ * @property {string | string[]} paths
107
+ * @property {WatchOptions & { aggregateTimeout?: number, ignored?: WatchOptions["ignored"], poll?: number | boolean }} [options]
108
+ */
109
+ /**
110
+ * @typedef {Object} Static
111
+ * @property {string} [directory]
112
+ * @property {string | string[]} [publicPath]
113
+ * @property {boolean | ServeIndexOptions} [serveIndex]
114
+ * @property {ServeStaticOptions} [staticOptions]
115
+ * @property {boolean | WatchOptions & { aggregateTimeout?: number, ignored?: WatchOptions["ignored"], poll?: number | boolean }} [watch]
116
+ */
117
+ /**
118
+ * @typedef {Object} NormalizedStatic
119
+ * @property {string} directory
120
+ * @property {string[]} publicPath
121
+ * @property {false | ServeIndexOptions} serveIndex
122
+ * @property {ServeStaticOptions} staticOptions
123
+ * @property {false | WatchOptions} watch
124
+ */
125
+ /**
126
+ * @typedef {Object} ServerConfiguration
127
+ * @property {"http" | "https" | "spdy" | string} [type]
128
+ * @property {ServerOptions} [options]
129
+ */
130
+ /**
131
+ * @typedef {Object} WebSocketServerConfiguration
132
+ * @property {"sockjs" | "ws" | string | Function} [type]
133
+ * @property {Record<string, any>} [options]
134
+ */
135
+ /**
136
+ * @typedef {(import("ws").WebSocket | import("sockjs").Connection & { send: import("ws").WebSocket["send"], terminate: import("ws").WebSocket["terminate"], ping: import("ws").WebSocket["ping"] }) & { isAlive?: boolean }} ClientConnection
137
+ */
138
+ /**
139
+ * @typedef {import("ws").WebSocketServer | import("sockjs").Server & { close: import("ws").WebSocketServer["close"] }} WebSocketServer
140
+ */
141
+ /**
142
+ * @typedef {{ implementation: WebSocketServer, clients: ClientConnection[] }} WebSocketServerImplementation
143
+ */
144
+ /**
145
+ * @callback ByPass
146
+ * @param {Request} req
147
+ * @param {Response} res
148
+ * @param {ProxyConfigArrayItem} proxyConfig
149
+ */
150
+ /**
151
+ * @typedef {{ path?: HttpProxyMiddlewareOptionsFilter | undefined, context?: HttpProxyMiddlewareOptionsFilter | undefined } & { bypass?: ByPass } & HttpProxyMiddlewareOptions } ProxyConfigArrayItem
152
+ */
153
+ /**
154
+ * @typedef {(ProxyConfigArrayItem | ((req?: Request | undefined, res?: Response | undefined, next?: NextFunction | undefined) => ProxyConfigArrayItem))[]} ProxyConfigArray
155
+ */
156
+ /**
157
+ * @typedef {Object} OpenApp
158
+ * @property {string} [name]
159
+ * @property {string[]} [arguments]
160
+ */
161
+ /**
162
+ * @typedef {Object} Open
163
+ * @property {string | string[] | OpenApp} [app]
164
+ * @property {string | string[]} [target]
165
+ */
166
+ /**
167
+ * @typedef {Object} NormalizedOpen
168
+ * @property {string} target
169
+ * @property {import("open").Options} options
170
+ */
171
+ /**
172
+ * @typedef {Object} WebSocketURL
173
+ * @property {string} [hostname]
174
+ * @property {string} [password]
175
+ * @property {string} [pathname]
176
+ * @property {number | string} [port]
177
+ * @property {string} [protocol]
178
+ * @property {string} [username]
179
+ */
180
+ /**
181
+ * @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions
182
+ */
183
+ /**
184
+ * @typedef {Object} ClientConfiguration
185
+ * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging]
186
+ * @property {boolean | { warnings?: OverlayMessageOptions, errors?: OverlayMessageOptions, runtimeErrors?: OverlayMessageOptions }} [overlay]
187
+ * @property {boolean} [progress]
188
+ * @property {boolean | number} [reconnect]
189
+ * @property {"ws" | "sockjs" | string} [webSocketTransport]
190
+ * @property {string | WebSocketURL} [webSocketURL]
191
+ */
192
+ /**
193
+ * @typedef {Array<{ key: string; value: string }> | Record<string, string | string[]>} Headers
194
+ */
195
+ /**
196
+ * @typedef {{ name?: string, path?: string, middleware: ExpressRequestHandler | ExpressErrorRequestHandler } | ExpressRequestHandler | ExpressErrorRequestHandler} Middleware
197
+ */
198
+ /**
199
+ * @typedef {Object} Configuration
200
+ * @property {boolean | string} [ipc]
201
+ * @property {Host} [host]
202
+ * @property {Port} [port]
203
+ * @property {boolean | "only"} [hot]
204
+ * @property {boolean} [liveReload]
205
+ * @property {DevMiddlewareOptions<Request, Response>} [devMiddleware]
206
+ * @property {boolean} [compress]
207
+ * @property {"auto" | "all" | string | string[]} [allowedHosts]
208
+ * @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback]
209
+ * @property {boolean | Record<string, never> | BonjourOptions} [bonjour]
210
+ * @property {string | string[] | WatchFiles | Array<string | WatchFiles>} [watchFiles]
211
+ * @property {boolean | string | Static | Array<string | Static>} [static]
212
+ * @property {boolean | ServerOptions} [https]
213
+ * @property {boolean} [http2]
214
+ * @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server]
215
+ * @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer]
216
+ * @property {ProxyConfigArray} [proxy]
217
+ * @property {boolean | string | Open | Array<string | Open>} [open]
218
+ * @property {boolean} [setupExitSignals]
219
+ * @property {boolean | ClientConfiguration} [client]
220
+ * @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response>) => Headers)} [headers]
221
+ * @property {(devServer: Server) => void} [onListening]
222
+ * @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares]
223
+ */
81
224
  overlay: {
82
225
  $ref: string;
83
226
  };
@@ -104,139 +247,6 @@ declare class Server {
104
247
  description: string;
105
248
  link: string;
106
249
  };
107
- /**
108
- * @template Request, Response
109
- * @typedef {import("webpack-dev-middleware").Context<IncomingMessage, ServerResponse>} DevMiddlewareContext
110
- */
111
- /**
112
- * @typedef {"local-ip" | "local-ipv4" | "local-ipv6" | string} Host
113
- */
114
- /**
115
- * @typedef {number | string | "auto"} Port
116
- */
117
- /**
118
- * @typedef {Object} WatchFiles
119
- * @property {string | string[]} paths
120
- * @property {WatchOptions & { aggregateTimeout?: number, ignored?: WatchOptions["ignored"], poll?: number | boolean }} [options]
121
- */
122
- /**
123
- * @typedef {Object} Static
124
- * @property {string} [directory]
125
- * @property {string | string[]} [publicPath]
126
- * @property {boolean | ServeIndexOptions} [serveIndex]
127
- * @property {ServeStaticOptions} [staticOptions]
128
- * @property {boolean | WatchOptions & { aggregateTimeout?: number, ignored?: WatchOptions["ignored"], poll?: number | boolean }} [watch]
129
- */
130
- /**
131
- * @typedef {Object} NormalizedStatic
132
- * @property {string} directory
133
- * @property {string[]} publicPath
134
- * @property {false | ServeIndexOptions} serveIndex
135
- * @property {ServeStaticOptions} staticOptions
136
- * @property {false | WatchOptions} watch
137
- */
138
- /**
139
- * @typedef {Object} ServerConfiguration
140
- * @property {"http" | "https" | "spdy" | string} [type]
141
- * @property {ServerOptions} [options]
142
- */
143
- /**
144
- * @typedef {Object} WebSocketServerConfiguration
145
- * @property {"sockjs" | "ws" | string | Function} [type]
146
- * @property {Record<string, any>} [options]
147
- */
148
- /**
149
- * @typedef {(import("ws").WebSocket | import("sockjs").Connection & { send: import("ws").WebSocket["send"], terminate: import("ws").WebSocket["terminate"], ping: import("ws").WebSocket["ping"] }) & { isAlive?: boolean }} ClientConnection
150
- */
151
- /**
152
- * @typedef {import("ws").WebSocketServer | import("sockjs").Server & { close: import("ws").WebSocketServer["close"] }} WebSocketServer
153
- */
154
- /**
155
- * @typedef {{ implementation: WebSocketServer, clients: ClientConnection[] }} WebSocketServerImplementation
156
- */
157
- /**
158
- * @callback ByPass
159
- * @param {Request} req
160
- * @param {Response} res
161
- * @param {ProxyConfigArrayItem} proxyConfig
162
- */
163
- /**
164
- * @typedef {{ path?: HttpProxyMiddlewareOptionsFilter | undefined, context?: HttpProxyMiddlewareOptionsFilter | undefined } & { bypass?: ByPass } & HttpProxyMiddlewareOptions } ProxyConfigArrayItem
165
- */
166
- /**
167
- * @typedef {(ProxyConfigArrayItem | ((req?: Request | undefined, res?: Response | undefined, next?: NextFunction | undefined) => ProxyConfigArrayItem))[]} ProxyConfigArray
168
- */
169
- /**
170
- * @typedef {{ [url: string]: string | ProxyConfigArrayItem }} ProxyConfigMap
171
- */
172
- /**
173
- * @typedef {Object} OpenApp
174
- * @property {string} [name]
175
- * @property {string[]} [arguments]
176
- */
177
- /**
178
- * @typedef {Object} Open
179
- * @property {string | string[] | OpenApp} [app]
180
- * @property {string | string[]} [target]
181
- */
182
- /**
183
- * @typedef {Object} NormalizedOpen
184
- * @property {string} target
185
- * @property {import("open").Options} options
186
- */
187
- /**
188
- * @typedef {Object} WebSocketURL
189
- * @property {string} [hostname]
190
- * @property {string} [password]
191
- * @property {string} [pathname]
192
- * @property {number | string} [port]
193
- * @property {string} [protocol]
194
- * @property {string} [username]
195
- */
196
- /**
197
- * @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions
198
- */
199
- /**
200
- * @typedef {Object} ClientConfiguration
201
- * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging]
202
- * @property {boolean | { warnings?: OverlayMessageOptions, errors?: OverlayMessageOptions, runtimeErrors?: OverlayMessageOptions }} [overlay]
203
- * @property {boolean} [progress]
204
- * @property {boolean | number} [reconnect]
205
- * @property {"ws" | "sockjs" | string} [webSocketTransport]
206
- * @property {string | WebSocketURL} [webSocketURL]
207
- */
208
- /**
209
- * @typedef {Array<{ key: string; value: string }> | Record<string, string | string[]>} Headers
210
- */
211
- /**
212
- * @typedef {{ name?: string, path?: string, middleware: ExpressRequestHandler | ExpressErrorRequestHandler } | ExpressRequestHandler | ExpressErrorRequestHandler} Middleware
213
- */
214
- /**
215
- * @typedef {Object} Configuration
216
- * @property {boolean | string} [ipc]
217
- * @property {Host} [host]
218
- * @property {Port} [port]
219
- * @property {boolean | "only"} [hot]
220
- * @property {boolean} [liveReload]
221
- * @property {DevMiddlewareOptions<Request, Response>} [devMiddleware]
222
- * @property {boolean} [compress]
223
- * @property {"auto" | "all" | string | string[]} [allowedHosts]
224
- * @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback]
225
- * @property {boolean | Record<string, never> | BonjourOptions} [bonjour]
226
- * @property {string | string[] | WatchFiles | Array<string | WatchFiles>} [watchFiles]
227
- * @property {boolean | string | Static | Array<string | Static>} [static]
228
- * @property {boolean | ServerOptions} [https]
229
- * @property {boolean} [http2]
230
- * @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server]
231
- * @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer]
232
- * @property {ProxyConfigMap | ProxyConfigArrayItem | ProxyConfigArray} [proxy]
233
- * @property {boolean | string | Open | Array<string | Open>} [open]
234
- * @property {boolean} [setupExitSignals]
235
- * @property {boolean | ClientConfiguration} [client]
236
- * @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response>) => Headers)} [headers]
237
- * @property {(devServer: Server) => void} [onListening]
238
- * @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares]
239
- */
240
250
  ClientOverlay: {
241
251
  anyOf: (
242
252
  | {
@@ -282,7 +292,9 @@ declare class Server {
282
292
  instanceof?: undefined;
283
293
  }
284
294
  | {
285
- instanceof: string;
295
+ instanceof: string /**
296
+ * @typedef {import("ws").WebSocketServer | import("sockjs").Server & { close: import("ws").WebSocketServer["close"] }} WebSocketServer
297
+ */;
286
298
  description: string;
287
299
  type?: undefined;
288
300
  cli?: undefined;
@@ -345,6 +357,35 @@ declare class Server {
345
357
  )[];
346
358
  };
347
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
+ */
348
389
  anyOf: {
349
390
  $ref: string;
350
391
  }[];
@@ -438,6 +479,9 @@ declare class Server {
438
479
  };
439
480
  HeaderObject: {
440
481
  type: string;
482
+ /**
483
+ * @type {FSWatcher[]}
484
+ */
441
485
  additionalProperties: boolean;
442
486
  properties: {
443
487
  key: {
@@ -586,9 +630,7 @@ declare class Server {
586
630
  type: string;
587
631
  cli: {
588
632
  negatedDescription: string;
589
- } /**
590
- * @type {string | undefined}
591
- */;
633
+ };
592
634
  };
593
635
  OpenObject: {
594
636
  type: string;
@@ -621,11 +663,7 @@ declare class Server {
621
663
  type: string;
622
664
  items: {
623
665
  type: string;
624
- minLength: number /**
625
- * @private
626
- * @param {Compiler} compiler
627
- * @returns bool
628
- */;
666
+ minLength: number;
629
667
  };
630
668
  minItems: number;
631
669
  minLength?: undefined;
@@ -693,7 +731,7 @@ declare class Server {
693
731
  }
694
732
  )[];
695
733
  description: string;
696
- link: string;
734
+ link: string /** @type {WebSocketURL} */;
697
735
  };
698
736
  Proxy: {
699
737
  type: string;
@@ -705,6 +743,7 @@ declare class Server {
705
743
  }
706
744
  | {
707
745
  instanceof: string;
746
+ /** @type {{ type: WebSocketServerConfiguration["type"], options: NonNullable<WebSocketServerConfiguration["options"]> }} */
708
747
  type?: undefined;
709
748
  }
710
749
  )[];
@@ -731,6 +770,7 @@ declare class Server {
731
770
  ServerString: {
732
771
  type: string;
733
772
  minLength: number;
773
+ /** @type {string} */
734
774
  cli: {
735
775
  exclude: boolean;
736
776
  };
@@ -985,7 +1025,7 @@ declare class Server {
985
1025
  directory: {
986
1026
  type: string;
987
1027
  minLength: number;
988
- /** @type {MultiCompiler} */ description: string;
1028
+ description: string;
989
1029
  link: string;
990
1030
  };
991
1031
  staticOptions: {
@@ -1388,8 +1428,14 @@ declare class Server {
1388
1428
  private setupDevMiddleware;
1389
1429
  middleware:
1390
1430
  | import("webpack-dev-middleware").API<
1391
- import("http").IncomingMessage,
1392
- import("http").ServerResponse<import("http").IncomingMessage>
1431
+ import("express").Request<
1432
+ import("express-serve-static-core").ParamsDictionary,
1433
+ any,
1434
+ any,
1435
+ qs.ParsedQs,
1436
+ Record<string, any>
1437
+ >,
1438
+ import("express").Response<any, Record<string, any>>
1393
1439
  >
1394
1440
  | null
1395
1441
  | undefined;
@@ -1529,8 +1575,6 @@ declare namespace Server {
1529
1575
  Stats,
1530
1576
  MultiStats,
1531
1577
  NetworkInterfaceInfo,
1532
- Request,
1533
- Response,
1534
1578
  NextFunction,
1535
1579
  ExpressRequestHandler,
1536
1580
  ExpressErrorRequestHandler,
@@ -1551,6 +1595,8 @@ declare namespace Server {
1551
1595
  ServerResponse,
1552
1596
  OpenOptions,
1553
1597
  ServerOptions,
1598
+ Request,
1599
+ Response,
1554
1600
  DevMiddlewareOptions,
1555
1601
  DevMiddlewareContext,
1556
1602
  Host,
@@ -1566,7 +1612,6 @@ declare namespace Server {
1566
1612
  ByPass,
1567
1613
  ProxyConfigArrayItem,
1568
1614
  ProxyConfigArray,
1569
- ProxyConfigMap,
1570
1615
  OpenApp,
1571
1616
  Open,
1572
1617
  NormalizedOpen,
@@ -1596,8 +1641,6 @@ type StatsCompilation = import("webpack").StatsCompilation;
1596
1641
  type Stats = import("webpack").Stats;
1597
1642
  type MultiStats = import("webpack").MultiStats;
1598
1643
  type NetworkInterfaceInfo = import("os").NetworkInterfaceInfo;
1599
- type Request = import("express").Request;
1600
- type Response = import("express").Response;
1601
1644
  type NextFunction = import("express").NextFunction;
1602
1645
  type ExpressRequestHandler = import("express").RequestHandler;
1603
1646
  type ExpressErrorRequestHandler = import("express").ErrorRequestHandler;
@@ -1625,10 +1668,28 @@ type ServerOptions = import("https").ServerOptions & {
1625
1668
  protocols?: string[] | undefined;
1626
1669
  };
1627
1670
  };
1628
- type DevMiddlewareOptions<Request_1, Response_1> =
1629
- import("webpack-dev-middleware").Options<IncomingMessage, ServerResponse>;
1630
- type DevMiddlewareContext<Request_1, Response_1> =
1631
- import("webpack-dev-middleware").Context<IncomingMessage, ServerResponse>;
1671
+ type Request = import("express").Request;
1672
+ type Response = import("express").Response;
1673
+ type DevMiddlewareOptions<
1674
+ T extends import("express").Request<
1675
+ import("express-serve-static-core").ParamsDictionary,
1676
+ any,
1677
+ any,
1678
+ qs.ParsedQs,
1679
+ Record<string, any>
1680
+ >,
1681
+ U extends import("express").Response<any, Record<string, any>>,
1682
+ > = import("webpack-dev-middleware").Options<T, U>;
1683
+ type DevMiddlewareContext<
1684
+ T extends import("express").Request<
1685
+ import("express-serve-static-core").ParamsDictionary,
1686
+ any,
1687
+ any,
1688
+ qs.ParsedQs,
1689
+ Record<string, any>
1690
+ >,
1691
+ U extends import("express").Response<any, Record<string, any>>,
1692
+ > = import("webpack-dev-middleware").Context<T, U>;
1632
1693
  type Host = "local-ip" | "local-ipv4" | "local-ipv6" | string;
1633
1694
  type Port = number | string | "auto";
1634
1695
  type WatchFiles = {
@@ -1708,9 +1769,6 @@ type ProxyConfigArray = (
1708
1769
  next?: NextFunction | undefined,
1709
1770
  ) => ProxyConfigArrayItem)
1710
1771
  )[];
1711
- type ProxyConfigMap = {
1712
- [url: string]: string | ProxyConfigArrayItem;
1713
- };
1714
1772
  type OpenApp = {
1715
1773
  name?: string | undefined;
1716
1774
  arguments?: string[] | undefined;
@@ -1767,7 +1825,18 @@ type Configuration = {
1767
1825
  port?: Port | undefined;
1768
1826
  hot?: boolean | "only" | undefined;
1769
1827
  liveReload?: boolean | undefined;
1770
- devMiddleware?: DevMiddlewareOptions<Request_1, Response_1> | undefined;
1828
+ devMiddleware?:
1829
+ | DevMiddlewareOptions<
1830
+ import("express").Request<
1831
+ import("express-serve-static-core").ParamsDictionary,
1832
+ any,
1833
+ any,
1834
+ qs.ParsedQs,
1835
+ Record<string, any>
1836
+ >,
1837
+ import("express").Response<any, Record<string, any>>
1838
+ >
1839
+ | undefined;
1771
1840
  compress?: boolean | undefined;
1772
1841
  allowedHosts?: string | string[] | undefined;
1773
1842
  historyApiFallback?:
@@ -1790,7 +1859,7 @@ type Configuration = {
1790
1859
  http2?: boolean | undefined;
1791
1860
  server?: string | ServerConfiguration | undefined;
1792
1861
  webSocketServer?: string | boolean | WebSocketServerConfiguration | undefined;
1793
- proxy?: ProxyConfigArrayItem | ProxyConfigMap | ProxyConfigArray | undefined;
1862
+ proxy?: ProxyConfigArray | undefined;
1794
1863
  open?: string | boolean | Open | (string | Open)[] | undefined;
1795
1864
  setupExitSignals?: boolean | undefined;
1796
1865
  client?: boolean | ClientConfiguration | undefined;