webpack-dev-server 4.8.1 → 4.9.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 CHANGED
@@ -80,137 +80,127 @@ Usage: webpack serve|server|s [entries...] [options]
80
80
  Run the webpack dev server.
81
81
 
82
82
  Options:
83
- -c, --config <value...> Provide path to a webpack configuration file e.g. ./webpack.config.js.
84
- --config-name <value...> Name of the configuration to use.
85
- -m, --merge Merge two or more configurations using 'webpack-merge'.
86
- --env <value...> Environment passed to the configuration when it is a function.
87
- --node-env <value> Sets process.env.NODE_ENV to the specified value.
88
- --progress [value] Print compilation progress during build.
89
- -j, --json [value] Prints result as JSON or store it in a file.
90
- --entry <value...> The entry point(s) of your application e.g. ./src/main.js.
91
- -o, --output-path <value> Output location of the file generated by webpack e.g. ./dist/.
92
- -t, --target <value> Sets the build target e.g. node.
93
- -d, --devtool <value> Determine source maps to use.
94
- --no-devtool Do not generate source maps.
95
- --mode <value> Defines the mode to pass to webpack.
96
- --name <value> Name of the configuration. Used when loading multiple configurations.
97
- --stats [value] It instructs webpack on how to treat the stats e.g. verbose.
98
- --no-stats Disable stats output.
99
- --watch-options-stdin Stop watching when stdin stream has ended.
100
- --no-watch-options-stdin Do not stop watching when stdin stream has ended.
101
- --allowed-hosts <value...> Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto').
102
- --allowed-hosts-reset Clear all items provided in 'allowedHosts' configuration. Allows to enumerate the hosts from which access to the dev server are allowed (useful when
103
- you are proxying dev server, by default is 'auto').
104
- --bonjour Allows to broadcasts dev server via ZeroConf networking on start.
105
- --no-bonjour Disallows to broadcasts dev server via ZeroConf networking on start.
106
- --no-client Disables client script.
107
- --client-logging <value> Allows to set log level in the browser.
108
- --client-overlay Enables a full-screen overlay in the browser when there are compiler errors or warnings.
109
- --no-client-overlay Disables the full-screen overlay in the browser when there are compiler errors or warnings.
110
- --client-overlay-errors Enables a full-screen overlay in the browser when there are compiler errors.
111
- --no-client-overlay-errors Disables the full-screen overlay in the browser when there are compiler errors.
112
- --client-overlay-warnings Enables a full-screen overlay in the browser when there are compiler warnings.
113
- --no-client-overlay-warnings Disables the full-screen overlay in the browser when there are compiler warnings.
114
- --client-progress Prints compilation progress in percentage in the browser.
115
- --no-client-progress Does not print compilation progress in percentage in the browser.
116
- --client-reconnect [value] Tells dev-server the number of times it should try to reconnect the client.
117
- --no-client-reconnect Tells dev-server to not to try to reconnect the client.
118
- --client-web-socket-transport <value> Allows to set custom web socket transport to communicate with dev server.
119
- --client-web-socket-url <value> Allows to specify URL to web socket server (useful when you're proxying dev server and client script does not always know where to connect to).
120
- --client-web-socket-url-hostname <value> Tells clients connected to devServer to use the provided hostname.
121
- --client-web-socket-url-password <value> Tells clients connected to devServer to use the provided password to authenticate.
122
- --client-web-socket-url-pathname <value> Tells clients connected to devServer to use the provided path to connect.
123
- --client-web-socket-url-port <value> Tells clients connected to devServer to use the provided port.
124
- --client-web-socket-url-protocol <value> Tells clients connected to devServer to use the provided protocol.
125
- --client-web-socket-url-username <value> Tells clients connected to devServer to use the provided username to authenticate.
126
- --compress Enables gzip compression for everything served.
127
- --no-compress Disables gzip compression for everything served.
128
- --history-api-fallback Allows to proxy requests through a specified index page (by default 'index.html'), useful for Single Page Applications that utilise the HTML5
129
- History API.
130
- --no-history-api-fallback Disallows to proxy requests through a specified index page.
131
- --host <value> Allows to specify a hostname to use.
132
- --hot [value] Enables Hot Module Replacement.
133
- --no-hot Disables Hot Module Replacement.
134
- --http2 Allows to serve over HTTP/2 using SPDY. Deprecated, use the `server` option.
135
- --no-http2 Does not serve over HTTP/2 using SPDY.
136
- --https Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). Deprecated, use the `server` option.
137
- --no-https Disallows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP).
138
- --https-ca <value...> Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
139
- --https-ca-reset Clear all items provided in 'https.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the
140
- `server.options.ca` option.
141
- --https-cacert <value...> Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
142
- --https-cacert-reset Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the
143
- `server.options.ca` option.
144
- --https-cert <value...> Path to an SSL certificate or content of an SSL certificate. Deprecated, use the `server.options.cert` option.
145
- --https-cert-reset Clear all items provided in 'https.cert' configuration. Path to an SSL certificate or content of an SSL certificate. Deprecated, use the
146
- `server.options.cert` option.
147
- --https-crl <value...> Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, use the
148
- `server.options.crl` option.
149
- --https-crl-reset Clear all items provided in 'https.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs
150
- (Certificate Revocation Lists). Deprecated, use the `server.options.crl` option.
151
- --https-key <value...> Path to an SSL key or content of an SSL key. Deprecated, use the `server.options.key` option.
152
- --https-key-reset Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key. Deprecated, use the `server.options.key` option.
153
- --https-passphrase <value> Passphrase for a pfx file. Deprecated, use the `server.options.passphrase` option.
154
- --https-pfx <value...> Path to an SSL pfx file or content of an SSL pfx file. Deprecated, use the `server.options.pfx` option.
155
- --https-pfx-reset Clear all items provided in 'https.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. Deprecated, use the
156
- `server.options.pfx` option.
157
- --https-request-cert Request for an SSL certificate. Deprecated, use the `server.options.requestCert` option.
158
- --no-https-request-cert Does not request for an SSL certificate.
159
- --ipc [value] Listen to a unix socket.
160
- --live-reload Enables reload/refresh the page(s) when file changes are detected (enabled by default).
161
- --no-live-reload Disables reload/refresh the page(s) when file changes are detected (enabled by default)
162
- --magic-html Tells dev-server whether to enable magic HTML routes (routes corresponding to your webpack output, for example '/main' for 'main.js').
163
- --no-magic-html Disables magic HTML routes (routes corresponding to your webpack output, for example '/main' for 'main.js').
164
- --open [value...] Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to true to open your default browser).
165
- --no-open Does not open the default browser.
166
- --open-app <value...> Open specified browser. Deprecated: please use '--open-app-name'.
167
- --open-app-name <value...> Open specified browser.
168
- --open-app-name-reset Clear all items provided in 'open.app.name' configuration. Open specified browser.
169
- --open-reset Clear all items provided in 'open' configuration. Allows to configure dev server to open the browser(s) and page(s) after server had been started
170
- (set it to true to open your default browser).
171
- --open-target <value...> Opens specified page in browser.
172
- --open-target-reset Clear all items provided in 'open.target' configuration. Opens specified page in browser.
173
- --port <value> Allows to specify a port to use.
174
- --server-options-ca <value...> Path to an SSL CA certificate or content of an SSL CA certificate.
175
- --server-options-ca-reset Clear all items provided in 'server.options.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate.
176
- --server-options-cacert <value...> Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
177
- --server-options-cacert-reset Clear all items provided in 'server.options.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated,
178
- use the `server.options.ca` option.
179
- --server-options-cert <value...> Path to an SSL certificate or content of an SSL certificate.
180
- --server-options-cert-reset Clear all items provided in 'server.options.cert' configuration. Path to an SSL certificate or content of an SSL certificate.
181
- --server-options-crl <value...> Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists).
182
- --server-options-crl-reset Clear all items provided in 'server.options.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM
183
- formatted CRLs (Certificate Revocation Lists).
184
- --server-options-key <value...> Path to an SSL key or content of an SSL key.
185
- --server-options-key-reset Clear all items provided in 'server.options.key' configuration. Path to an SSL key or content of an SSL key.
186
- --server-options-passphrase <value> Passphrase for a pfx file.
187
- --server-options-pfx <value...> Path to an SSL pfx file or content of an SSL pfx file.
188
- --server-options-pfx-reset Clear all items provided in 'server.options.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file.
189
- --server-options-request-cert Request for an SSL certificate.
190
- --no-server-options-request-cert Negative 'server-options-request-cert' option.
191
- --server-type <value> Allows to set server and options (by default 'http').
192
- --static [value...] Allows to configure options for serving static files from directory (by default 'public' directory).
193
- --no-static Negative 'static' option.
194
- --static-directory <value...> Directory for static contents.
195
- --static-public-path <value...> The static files will be available in the browser under this public path.
196
- --static-public-path-reset Clear all items provided in 'static.publicPath' configuration. The static files will be available in the browser under this public path.
197
- --static-reset Clear all items provided in 'static' configuration. Allows to configure options for serving static files from directory (by default 'public'
198
- directory).
199
- --static-serve-index Tells dev server to use serveIndex middleware when enabled.
200
- --no-static-serve-index Does not tell dev server to use serveIndex middleware.
201
- --static-watch Watches for files in static content directory.
202
- --no-static-watch Does not watch for files in static content directory.
203
- --watch-files <value...> Allows to configure list of globs/directories/files to watch for file changes.
204
- --watch-files-reset Clear all items provided in 'watchFiles' configuration. Allows to configure list of globs/directories/files to watch for file changes.
205
- --web-socket-server <value> Deprecated: please use '--web-socket-server-type' option. Allows to set web socket server and options (by default 'ws').
206
- --no-web-socket-server Negative 'web-socket-server' option.
207
- --web-socket-server-type <value> Allows to set web socket server and options (by default 'ws').
83
+ -c, --config <value...> Provide path to a webpack configuration file e.g. ./webpack.config.js.
84
+ --config-name <value...> Name of the configuration to use.
85
+ -m, --merge Merge two or more configurations using 'webpack-merge'.
86
+ --env <value...> Environment passed to the configuration when it is a function.
87
+ --node-env <value> Sets process.env.NODE_ENV to the specified value.
88
+ --progress [value] Print compilation progress during build.
89
+ -j, --json [value] Prints result as JSON or store it in a file.
90
+ -d, --devtool <value> Determine source maps to use.
91
+ --no-devtool Do not generate source maps.
92
+ --entry <value...> The entry point(s) of your application e.g. ./src/main.js.
93
+ --mode <value> Defines the mode to pass to webpack.
94
+ --name <value> Name of the configuration. Used when loading multiple configurations.
95
+ -o, --output-path <value> Output location of the file generated by webpack e.g. ./dist/.
96
+ --stats [value] It instructs webpack on how to treat the stats e.g. verbose.
97
+ --no-stats Disable stats output.
98
+ -t, --target <value...> Sets the build target e.g. node.
99
+ --no-target Negative 'target' option.
100
+ --watch-options-stdin Stop watching when stdin stream has ended.
101
+ --no-watch-options-stdin Do not stop watching when stdin stream has ended.
102
+ --allowed-hosts <value...> Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto').
103
+ --allowed-hosts-reset Clear all items provided in 'allowedHosts' configuration. Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto').
104
+ --bonjour Allows to broadcasts dev server via ZeroConf networking on start.
105
+ --no-bonjour Disallows to broadcasts dev server via ZeroConf networking on start.
106
+ --no-client Disables client script.
107
+ --client-logging <value> Allows to set log level in the browser.
108
+ --client-overlay Enables a full-screen overlay in the browser when there are compiler errors or warnings.
109
+ --no-client-overlay Disables the full-screen overlay in the browser when there are compiler errors or warnings.
110
+ --client-overlay-errors Enables a full-screen overlay in the browser when there are compiler errors.
111
+ --no-client-overlay-errors Disables the full-screen overlay in the browser when there are compiler errors.
112
+ --client-overlay-warnings Enables a full-screen overlay in the browser when there are compiler warnings.
113
+ --no-client-overlay-warnings Disables the full-screen overlay in the browser when there are compiler warnings.
114
+ --client-overlay-trusted-types-policy-name <value> The name of a Trusted Types policy for the overlay. Defaults to 'webpack-dev-server#overlay'.
115
+ --client-progress Prints compilation progress in percentage in the browser.
116
+ --no-client-progress Does not print compilation progress in percentage in the browser.
117
+ --client-reconnect [value] Tells dev-server the number of times it should try to reconnect the client.
118
+ --no-client-reconnect Tells dev-server to not to try to reconnect the client.
119
+ --client-web-socket-transport <value> Allows to set custom web socket transport to communicate with dev server.
120
+ --client-web-socket-url <value> Allows to specify URL to web socket server (useful when you're proxying dev server and client script does not always know where to connect to).
121
+ --client-web-socket-url-hostname <value> Tells clients connected to devServer to use the provided hostname.
122
+ --client-web-socket-url-pathname <value> Tells clients connected to devServer to use the provided path to connect.
123
+ --client-web-socket-url-password <value> Tells clients connected to devServer to use the provided password to authenticate.
124
+ --client-web-socket-url-port <value> Tells clients connected to devServer to use the provided port.
125
+ --client-web-socket-url-protocol <value> Tells clients connected to devServer to use the provided protocol.
126
+ --client-web-socket-url-username <value> Tells clients connected to devServer to use the provided username to authenticate.
127
+ --compress Enables gzip compression for everything served.
128
+ --no-compress Disables gzip compression for everything served.
129
+ --history-api-fallback Allows to proxy requests through a specified index page (by default 'index.html'), useful for Single Page Applications that utilise the HTML5 History API.
130
+ --no-history-api-fallback Disallows to proxy requests through a specified index page.
131
+ --host <value> Allows to specify a hostname to use.
132
+ --hot [value] Enables Hot Module Replacement.
133
+ --no-hot Disables Hot Module Replacement.
134
+ --http2 Allows to serve over HTTP/2 using SPDY. Deprecated, use the `server` option.
135
+ --no-http2 Does not serve over HTTP/2 using SPDY.
136
+ --https Allows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP). Deprecated, use the `server` option.
137
+ --no-https Disallows to configure the server's listening socket for TLS (by default, dev server will be served over HTTP).
138
+ --https-passphrase <value> Passphrase for a pfx file. Deprecated, use the `server.options.passphrase` option.
139
+ --https-request-cert Request for an SSL certificate. Deprecated, use the `server.options.requestCert` option.
140
+ --no-https-request-cert Does not request for an SSL certificate.
141
+ --https-ca <value...> Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
142
+ --https-ca-reset Clear all items provided in 'https.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
143
+ --https-cacert <value...> Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
144
+ --https-cacert-reset Clear all items provided in 'https.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
145
+ --https-cert <value...> Path to an SSL certificate or content of an SSL certificate. Deprecated, use the `server.options.cert` option.
146
+ --https-cert-reset Clear all items provided in 'https.cert' configuration. Path to an SSL certificate or content of an SSL certificate. Deprecated, use the `server.options.cert` option.
147
+ --https-crl <value...> Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, use the `server.options.crl` option.
148
+ --https-crl-reset Clear all items provided in 'https.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists). Deprecated, use the `server.options.crl` option.
149
+ --https-key <value...> Path to an SSL key or content of an SSL key. Deprecated, use the `server.options.key` option.
150
+ --https-key-reset Clear all items provided in 'https.key' configuration. Path to an SSL key or content of an SSL key. Deprecated, use the `server.options.key` option.
151
+ --https-pfx <value...> Path to an SSL pfx file or content of an SSL pfx file. Deprecated, use the `server.options.pfx` option.
152
+ --https-pfx-reset Clear all items provided in 'https.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file. Deprecated, use the `server.options.pfx` option.
153
+ --ipc [value] Listen to a unix socket.
154
+ --live-reload Enables reload/refresh the page(s) when file changes are detected (enabled by default).
155
+ --no-live-reload Disables reload/refresh the page(s) when file changes are detected (enabled by default).
156
+ --magic-html Tells dev-server whether to enable magic HTML routes (routes corresponding to your webpack output, for example '/main' for 'main.js').
157
+ --no-magic-html Disables magic HTML routes (routes corresponding to your webpack output, for example '/main' for 'main.js').
158
+ --open [value...] Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to true to open your default browser).
159
+ --no-open Does not open the default browser.
160
+ --open-target <value...> Opens specified page in browser.
161
+ --open-app-name <value...> Open specified browser.
162
+ --open-app <value...> Open specified browser. Deprecated: please use '--open-app-name'.
163
+ --open-reset Clear all items provided in 'open' configuration. Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to true to open your default browser).
164
+ --open-target-reset Clear all items provided in 'open.target' configuration. Opens specified page in browser.
165
+ --open-app-name-reset Clear all items provided in 'open.app.name' configuration. Open specified browser.
166
+ --port <value> Allows to specify a port to use.
167
+ --server-type <value> Allows to set server and options (by default 'http').
168
+ --server-options-passphrase <value> Passphrase for a pfx file.
169
+ --server-options-request-cert Request for an SSL certificate.
170
+ --no-server-options-request-cert Does not request for an SSL certificate.
171
+ --server-options-ca <value...> Path to an SSL CA certificate or content of an SSL CA certificate.
172
+ --server-options-ca-reset Clear all items provided in 'server.options.ca' configuration. Path to an SSL CA certificate or content of an SSL CA certificate.
173
+ --server-options-cacert <value...> Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
174
+ --server-options-cacert-reset Clear all items provided in 'server.options.cacert' configuration. Path to an SSL CA certificate or content of an SSL CA certificate. Deprecated, use the `server.options.ca` option.
175
+ --server-options-cert <value...> Path to an SSL certificate or content of an SSL certificate.
176
+ --server-options-cert-reset Clear all items provided in 'server.options.cert' configuration. Path to an SSL certificate or content of an SSL certificate.
177
+ --server-options-crl <value...> Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists).
178
+ --server-options-crl-reset Clear all items provided in 'server.options.crl' configuration. Path to PEM formatted CRLs (Certificate Revocation Lists) or content of PEM formatted CRLs (Certificate Revocation Lists).
179
+ --server-options-key <value...> Path to an SSL key or content of an SSL key.
180
+ --server-options-key-reset Clear all items provided in 'server.options.key' configuration. Path to an SSL key or content of an SSL key.
181
+ --server-options-pfx <value...> Path to an SSL pfx file or content of an SSL pfx file.
182
+ --server-options-pfx-reset Clear all items provided in 'server.options.pfx' configuration. Path to an SSL pfx file or content of an SSL pfx file.
183
+ --static [value...] Allows to configure options for serving static files from directory (by default 'public' directory).
184
+ --no-static Disallows to configure options for serving static files from directory.
185
+ --static-directory <value...> Directory for static contents.
186
+ --static-public-path <value...> The static files will be available in the browser under this public path.
187
+ --static-serve-index Tells dev server to use serveIndex middleware when enabled.
188
+ --no-static-serve-index Does not tell dev server to use serveIndex middleware.
189
+ --static-watch Watches for files in static content directory.
190
+ --no-static-watch Does not watch for files in static content directory.
191
+ --static-reset Clear all items provided in 'static' configuration. Allows to configure options for serving static files from directory (by default 'public' directory).
192
+ --static-public-path-reset Clear all items provided in 'static.publicPath' configuration. The static files will be available in the browser under this public path.
193
+ --watch-files <value...> Allows to configure list of globs/directories/files to watch for file changes.
194
+ --watch-files-reset Clear all items provided in 'watchFiles' configuration. Allows to configure list of globs/directories/files to watch for file changes.
195
+ --web-socket-server <value> Deprecated: please use '--web-socket-server-type' option. Allows to set web socket server and options (by default 'ws').
196
+ --no-web-socket-server Disallows to set web socket server and options.
197
+ --web-socket-server-type <value> Allows to set web socket server and options (by default 'ws').
208
198
 
209
199
  Global options:
210
- --color Enable colors on console.
211
- --no-color Disable colors on console.
212
- -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.
213
- -h, --help [verbose] Display help for commands and options.
200
+ --color Enable colors on console.
201
+ --no-color Disable colors on console.
202
+ -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.
203
+ -h, --help [verbose] Display help for commands and options.
214
204
 
215
205
  To see list of all supported commands and options run 'webpack --help=verbose'.
216
206
 
@@ -241,7 +231,7 @@ And run the following in your terminal/console:
241
231
  npm run serve
242
232
  ```
243
233
 
244
- NPM will automagically reference the binary in `node_modules` for you, and
234
+ NPM will automatically refer to the the binary in `node_modules` for you, and
245
235
  execute the file or command.
246
236
 
247
237
  ### With the API
package/bin/cli-flags.js CHANGED
@@ -121,6 +121,21 @@ module.exports = {
121
121
  simpleType: "boolean",
122
122
  multiple: false,
123
123
  },
124
+ "client-overlay-trusted-types-policy-name": {
125
+ configs: [
126
+ {
127
+ description:
128
+ "The name of a Trusted Types policy for the overlay. Defaults to 'webpack-dev-server#overlay'.",
129
+ multiple: false,
130
+ path: "client.overlay.trustedTypesPolicyName",
131
+ type: "string",
132
+ },
133
+ ],
134
+ description:
135
+ "The name of a Trusted Types policy for the overlay. Defaults to 'webpack-dev-server#overlay'.",
136
+ multiple: false,
137
+ simpleType: "string",
138
+ },
124
139
  "client-overlay-warnings": {
125
140
  configs: [
126
141
  {
package/client/index.js CHANGED
@@ -14,7 +14,7 @@ import createSocketURL from "./utils/createSocketURL.js";
14
14
  * @property {boolean} hot
15
15
  * @property {boolean} liveReload
16
16
  * @property {boolean} progress
17
- * @property {boolean | { warnings?: boolean, errors?: boolean }} overlay
17
+ * @property {boolean | { warnings?: boolean, errors?: boolean, trustedTypesPolicyName?: string }} overlay
18
18
  * @property {string} [logging]
19
19
  * @property {number} [reconnect]
20
20
  */
@@ -216,7 +216,8 @@ var onSocketMessage = {
216
216
  var needShowOverlayForWarnings = typeof options.overlay === "boolean" ? options.overlay : options.overlay && options.overlay.warnings;
217
217
 
218
218
  if (needShowOverlayForWarnings) {
219
- show("warning", _warnings);
219
+ var trustedTypesPolicyName = typeof options.overlay === "object" && options.overlay.trustedTypesPolicyName;
220
+ show("warning", _warnings, trustedTypesPolicyName || null);
220
221
  }
221
222
 
222
223
  if (params && params.preventReloading) {
@@ -249,7 +250,8 @@ var onSocketMessage = {
249
250
  var needShowOverlayForErrors = typeof options.overlay === "boolean" ? options.overlay : options.overlay && options.overlay.errors;
250
251
 
251
252
  if (needShowOverlayForErrors) {
252
- show("error", _errors);
253
+ var trustedTypesPolicyName = typeof options.overlay === "object" && options.overlay.trustedTypesPolicyName;
254
+ show("error", _errors, trustedTypesPolicyName || null);
253
255
  }
254
256
  },
255
257
 
package/client/overlay.js CHANGED
@@ -23,9 +23,24 @@ var containerElement;
23
23
  /** @type {Array<(element: HTMLDivElement) => void>} */
24
24
 
25
25
  var onLoadQueue = [];
26
+ /** @type {TrustedTypePolicy | undefined} */
27
+
28
+ var overlayTrustedTypesPolicy;
26
29
  ansiHTML.setColors(colors);
30
+ /**
31
+ * @param {string | null} trustedTypesPolicyName
32
+ */
33
+
34
+ function createContainer(trustedTypesPolicyName) {
35
+ // Enable Trusted Types if they are available in the current browser.
36
+ if (window.trustedTypes) {
37
+ overlayTrustedTypesPolicy = window.trustedTypes.createPolicy(trustedTypesPolicyName || "webpack-dev-server#overlay", {
38
+ createHTML: function createHTML(value) {
39
+ return value;
40
+ }
41
+ });
42
+ }
27
43
 
28
- function createContainer() {
29
44
  iframeContainerElement = document.createElement("iframe");
30
45
  iframeContainerElement.id = "webpack-dev-server-client-overlay";
31
46
  iframeContainerElement.src = "about:blank";
@@ -101,10 +116,11 @@ function createContainer() {
101
116
  }
102
117
  /**
103
118
  * @param {(element: HTMLDivElement) => void} callback
119
+ * @param {string | null} trustedTypesPolicyName
104
120
  */
105
121
 
106
122
 
107
- function ensureOverlayExists(callback) {
123
+ function ensureOverlayExists(callback, trustedTypesPolicyName) {
108
124
  if (containerElement) {
109
125
  // Everything is ready, call the callback right away.
110
126
  callback(containerElement);
@@ -117,7 +133,7 @@ function ensureOverlayExists(callback) {
117
133
  return;
118
134
  }
119
135
 
120
- createContainer();
136
+ createContainer(trustedTypesPolicyName);
121
137
  } // Successful compilation.
122
138
 
123
139
 
@@ -162,10 +178,11 @@ function formatProblem(type, item) {
162
178
  /**
163
179
  * @param {string} type
164
180
  * @param {Array<string | { file?: string, moduleName?: string, loc?: string, message?: string }>} messages
181
+ * @param {string | null} trustedTypesPolicyName
165
182
  */
166
183
 
167
184
 
168
- function show(type, messages) {
185
+ function show(type, messages, trustedTypesPolicyName) {
169
186
  ensureOverlayExists(function () {
170
187
  messages.forEach(function (message) {
171
188
  var entryElement = document.createElement("div");
@@ -180,7 +197,7 @@ function show(type, messages) {
180
197
 
181
198
  var text = ansiHTML(encode(body));
182
199
  var messageTextNode = document.createElement("div");
183
- messageTextNode.innerHTML = text;
200
+ messageTextNode.innerHTML = overlayTrustedTypesPolicy ? overlayTrustedTypesPolicy.createHTML(text) : text;
184
201
  entryElement.appendChild(typeElement);
185
202
  entryElement.appendChild(document.createElement("br"));
186
203
  entryElement.appendChild(document.createElement("br"));
@@ -191,7 +208,7 @@ function show(type, messages) {
191
208
 
192
209
  containerElement.appendChild(entryElement);
193
210
  });
194
- });
211
+ }, trustedTypesPolicyName);
195
212
  }
196
213
 
197
214
  export { formatProblem, show, hide };
@@ -5,7 +5,7 @@
5
5
  function format(objURL) {
6
6
  var protocol = objURL.protocol || "";
7
7
 
8
- if (protocol && !protocol.endsWith(":")) {
8
+ if (protocol && protocol.substr(-1) !== ":") {
9
9
  protocol += ":";
10
10
  }
11
11
 
package/lib/Server.js CHANGED
@@ -385,17 +385,17 @@ class Server {
385
385
 
386
386
  /**
387
387
  * @param {Port} port
388
+ * @param {string} host
388
389
  * @returns {Promise<number | string>}
389
390
  */
390
- static async getFreePort(port) {
391
+ static async getFreePort(port, host) {
391
392
  if (typeof port !== "undefined" && port !== null && port !== "auto") {
392
393
  return port;
393
394
  }
394
395
 
395
396
  const pRetry = require("p-retry");
396
- const portfinder = require("portfinder");
397
-
398
- portfinder.basePort =
397
+ const getPort = require("./getPort");
398
+ const basePort =
399
399
  typeof process.env.WEBPACK_DEV_SERVER_BASE_PORT !== "undefined"
400
400
  ? parseInt(process.env.WEBPACK_DEV_SERVER_BASE_PORT, 10)
401
401
  : 8080;
@@ -407,7 +407,7 @@ class Server {
407
407
  ? parseInt(process.env.WEBPACK_DEV_SERVER_PORT_RETRY, 10)
408
408
  : 3;
409
409
 
410
- return pRetry(() => portfinder.getPortPromise(), {
410
+ return pRetry(() => getPort(basePort, host), {
411
411
  retries: defaultPortRetry,
412
412
  });
413
413
  }
@@ -3201,7 +3201,8 @@ class Server {
3201
3201
  /** @type {Host} */ (this.options.host)
3202
3202
  );
3203
3203
  this.options.port = await Server.getFreePort(
3204
- /** @type {Port} */ (this.options.port)
3204
+ /** @type {Port} */ (this.options.port),
3205
+ this.options.host
3205
3206
  );
3206
3207
  }
3207
3208
 
package/lib/getPort.js ADDED
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Based on the packages get-port https://www.npmjs.com/package/get-port
5
+ * and portfinder https://www.npmjs.com/package/portfinder
6
+ * The code structure is similar to get-port, but it searches
7
+ * ports deterministically like portfinder
8
+ */
9
+ const net = require("net");
10
+ const os = require("os");
11
+
12
+ const minPort = 1024;
13
+ const maxPort = 65_535;
14
+
15
+ /**
16
+ * @return {Set<string|undefined>}
17
+ */
18
+ const getLocalHosts = () => {
19
+ const interfaces = os.networkInterfaces();
20
+
21
+ // Add undefined value for createServer function to use default host,
22
+ // and default IPv4 host in case createServer defaults to IPv6.
23
+ // eslint-disable-next-line no-undefined
24
+ const results = new Set([undefined, "0.0.0.0"]);
25
+
26
+ for (const _interface of Object.values(interfaces)) {
27
+ if (_interface) {
28
+ for (const config of _interface) {
29
+ results.add(config.address);
30
+ }
31
+ }
32
+ }
33
+
34
+ return results;
35
+ };
36
+
37
+ /**
38
+ * @param {number} basePort
39
+ * @param {string | undefined} host
40
+ * @return {Promise<number>}
41
+ */
42
+ const checkAvailablePort = (basePort, host) =>
43
+ new Promise((resolve, reject) => {
44
+ const server = net.createServer();
45
+ server.unref();
46
+ server.on("error", reject);
47
+
48
+ server.listen(basePort, host, () => {
49
+ // Next line should return AdressInfo because we're calling it after listen() and before close()
50
+ const { port } = /** @type {import("net").AddressInfo} */ (
51
+ server.address()
52
+ );
53
+ server.close(() => {
54
+ resolve(port);
55
+ });
56
+ });
57
+ });
58
+
59
+ /**
60
+ * @param {number} port
61
+ * @param {Set<string|undefined>} hosts
62
+ * @return {Promise<number>}
63
+ */
64
+ const getAvailablePort = async (port, hosts) => {
65
+ /**
66
+ * Errors that mean that host is not available.
67
+ * @type {Set<string | undefined>}
68
+ */
69
+ const nonExistentInterfaceErrors = new Set(["EADDRNOTAVAIL", "EINVAL"]);
70
+ /* Check if the post is available on every local host name */
71
+ for (const host of hosts) {
72
+ try {
73
+ await checkAvailablePort(port, host); // eslint-disable-line no-await-in-loop
74
+ } catch (error) {
75
+ /* We throw an error only if the interface exists */
76
+ if (
77
+ !nonExistentInterfaceErrors.has(
78
+ /** @type {NodeJS.ErrnoException} */ (error).code
79
+ )
80
+ ) {
81
+ throw error;
82
+ }
83
+ }
84
+ }
85
+
86
+ return port;
87
+ };
88
+
89
+ /**
90
+ * @param {number} basePort
91
+ * @param {string=} host
92
+ * @return {Promise<number>}
93
+ */
94
+ async function getPorts(basePort, host) {
95
+ if (basePort < minPort || basePort > maxPort) {
96
+ throw new Error(`Port number must lie between ${minPort} and ${maxPort}`);
97
+ }
98
+
99
+ let port = basePort;
100
+ const localhosts = getLocalHosts();
101
+ let hosts;
102
+ if (host && !localhosts.has(host)) {
103
+ hosts = new Set([host]);
104
+ } else {
105
+ /* If the host is equivalent to localhost
106
+ we need to check every equivalent host
107
+ else the port might falsely appear as available
108
+ on some operating systems */
109
+ hosts = localhosts;
110
+ }
111
+ /** @type {Set<string | undefined>} */
112
+ const portUnavailableErrors = new Set(["EADDRINUSE", "EACCES"]);
113
+ while (port <= maxPort) {
114
+ try {
115
+ const availablePort = await getAvailablePort(port, hosts); // eslint-disable-line no-await-in-loop
116
+ return availablePort;
117
+ } catch (error) {
118
+ /* Try next port if port is busy; throw for any other error */
119
+ if (
120
+ !portUnavailableErrors.has(
121
+ /** @type {NodeJS.ErrnoException} */ (error).code
122
+ )
123
+ ) {
124
+ throw error;
125
+ }
126
+ port += 1;
127
+ }
128
+ }
129
+
130
+ throw new Error("No available ports found");
131
+ }
132
+
133
+ module.exports = getPorts;
package/lib/options.json CHANGED
@@ -110,6 +110,10 @@
110
110
  "cli": {
111
111
  "negatedDescription": "Disables the full-screen overlay in the browser when there are compiler warnings."
112
112
  }
113
+ },
114
+ "trustedTypesPolicyName": {
115
+ "description": "The name of a Trusted Types policy for the overlay. Defaults to 'webpack-dev-server#overlay'.",
116
+ "type": "string"
113
117
  }
114
118
  }
115
119
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack-dev-server",
3
- "version": "4.8.1",
3
+ "version": "4.9.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",
@@ -55,7 +55,6 @@
55
55
  "ipaddr.js": "^2.0.1",
56
56
  "open": "^8.0.9",
57
57
  "p-retry": "^4.5.0",
58
- "portfinder": "^1.0.28",
59
58
  "rimraf": "^3.0.2",
60
59
  "schema-utils": "^4.0.0",
61
60
  "selfsigned": "^2.0.1",
@@ -79,6 +78,7 @@
79
78
  "@types/default-gateway": "^3.0.1",
80
79
  "@types/rimraf": "^3.0.2",
81
80
  "@types/sockjs-client": "^1.5.1",
81
+ "@types/trusted-types": "^2.0.2",
82
82
  "acorn": "^8.2.4",
83
83
  "babel-jest": "^27.5.1",
84
84
  "babel-loader": "^8.2.4",
@@ -91,6 +91,17 @@ declare const _exports: {
91
91
  simpleType: string;
92
92
  multiple: boolean;
93
93
  };
94
+ "client-overlay-trusted-types-policy-name": {
95
+ configs: {
96
+ description: string;
97
+ multiple: boolean;
98
+ path: string;
99
+ type: string;
100
+ }[];
101
+ description: string;
102
+ multiple: boolean;
103
+ simpleType: string;
104
+ };
94
105
  "client-overlay-warnings": {
95
106
  configs: {
96
107
  type: string;
@@ -393,6 +393,17 @@ declare class Server {
393
393
  simpleType: string;
394
394
  multiple: boolean;
395
395
  };
396
+ "client-overlay-trusted-types-policy-name": {
397
+ configs: {
398
+ description: string;
399
+ multiple: boolean;
400
+ path: string;
401
+ type: string;
402
+ }[];
403
+ description: string;
404
+ multiple: boolean;
405
+ simpleType: string;
406
+ };
396
407
  "client-overlay-warnings": {
397
408
  configs: {
398
409
  type: string;
@@ -417,6 +428,60 @@ declare class Server {
417
428
  simpleType: string;
418
429
  multiple: boolean;
419
430
  };
431
+ /**
432
+ * @typedef {Object} WebSocketURL
433
+ * @property {string} [hostname]
434
+ * @property {string} [password]
435
+ * @property {string} [pathname]
436
+ * @property {number | string} [port]
437
+ * @property {string} [protocol]
438
+ * @property {string} [username]
439
+ */
440
+ /**
441
+ * @typedef {Object} ClientConfiguration
442
+ * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging]
443
+ * @property {boolean | { warnings?: boolean, errors?: boolean }} [overlay]
444
+ * @property {boolean} [progress]
445
+ * @property {boolean | number} [reconnect]
446
+ * @property {"ws" | "sockjs" | string} [webSocketTransport]
447
+ * @property {string | WebSocketURL} [webSocketURL]
448
+ */
449
+ /**
450
+ * @typedef {Array<{ key: string; value: string }> | Record<string, string | string[]>} Headers
451
+ */
452
+ /**
453
+ * @typedef {{ name?: string, path?: string, middleware: ExpressRequestHandler | ExpressErrorRequestHandler } | ExpressRequestHandler | ExpressErrorRequestHandler} Middleware
454
+ */
455
+ /**
456
+ * @typedef {Object} Configuration
457
+ * @property {boolean | string} [ipc]
458
+ * @property {Host} [host]
459
+ * @property {Port} [port]
460
+ * @property {boolean | "only"} [hot]
461
+ * @property {boolean} [liveReload]
462
+ * @property {DevMiddlewareOptions<Request, Response>} [devMiddleware]
463
+ * @property {boolean} [compress]
464
+ * @property {boolean} [magicHtml]
465
+ * @property {"auto" | "all" | string | string[]} [allowedHosts]
466
+ * @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback]
467
+ * @property {boolean} [setupExitSignals]
468
+ * @property {boolean | Record<string, never> | BonjourOptions} [bonjour]
469
+ * @property {string | string[] | WatchFiles | Array<string | WatchFiles>} [watchFiles]
470
+ * @property {boolean | string | Static | Array<string | Static>} [static]
471
+ * @property {boolean | ServerOptions} [https]
472
+ * @property {boolean} [http2]
473
+ * @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server]
474
+ * @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer]
475
+ * @property {ProxyConfigMap | ProxyConfigArrayItem | ProxyConfigArray} [proxy]
476
+ * @property {boolean | string | Open | Array<string | Open>} [open]
477
+ * @property {boolean} [setupExitSignals]
478
+ * @property {boolean | ClientConfiguration} [client]
479
+ * @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response>) => Headers)} [headers]
480
+ * @property {(devServer: Server) => void} [onAfterSetupMiddleware]
481
+ * @property {(devServer: Server) => void} [onBeforeSetupMiddleware]
482
+ * @property {(devServer: Server) => void} [onListening]
483
+ * @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares]
484
+ */
420
485
  "client-reconnect": {
421
486
  configs: (
422
487
  | {
@@ -453,36 +518,6 @@ declare class Server {
453
518
  path: string;
454
519
  }
455
520
  )[];
456
- /**
457
- * @typedef {Object} Configuration
458
- * @property {boolean | string} [ipc]
459
- * @property {Host} [host]
460
- * @property {Port} [port]
461
- * @property {boolean | "only"} [hot]
462
- * @property {boolean} [liveReload]
463
- * @property {DevMiddlewareOptions<Request, Response>} [devMiddleware]
464
- * @property {boolean} [compress]
465
- * @property {boolean} [magicHtml]
466
- * @property {"auto" | "all" | string | string[]} [allowedHosts]
467
- * @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback]
468
- * @property {boolean} [setupExitSignals]
469
- * @property {boolean | Record<string, never> | BonjourOptions} [bonjour]
470
- * @property {string | string[] | WatchFiles | Array<string | WatchFiles>} [watchFiles]
471
- * @property {boolean | string | Static | Array<string | Static>} [static]
472
- * @property {boolean | ServerOptions} [https]
473
- * @property {boolean} [http2]
474
- * @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server]
475
- * @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer]
476
- * @property {ProxyConfigMap | ProxyConfigArrayItem | ProxyConfigArray} [proxy]
477
- * @property {boolean | string | Open | Array<string | Open>} [open]
478
- * @property {boolean} [setupExitSignals]
479
- * @property {boolean | ClientConfiguration} [client]
480
- * @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response>) => Headers)} [headers]
481
- * @property {(devServer: Server) => void} [onAfterSetupMiddleware]
482
- * @property {(devServer: Server) => void} [onBeforeSetupMiddleware]
483
- * @property {(devServer: Server) => void} [onListening]
484
- * @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares]
485
- */
486
521
  description: string;
487
522
  simpleType: string;
488
523
  multiple: boolean;
@@ -539,6 +574,9 @@ declare class Server {
539
574
  path: string;
540
575
  }[];
541
576
  description: string;
577
+ /**
578
+ * @type {FSWatcher[]}
579
+ */
542
580
  simpleType: string;
543
581
  multiple: boolean;
544
582
  };
@@ -558,20 +596,12 @@ declare class Server {
558
596
  type: string;
559
597
  }
560
598
  )[];
561
- /**
562
- * @private
563
- * @type {{ name: string | symbol, listener: (...args: any[]) => void}[] }}
564
- */
565
599
  description: string;
566
600
  multiple: boolean;
567
601
  simpleType: string;
568
602
  };
569
603
  "client-web-socket-url-username": {
570
604
  configs: {
571
- /**
572
- * @private
573
- * @type {RequestHandler[]}
574
- */
575
605
  type: string;
576
606
  multiple: boolean;
577
607
  description: string;
@@ -581,6 +611,10 @@ declare class Server {
581
611
  simpleType: string;
582
612
  multiple: boolean;
583
613
  };
614
+ /**
615
+ * @param {string} URL
616
+ * @returns {boolean}
617
+ */
584
618
  compress: {
585
619
  configs: {
586
620
  type: string;
@@ -591,6 +625,10 @@ declare class Server {
591
625
  }[];
592
626
  description: string;
593
627
  simpleType: string;
628
+ /**
629
+ * @param {string} gateway
630
+ * @returns {string | undefined}
631
+ */
594
632
  multiple: boolean;
595
633
  };
596
634
  "history-api-fallback": {
@@ -623,6 +661,10 @@ declare class Server {
623
661
  )[];
624
662
  description: string;
625
663
  simpleType: string;
664
+ /**
665
+ * @param {Host} hostname
666
+ * @returns {Promise<string>}
667
+ */
626
668
  multiple: boolean;
627
669
  };
628
670
  hot: {
@@ -632,10 +674,6 @@ declare class Server {
632
674
  multiple: boolean;
633
675
  description: string;
634
676
  negatedDescription: string;
635
- /**
636
- * @param {"v4" | "v6"} family
637
- * @returns {string | undefined}
638
- */
639
677
  path: string;
640
678
  }
641
679
  | {
@@ -662,10 +700,6 @@ declare class Server {
662
700
  simpleType: string;
663
701
  multiple: boolean;
664
702
  };
665
- /**
666
- * @param {Port} port
667
- * @returns {Promise<number | string>}
668
- */
669
703
  https: {
670
704
  configs: {
671
705
  type: string;
@@ -685,9 +719,6 @@ declare class Server {
685
719
  description: string;
686
720
  path: string;
687
721
  }[];
688
- /**
689
- * @type {string | undefined}
690
- */
691
722
  description: string;
692
723
  simpleType: string;
693
724
  multiple: boolean;
@@ -695,6 +726,9 @@ declare class Server {
695
726
  "https-ca-reset": {
696
727
  configs: {
697
728
  description: string;
729
+ /**
730
+ * @type {string[]}
731
+ */
698
732
  multiple: boolean;
699
733
  path: string;
700
734
  type: string;
@@ -719,7 +753,7 @@ declare class Server {
719
753
  description: string;
720
754
  multiple: boolean;
721
755
  path: string;
722
- /** @type {WebSocketURL} */ type: string;
756
+ type: string;
723
757
  }[];
724
758
  description: string;
725
759
  multiple: boolean;
@@ -829,7 +863,7 @@ declare class Server {
829
863
  type: string;
830
864
  multiple: boolean;
831
865
  description: string;
832
- negatedDescription: string;
866
+ /** @type {Object<string,string>} */ negatedDescription: string;
833
867
  path: string;
834
868
  }[];
835
869
  description: string;
@@ -841,12 +875,13 @@ declare class Server {
841
875
  | {
842
876
  type: string;
843
877
  multiple: boolean;
878
+ /** @type {any} */
844
879
  description: string;
845
880
  path: string;
846
881
  }
847
882
  | {
848
883
  type: string;
849
- /** @type {Object<string,string>} */ values: boolean[];
884
+ /** @type {any} */ values: boolean[];
850
885
  multiple: boolean;
851
886
  description: string;
852
887
  path: string;
@@ -896,7 +931,7 @@ declare class Server {
896
931
  path: string;
897
932
  }
898
933
  )[];
899
- description: string;
934
+ /** @type {Compiler} */ description: string;
900
935
  simpleType: string;
901
936
  multiple: boolean;
902
937
  };
@@ -952,7 +987,7 @@ declare class Server {
952
987
  path: string;
953
988
  }[];
954
989
  description: string;
955
- simpleType: string;
990
+ /** @type {NormalizedStatic} */ simpleType: string;
956
991
  multiple: boolean;
957
992
  };
958
993
  "open-target-reset": {
@@ -1127,8 +1162,9 @@ declare class Server {
1127
1162
  }[];
1128
1163
  description: string;
1129
1164
  multiple: boolean;
1130
- simpleType: string;
1165
+ simpleType: string /** @type {ServerOptions} */;
1131
1166
  };
1167
+ /** @type {ServerOptions} */
1132
1168
  "server-options-request-cert": {
1133
1169
  configs: {
1134
1170
  description: string;
@@ -1164,6 +1200,10 @@ declare class Server {
1164
1200
  | {
1165
1201
  type: string;
1166
1202
  multiple: boolean;
1203
+ /**
1204
+ * @param {string | Buffer | undefined} item
1205
+ * @returns {string | Buffer | undefined}
1206
+ */
1167
1207
  description: string;
1168
1208
  negatedDescription: string;
1169
1209
  path: string;
@@ -1180,7 +1220,7 @@ declare class Server {
1180
1220
  description: string;
1181
1221
  path: string;
1182
1222
  }[];
1183
- description: string;
1223
+ /** @type {any} */ description: string;
1184
1224
  simpleType: string;
1185
1225
  multiple: boolean;
1186
1226
  };
@@ -1287,7 +1327,9 @@ declare class Server {
1287
1327
  type: string;
1288
1328
  }
1289
1329
  )[];
1330
+ /** @type {ServerOptions & { cacert?: ServerOptions["ca"] }} */
1290
1331
  description: string;
1332
+ /** @type {ServerOptions} */
1291
1333
  simpleType: string;
1292
1334
  multiple: boolean;
1293
1335
  };
@@ -1603,6 +1645,10 @@ declare class Server {
1603
1645
  negatedDescription: string;
1604
1646
  };
1605
1647
  };
1648
+ trustedTypesPolicyName: {
1649
+ description: string;
1650
+ type: string;
1651
+ };
1606
1652
  };
1607
1653
  description?: undefined;
1608
1654
  link?: undefined;
@@ -1621,21 +1667,103 @@ declare class Server {
1621
1667
  ClientReconnect: {
1622
1668
  description: string;
1623
1669
  link: string;
1624
- /**
1625
- * @callback ByPass
1626
- * @param {Request} req
1627
- * @param {Response} res
1628
- * @param {ProxyConfigArrayItem} proxyConfig
1629
- */
1630
- /**
1631
- * @typedef {{ path?: HttpProxyMiddlewareOptionsFilter | undefined, context?: HttpProxyMiddlewareOptionsFilter | undefined } & { bypass?: ByPass } & HttpProxyMiddlewareOptions } ProxyConfigArrayItem
1632
- */
1633
- /**
1634
- * @typedef {(ProxyConfigArrayItem | ((req?: Request | undefined, res?: Response | undefined, next?: NextFunction | undefined) => ProxyConfigArrayItem))[]} ProxyConfigArray
1635
- */
1636
- /**
1637
- * @typedef {{ [url: string]: string | ProxyConfigArrayItem }} ProxyConfigMap
1638
- */
1670
+ anyOf: (
1671
+ | {
1672
+ /**
1673
+ * @typedef {{ path?: HttpProxyMiddlewareOptionsFilter | undefined, context?: HttpProxyMiddlewareOptionsFilter | undefined } & { bypass?: ByPass } & HttpProxyMiddlewareOptions } ProxyConfigArrayItem
1674
+ */
1675
+ /**
1676
+ * @typedef {(ProxyConfigArrayItem | ((req?: Request | undefined, res?: Response | undefined, next?: NextFunction | undefined) => ProxyConfigArrayItem))[]} ProxyConfigArray
1677
+ */
1678
+ /**
1679
+ * @typedef {{ [url: string]: string | ProxyConfigArrayItem }} ProxyConfigMap
1680
+ */
1681
+ /**
1682
+ * @typedef {Object} OpenApp
1683
+ * @property {string} [name]
1684
+ * @property {string[]} [arguments]
1685
+ */
1686
+ /**
1687
+ * @typedef {Object} Open
1688
+ * @property {string | string[] | OpenApp} [app]
1689
+ * @property {string | string[]} [target]
1690
+ */
1691
+ /**
1692
+ * @typedef {Object} NormalizedOpen
1693
+ * @property {string} target
1694
+ * @property {import("open").Options} options
1695
+ */
1696
+ /**
1697
+ * @typedef {Object} WebSocketURL
1698
+ * @property {string} [hostname]
1699
+ * @property {string} [password]
1700
+ * @property {string} [pathname]
1701
+ * @property {number | string} [port]
1702
+ * @property {string} [protocol]
1703
+ * @property {string} [username]
1704
+ */
1705
+ /**
1706
+ * @typedef {Object} ClientConfiguration
1707
+ * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging]
1708
+ * @property {boolean | { warnings?: boolean, errors?: boolean }} [overlay]
1709
+ * @property {boolean} [progress]
1710
+ * @property {boolean | number} [reconnect]
1711
+ * @property {"ws" | "sockjs" | string} [webSocketTransport]
1712
+ * @property {string | WebSocketURL} [webSocketURL]
1713
+ */
1714
+ /**
1715
+ * @typedef {Array<{ key: string; value: string }> | Record<string, string | string[]>} Headers
1716
+ */
1717
+ /**
1718
+ * @typedef {{ name?: string, path?: string, middleware: ExpressRequestHandler | ExpressErrorRequestHandler } | ExpressRequestHandler | ExpressErrorRequestHandler} Middleware
1719
+ */
1720
+ /**
1721
+ * @typedef {Object} Configuration
1722
+ * @property {boolean | string} [ipc]
1723
+ * @property {Host} [host]
1724
+ * @property {Port} [port]
1725
+ * @property {boolean | "only"} [hot]
1726
+ * @property {boolean} [liveReload]
1727
+ * @property {DevMiddlewareOptions<Request, Response>} [devMiddleware]
1728
+ * @property {boolean} [compress]
1729
+ * @property {boolean} [magicHtml]
1730
+ * @property {"auto" | "all" | string | string[]} [allowedHosts]
1731
+ * @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback]
1732
+ * @property {boolean} [setupExitSignals]
1733
+ * @property {boolean | Record<string, never> | BonjourOptions} [bonjour]
1734
+ * @property {string | string[] | WatchFiles | Array<string | WatchFiles>} [watchFiles]
1735
+ * @property {boolean | string | Static | Array<string | Static>} [static]
1736
+ * @property {boolean | ServerOptions} [https]
1737
+ * @property {boolean} [http2]
1738
+ * @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server]
1739
+ * @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer]
1740
+ * @property {ProxyConfigMap | ProxyConfigArrayItem | ProxyConfigArray} [proxy]
1741
+ * @property {boolean | string | Open | Array<string | Open>} [open]
1742
+ * @property {boolean} [setupExitSignals]
1743
+ * @property {boolean | ClientConfiguration} [client]
1744
+ * @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response>) => Headers)} [headers]
1745
+ * @property {(devServer: Server) => void} [onAfterSetupMiddleware]
1746
+ * @property {(devServer: Server) => void} [onBeforeSetupMiddleware]
1747
+ * @property {(devServer: Server) => void} [onListening]
1748
+ * @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares]
1749
+ */
1750
+ type: string;
1751
+ cli: {
1752
+ negatedDescription: string;
1753
+ };
1754
+ minimum?: undefined;
1755
+ }
1756
+ | {
1757
+ type: string;
1758
+ minimum: number;
1759
+ cli?: undefined /** @typedef {import("express").Request} Request */;
1760
+ }
1761
+ )[];
1762
+ };
1763
+ ClientWebSocketTransport: {
1764
+ anyOf: {
1765
+ $ref: string;
1766
+ }[];
1639
1767
  /**
1640
1768
  * @typedef {Object} OpenApp
1641
1769
  * @property {string} [name]
@@ -1705,25 +1833,6 @@ declare class Server {
1705
1833
  * @property {(devServer: Server) => void} [onListening]
1706
1834
  * @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares]
1707
1835
  */
1708
- anyOf: (
1709
- | {
1710
- type: string;
1711
- cli: {
1712
- negatedDescription: string;
1713
- };
1714
- minimum?: undefined;
1715
- }
1716
- | {
1717
- type: string;
1718
- minimum: number;
1719
- cli?: undefined /** @typedef {import("express").Request} Request */;
1720
- }
1721
- )[];
1722
- };
1723
- ClientWebSocketTransport: {
1724
- anyOf: {
1725
- $ref: string;
1726
- }[];
1727
1836
  description: string;
1728
1837
  link: string;
1729
1838
  };
@@ -1733,6 +1842,15 @@ declare class Server {
1733
1842
  ClientWebSocketTransportString: {
1734
1843
  type: string;
1735
1844
  minLength: number;
1845
+ /**
1846
+ * @typedef {Object} WebSocketURL
1847
+ * @property {string} [hostname]
1848
+ * @property {string} [password]
1849
+ * @property {string} [pathname]
1850
+ * @property {number | string} [port]
1851
+ * @property {string} [protocol]
1852
+ * @property {string} [username]
1853
+ */
1736
1854
  };
1737
1855
  ClientWebSocketURL: {
1738
1856
  description: string;
@@ -1757,9 +1875,6 @@ declare class Server {
1757
1875
  description: string;
1758
1876
  type: string;
1759
1877
  };
1760
- /**
1761
- * @typedef {Array<{ key: string; value: string }> | Record<string, string | string[]>} Headers
1762
- */
1763
1878
  password: {
1764
1879
  description: string;
1765
1880
  type: string;
@@ -1873,10 +1988,6 @@ declare class Server {
1873
1988
  }
1874
1989
  | {
1875
1990
  instanceof: string;
1876
- /**
1877
- * @private
1878
- * @type {RequestHandler[]}
1879
- */
1880
1991
  type?: undefined;
1881
1992
  items?: undefined;
1882
1993
  }
@@ -1946,6 +2057,10 @@ declare class Server {
1946
2057
  description: string;
1947
2058
  };
1948
2059
  crl: {
2060
+ /**
2061
+ * @param {"v4" | "v6"} family
2062
+ * @returns {Promise<string | undefined>}
2063
+ */
1949
2064
  anyOf: (
1950
2065
  | {
1951
2066
  type: string;
@@ -2100,7 +2215,7 @@ declare class Server {
2100
2215
  }
2101
2216
  )[];
2102
2217
  description: string;
2103
- link: string;
2218
+ link: string /** @type {WebSocketURL} */;
2104
2219
  };
2105
2220
  HistoryApiFallback: {
2106
2221
  anyOf: (
@@ -2116,11 +2231,12 @@ declare class Server {
2116
2231
  type: string;
2117
2232
  description: string;
2118
2233
  link: string;
2234
+ /** @type {string} */
2119
2235
  cli?: undefined /** @typedef {import("express").Request} Request */;
2120
2236
  }
2121
2237
  )[];
2122
2238
  description: string;
2123
- /** @type {string} */ link: string;
2239
+ link: string;
2124
2240
  };
2125
2241
  Host: {
2126
2242
  description: string;
@@ -2258,6 +2374,12 @@ declare class Server {
2258
2374
  anyOf: (
2259
2375
  | {
2260
2376
  type: string;
2377
+ /**
2378
+ * prependEntry Method for webpack 4
2379
+ * @param {any} originalEntry
2380
+ * @param {any} newAdditionalEntries
2381
+ * @returns {any}
2382
+ */
2261
2383
  items: {
2262
2384
  type: string;
2263
2385
  minLength: number;
@@ -2299,6 +2421,7 @@ declare class Server {
2299
2421
  };
2300
2422
  };
2301
2423
  };
2424
+ /** @type {any} */
2302
2425
  OpenString: {
2303
2426
  type: string;
2304
2427
  minLength: number;
@@ -2346,7 +2469,7 @@ declare class Server {
2346
2469
  }
2347
2470
  | {
2348
2471
  instanceof: string;
2349
- /** @type {string} */ type?: undefined;
2472
+ type?: undefined;
2350
2473
  }
2351
2474
  )[];
2352
2475
  };
@@ -2508,6 +2631,7 @@ declare class Server {
2508
2631
  anyOf: (
2509
2632
  | {
2510
2633
  type: string;
2634
+ /** @type {NormalizedStatic} */
2511
2635
  instanceof?: undefined;
2512
2636
  }
2513
2637
  | {
@@ -2812,7 +2936,7 @@ declare class Server {
2812
2936
  }
2813
2937
  )[];
2814
2938
  cli: {
2815
- description: string;
2939
+ description: string /** @type {any} */;
2816
2940
  };
2817
2941
  };
2818
2942
  WebSocketServerFunction: {
@@ -2850,7 +2974,6 @@ declare class Server {
2850
2974
  $ref: string;
2851
2975
  };
2852
2976
  client: {
2853
- /** @type {any} */
2854
2977
  $ref: string;
2855
2978
  };
2856
2979
  compress: {
@@ -2951,9 +3074,10 @@ declare class Server {
2951
3074
  static getHostname(hostname: Host): Promise<string>;
2952
3075
  /**
2953
3076
  * @param {Port} port
3077
+ * @param {string} host
2954
3078
  * @returns {Promise<number | string>}
2955
3079
  */
2956
- static getFreePort(port: Port): Promise<number | string>;
3080
+ static getFreePort(port: Port, host: string): Promise<number | string>;
2957
3081
  /**
2958
3082
  * @returns {string}
2959
3083
  */
@@ -0,0 +1,10 @@
1
+ export = getPorts;
2
+ /**
3
+ * @param {number} basePort
4
+ * @param {string=} host
5
+ * @return {Promise<number>}
6
+ */
7
+ declare function getPorts(
8
+ basePort: number,
9
+ host?: string | undefined
10
+ ): Promise<number>;