From dca2366e22a262e6052dae060c8b237f4e6fd26b Mon Sep 17 00:00:00 2001 From: Malcolm Kee Date: Sat, 18 Mar 2023 09:07:34 +1100 Subject: [PATCH] feat: added `client.overlay.runtimeErrors` option to control runtime errors (#4773) --- bin/cli-flags.js | 17 + client-src/index.js | 23 +- client-src/overlay.js | 40 +- lib/Server.js | 2 +- lib/options.json | 7 + .../validate-options.test.js.snap.webpack4 | 6 +- .../validate-options.test.js.snap.webpack5 | 6 +- .../__snapshots__/basic.test.js.snap.webpack4 | 2 + .../__snapshots__/basic.test.js.snap.webpack5 | 2 + types/bin/cli-flags.d.ts | 12 + types/lib/Server.d.ts | 355 ++++++++---------- 11 files changed, 251 insertions(+), 221 deletions(-) diff --git a/bin/cli-flags.js b/bin/cli-flags.js index ab968c5730..d32c38cbb0 100644 --- a/bin/cli-flags.js +++ b/bin/cli-flags.js @@ -153,6 +153,23 @@ module.exports = { simpleType: "boolean", multiple: false, }, + "client-overlay-runtime-errors": { + configs: [ + { + type: "boolean", + multiple: false, + description: + "Enables a full-screen overlay in the browser when there are uncaught runtime errors.", + negatedDescription: + "Disables the full-screen overlay in the browser when there are uncaught runtime errors.", + path: "client.overlay.runtimeErrors", + }, + ], + description: + "Enables a full-screen overlay in the browser when there are uncaught runtime errors.", + simpleType: "boolean", + multiple: false, + }, "client-progress": { configs: [ { diff --git a/client-src/index.js b/client-src/index.js index 981bb99ee8..4689552d9e 100644 --- a/client-src/index.js +++ b/client-src/index.js @@ -15,7 +15,7 @@ import createSocketURL from "./utils/createSocketURL.js"; * @property {boolean} hot * @property {boolean} liveReload * @property {boolean} progress - * @property {boolean | { warnings?: boolean, errors?: boolean, trustedTypesPolicyName?: string }} overlay + * @property {boolean | { warnings?: boolean, errors?: boolean, runtimeErrors?: boolean, trustedTypesPolicyName?: string }} overlay * @property {string} [logging] * @property {number} [reconnect] */ @@ -80,6 +80,7 @@ if (parsedResourceQuery.overlay) { options.overlay = { errors: true, warnings: true, + runtimeErrors: true, ...options.overlay, }; } @@ -115,12 +116,20 @@ self.addEventListener("beforeunload", () => { status.isUnloading = true; }); -const trustedTypesPolicyName = - typeof options.overlay === "object" && options.overlay.trustedTypesPolicyName; - -const overlay = createOverlay({ - trustedTypesPolicyName, -}); +const overlay = + typeof window !== "undefined" + ? createOverlay( + typeof options.overlay === "object" + ? { + trustedTypesPolicyName: options.overlay.trustedTypesPolicyName, + catchRuntimeError: options.overlay.runtimeErrors, + } + : { + trustedTypesPolicyName: false, + catchRuntimeError: options.overlay, + } + ) + : { send: () => {} }; const onSocketMessage = { hot() { diff --git a/client-src/overlay.js b/client-src/overlay.js index a46300a61b..2887c28ad3 100644 --- a/client-src/overlay.js +++ b/client-src/overlay.js @@ -78,6 +78,7 @@ function formatProblem(type, item) { /** * @typedef {Object} CreateOverlayOptions * @property {string | null} trustedTypesPolicyName + * @property {boolean} [catchRuntimeError] */ /** @@ -271,24 +272,29 @@ const createOverlay = (options) => { hideOverlay: hide, }); - listenToRuntimeError((errorEvent) => { - // error property may be empty in older browser like IE - const { error, message } = errorEvent; - if (!error && !message) { - return; - } - const errorObject = - error instanceof Error ? error : new Error(error || message); - overlayService.send({ - type: "RUNTIME_ERROR", - messages: [ - { - message: errorObject.message, - stack: parseErrorToStacks(errorObject), - }, - ], + if (options.catchRuntimeError) { + listenToRuntimeError((errorEvent) => { + // error property may be empty in older browser like IE + const { error, message } = errorEvent; + + if (!error && !message) { + return; + } + + const errorObject = + error instanceof Error ? error : new Error(error || message); + + overlayService.send({ + type: "RUNTIME_ERROR", + messages: [ + { + message: errorObject.message, + stack: parseErrorToStacks(errorObject), + }, + ], + }); }); - }); + } return overlayService; }; diff --git a/lib/Server.js b/lib/Server.js index 6b47cb686b..573707d640 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -159,7 +159,7 @@ const schema = require("./options.json"); /** * @typedef {Object} ClientConfiguration * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging] - * @property {boolean | { warnings?: boolean, errors?: boolean }} [overlay] + * @property {boolean | { warnings?: boolean, errors?: boolean, runtimeErrors?: boolean }} [overlay] * @property {boolean} [progress] * @property {boolean | number} [reconnect] * @property {"ws" | "sockjs" | string} [webSocketTransport] diff --git a/lib/options.json b/lib/options.json index ad49a930d7..87ac7e1fb3 100644 --- a/lib/options.json +++ b/lib/options.json @@ -111,6 +111,13 @@ "negatedDescription": "Disables the full-screen overlay in the browser when there are compiler warnings." } }, + "runtimeErrors": { + "description": "Enables a full-screen overlay in the browser when there are uncaught runtime errors.", + "type": "boolean", + "cli": { + "negatedDescription": "Disables the full-screen overlay in the browser when there are uncaught runtime errors." + } + }, "trustedTypesPolicyName": { "description": "The name of a Trusted Types policy for the overlay. Defaults to 'webpack-dev-server#overlay'.", "type": "string" diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack4 b/test/__snapshots__/validate-options.test.js.snap.webpack4 index 04f19dc2d9..2a5ed5e47d 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack4 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack4 @@ -90,19 +90,19 @@ exports[`options validate should throw an error on the "client" option with '{"o -> Read more at https://webpack.js.org/configuration/dev-server/#devserverclient Details: * options.client.overlay should be one of these: - boolean | object { errors?, warnings?, trustedTypesPolicyName? } + boolean | object { errors?, warnings?, runtimeErrors?, trustedTypesPolicyName? } Details: * options.client.overlay should be a boolean. -> Enables a full-screen overlay in the browser when there are compiler errors or warnings. -> Read more at https://webpack.js.org/configuration/dev-server/#overlay * options.client.overlay should be an object: - object { errors?, warnings?, trustedTypesPolicyName? }" + object { errors?, warnings?, runtimeErrors?, trustedTypesPolicyName? }" `; exports[`options validate should throw an error on the "client" option with '{"overlay":{"arbitrary":""}}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.client.overlay has an unknown property 'arbitrary'. These properties are valid: - object { errors?, warnings?, trustedTypesPolicyName? }" + object { errors?, warnings?, runtimeErrors?, trustedTypesPolicyName? }" `; exports[`options validate should throw an error on the "client" option with '{"overlay":{"errors":""}}' value 1`] = ` diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack5 b/test/__snapshots__/validate-options.test.js.snap.webpack5 index 04f19dc2d9..2a5ed5e47d 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack5 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack5 @@ -90,19 +90,19 @@ exports[`options validate should throw an error on the "client" option with '{"o -> Read more at https://webpack.js.org/configuration/dev-server/#devserverclient Details: * options.client.overlay should be one of these: - boolean | object { errors?, warnings?, trustedTypesPolicyName? } + boolean | object { errors?, warnings?, runtimeErrors?, trustedTypesPolicyName? } Details: * options.client.overlay should be a boolean. -> Enables a full-screen overlay in the browser when there are compiler errors or warnings. -> Read more at https://webpack.js.org/configuration/dev-server/#overlay * options.client.overlay should be an object: - object { errors?, warnings?, trustedTypesPolicyName? }" + object { errors?, warnings?, runtimeErrors?, trustedTypesPolicyName? }" `; exports[`options validate should throw an error on the "client" option with '{"overlay":{"arbitrary":""}}' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.client.overlay has an unknown property 'arbitrary'. These properties are valid: - object { errors?, warnings?, trustedTypesPolicyName? }" + object { errors?, warnings?, runtimeErrors?, trustedTypesPolicyName? }" `; exports[`options validate should throw an error on the "client" option with '{"overlay":{"errors":""}}' value 1`] = ` diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack4 b/test/cli/__snapshots__/basic.test.js.snap.webpack4 index 638c0af0cb..203c182fe7 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack4 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack4 @@ -67,6 +67,8 @@ Options: --client-overlay-trusted-types-policy-name The name of a Trusted Types policy for the overlay. Defaults to 'webpack-dev-server#overlay'. --client-overlay-warnings Enables a full-screen overlay in the browser when there are compiler warnings. --no-client-overlay-warnings Disables the full-screen overlay in the browser when there are compiler warnings. + --client-overlay-runtime-errors Enables a full-screen overlay in the browser when there are uncaught runtime errors. + --no-client-overlay-runtime-errors Disables the full-screen overlay in the browser when there are uncaught runtime errors. --client-progress Prints compilation progress in percentage in the browser. --no-client-progress Does not print compilation progress in percentage in the browser. --client-reconnect [value] Tells dev-server the number of times it should try to reconnect the client. diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack5 b/test/cli/__snapshots__/basic.test.js.snap.webpack5 index ee50ea5895..2c53b7d7a5 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack5 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack5 @@ -67,6 +67,8 @@ Options: --no-client-overlay-errors Disables the full-screen overlay in the browser when there are compiler errors. --client-overlay-warnings Enables a full-screen overlay in the browser when there are compiler warnings. --no-client-overlay-warnings Disables the full-screen overlay in the browser when there are compiler warnings. + --client-overlay-runtime-errors Enables a full-screen overlay in the browser when there are uncaught runtime errors. + --no-client-overlay-runtime-errors Disables the full-screen overlay in the browser when there are uncaught runtime errors. --client-overlay-trusted-types-policy-name The name of a Trusted Types policy for the overlay. Defaults to 'webpack-dev-server#overlay'. --client-progress Prints compilation progress in percentage in the browser. --no-client-progress Does not print compilation progress in percentage in the browser. diff --git a/types/bin/cli-flags.d.ts b/types/bin/cli-flags.d.ts index ac17b73866..e8553ac5f6 100644 --- a/types/bin/cli-flags.d.ts +++ b/types/bin/cli-flags.d.ts @@ -114,6 +114,18 @@ declare const _exports: { simpleType: string; multiple: boolean; }; + "client-overlay-runtime-errors": { + configs: { + type: string; + multiple: boolean; + description: string; + negatedDescription: string; + path: string; + }[]; + description: string; + simpleType: string; + multiple: boolean; + }; "client-progress": { configs: { type: string; diff --git a/types/lib/Server.d.ts b/types/lib/Server.d.ts index 6b43dba39b..2608f1ec11 100644 --- a/types/lib/Server.d.ts +++ b/types/lib/Server.d.ts @@ -138,7 +138,7 @@ declare class Server { /** * @typedef {Object} ClientConfiguration * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging] - * @property {boolean | { warnings?: boolean, errors?: boolean }} [overlay] + * @property {boolean | { warnings?: boolean, errors?: boolean, runtimeErrors?: boolean }} [overlay] * @property {boolean} [progress] * @property {boolean | number} [reconnect] * @property {"ws" | "sockjs" | string} [webSocketTransport] @@ -316,7 +316,7 @@ declare class Server { /** * @typedef {Object} ClientConfiguration * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging] - * @property {boolean | { warnings?: boolean, errors?: boolean }} [overlay] + * @property {boolean | { warnings?: boolean, errors?: boolean, runtimeErrors?: boolean }} [overlay] * @property {boolean} [progress] * @property {boolean | number} [reconnect] * @property {"ws" | "sockjs" | string} [webSocketTransport] @@ -416,6 +416,82 @@ declare class Server { simpleType: string; multiple: boolean; }; + "client-overlay-runtime-errors": { + configs: { + type: string; + multiple: boolean; + description: string; + /** + * @typedef {Object} Open + * @property {string | string[] | OpenApp} [app] + * @property {string | string[]} [target] + */ + /** + * @typedef {Object} NormalizedOpen + * @property {string} target + * @property {import("open").Options} options + */ + /** + * @typedef {Object} WebSocketURL + * @property {string} [hostname] + * @property {string} [password] + * @property {string} [pathname] + * @property {number | string} [port] + * @property {string} [protocol] + * @property {string} [username] + */ + /** + * @typedef {Object} ClientConfiguration + * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging] + * @property {boolean | { warnings?: boolean, errors?: boolean, runtimeErrors?: boolean }} [overlay] + * @property {boolean} [progress] + * @property {boolean | number} [reconnect] + * @property {"ws" | "sockjs" | string} [webSocketTransport] + * @property {string | WebSocketURL} [webSocketURL] + */ + /** + * @typedef {Array<{ key: string; value: string }> | Record} Headers + */ + /** + * @typedef {{ name?: string, path?: string, middleware: ExpressRequestHandler | ExpressErrorRequestHandler } | ExpressRequestHandler | ExpressErrorRequestHandler} Middleware + */ + /** + * @typedef {Object} Configuration + * @property {boolean | string} [ipc] + * @property {Host} [host] + * @property {Port} [port] + * @property {boolean | "only"} [hot] + * @property {boolean} [liveReload] + * @property {DevMiddlewareOptions} [devMiddleware] + * @property {boolean} [compress] + * @property {boolean} [magicHtml] + * @property {"auto" | "all" | string | string[]} [allowedHosts] + * @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback] + * @property {boolean} [setupExitSignals] + * @property {boolean | Record | BonjourOptions} [bonjour] + * @property {string | string[] | WatchFiles | Array} [watchFiles] + * @property {boolean | string | Static | Array} [static] + * @property {boolean | ServerOptions} [https] + * @property {boolean} [http2] + * @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server] + * @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer] + * @property {ProxyConfigMap | ProxyConfigArrayItem | ProxyConfigArray} [proxy] + * @property {boolean | string | Open | Array} [open] + * @property {boolean} [setupExitSignals] + * @property {boolean | ClientConfiguration} [client] + * @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext) => Headers)} [headers] + * @property {(devServer: Server) => void} [onAfterSetupMiddleware] + * @property {(devServer: Server) => void} [onBeforeSetupMiddleware] + * @property {(devServer: Server) => void} [onListening] + * @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares] + */ + negatedDescription: string; + path: string; + }[]; + description: string; + simpleType: string; + multiple: boolean; + }; "client-progress": { configs: { type: string; @@ -428,60 +504,6 @@ declare class Server { simpleType: string; multiple: boolean; }; - /** - * @typedef {Object} WebSocketURL - * @property {string} [hostname] - * @property {string} [password] - * @property {string} [pathname] - * @property {number | string} [port] - * @property {string} [protocol] - * @property {string} [username] - */ - /** - * @typedef {Object} ClientConfiguration - * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging] - * @property {boolean | { warnings?: boolean, errors?: boolean }} [overlay] - * @property {boolean} [progress] - * @property {boolean | number} [reconnect] - * @property {"ws" | "sockjs" | string} [webSocketTransport] - * @property {string | WebSocketURL} [webSocketURL] - */ - /** - * @typedef {Array<{ key: string; value: string }> | Record} Headers - */ - /** - * @typedef {{ name?: string, path?: string, middleware: ExpressRequestHandler | ExpressErrorRequestHandler } | ExpressRequestHandler | ExpressErrorRequestHandler} Middleware - */ - /** - * @typedef {Object} Configuration - * @property {boolean | string} [ipc] - * @property {Host} [host] - * @property {Port} [port] - * @property {boolean | "only"} [hot] - * @property {boolean} [liveReload] - * @property {DevMiddlewareOptions} [devMiddleware] - * @property {boolean} [compress] - * @property {boolean} [magicHtml] - * @property {"auto" | "all" | string | string[]} [allowedHosts] - * @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback] - * @property {boolean} [setupExitSignals] - * @property {boolean | Record | BonjourOptions} [bonjour] - * @property {string | string[] | WatchFiles | Array} [watchFiles] - * @property {boolean | string | Static | Array} [static] - * @property {boolean | ServerOptions} [https] - * @property {boolean} [http2] - * @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server] - * @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer] - * @property {ProxyConfigMap | ProxyConfigArrayItem | ProxyConfigArray} [proxy] - * @property {boolean | string | Open | Array} [open] - * @property {boolean} [setupExitSignals] - * @property {boolean | ClientConfiguration} [client] - * @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext) => Headers)} [headers] - * @property {(devServer: Server) => void} [onAfterSetupMiddleware] - * @property {(devServer: Server) => void} [onBeforeSetupMiddleware] - * @property {(devServer: Server) => void} [onListening] - * @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares] - */ "client-reconnect": { configs: ( | { @@ -540,6 +562,10 @@ declare class Server { description: string; path: string; }[]; + /** + * @param {Configuration | Compiler | MultiCompiler} options + * @param {Compiler | MultiCompiler | Configuration} compiler + */ description: string; simpleType: string; multiple: boolean; @@ -565,18 +591,22 @@ declare class Server { description: string; simpleType: string; multiple: boolean; + /** + * @type {FSWatcher[]} + */ }; "client-web-socket-url-port": { configs: { type: string; multiple: boolean; description: string; + /** + * @private + * @type {RequestHandler[]} + */ path: string; }[]; description: string; - /** - * @type {FSWatcher[]} - */ simpleType: string; multiple: boolean; }; @@ -611,10 +641,6 @@ declare class Server { simpleType: string; multiple: boolean; }; - /** - * @param {string} URL - * @returns {boolean} - */ compress: { configs: { type: string; @@ -625,10 +651,6 @@ declare class Server { }[]; description: string; simpleType: string; - /** - * @param {string} gateway - * @returns {string | undefined} - */ multiple: boolean; }; "history-api-fallback": { @@ -661,10 +683,6 @@ declare class Server { )[]; description: string; simpleType: string; - /** - * @param {Host} hostname - * @returns {Promise} - */ multiple: boolean; }; hot: { @@ -754,6 +772,7 @@ declare class Server { }[]; description: string; multiple: boolean; + /** @type {ServerConfiguration} */ simpleType: string; }; "https-cert": { @@ -761,10 +780,10 @@ declare class Server { type: string; multiple: boolean; description: string; - path: string /** @type {string} */; + path: string; }[]; description: string; - simpleType: string; + /** @type {string} */ simpleType: string; multiple: boolean; }; "https-cert-reset": { @@ -796,7 +815,7 @@ declare class Server { path: string; type: string; }[]; - /** @type {number | string} */ description: string; + description: string; multiple: boolean; simpleType: string; }; @@ -818,7 +837,7 @@ declare class Server { path: string; type: string; }[]; - /** @type {string} */ description: string; + description: string; multiple: boolean; simpleType: string; }; @@ -886,13 +905,8 @@ declare class Server { description: string; simpleType: string; multiple: boolean; - /** - * prependEntry Method for webpack 4 - * @param {any} originalEntry - * @param {any} newAdditionalEntries - * @returns {any} - */ }; + /** @type {Object} */ "live-reload": { configs: { type: string; @@ -954,6 +968,10 @@ declare class Server { multiple: boolean; description: string; path: string; + /** + * @private + * @returns {Promise} + */ }[]; description: string; simpleType: string; @@ -964,7 +982,7 @@ declare class Server { type: string; multiple: boolean; description: string; - path: string /** @type {Compiler} */; + path: string; }[]; description: string; simpleType: string; @@ -1206,8 +1224,8 @@ declare class Server { path: string; } )[]; - /** @type {ServerOptions} */ description: string; - /** @type {Array} */ simpleType: string; + description: string; + simpleType: string; multiple: boolean; }; "static-directory": { @@ -1218,6 +1236,10 @@ declare class Server { path: string; }[]; description: string; + /** + * @param {string | Buffer | undefined} item + * @returns {string | Buffer | undefined} + */ simpleType: string; multiple: boolean; }; @@ -1230,7 +1252,7 @@ declare class Server { }[]; description: string; simpleType: string; - multiple: boolean; + multiple: boolean /** @type {any} */; }; "static-public-path-reset": { configs: { @@ -1248,7 +1270,7 @@ declare class Server { type: string; multiple: boolean; description: string; - path: string /** @type {ServerOptions} */; + path: string; }[]; description: string; simpleType: string; @@ -1542,7 +1564,7 @@ declare class Server { /** * @typedef {Object} ClientConfiguration * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging] - * @property {boolean | { warnings?: boolean, errors?: boolean }} [overlay] + * @property {boolean | { warnings?: boolean, errors?: boolean, runtimeErrors?: boolean }} [overlay] * @property {boolean} [progress] * @property {boolean | number} [reconnect] * @property {"ws" | "sockjs" | string} [webSocketTransport] @@ -1640,6 +1662,13 @@ declare class Server { negatedDescription: string; }; }; + runtimeErrors: { + description: string; + type: string; + cli: { + negatedDescription: string; + }; + }; trustedTypesPolicyName: { description: string; type: string; @@ -1664,15 +1693,7 @@ declare class Server { link: string; anyOf: ( | { - /** - * @typedef {{ path?: HttpProxyMiddlewareOptionsFilter | undefined, context?: HttpProxyMiddlewareOptionsFilter | undefined } & { bypass?: ByPass } & HttpProxyMiddlewareOptions } ProxyConfigArrayItem - */ - /** - * @typedef {(ProxyConfigArrayItem | ((req?: Request | undefined, res?: Response | undefined, next?: NextFunction | undefined) => ProxyConfigArrayItem))[]} ProxyConfigArray - */ - /** - * @typedef {{ [url: string]: string | ProxyConfigArrayItem }} ProxyConfigMap - */ + type: string; /** * @typedef {Object} OpenApp * @property {string} [name] @@ -1700,7 +1721,7 @@ declare class Server { /** * @typedef {Object} ClientConfiguration * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging] - * @property {boolean | { warnings?: boolean, errors?: boolean }} [overlay] + * @property {boolean | { warnings?: boolean, errors?: boolean, runtimeErrors?: boolean }} [overlay] * @property {boolean} [progress] * @property {boolean | number} [reconnect] * @property {"ws" | "sockjs" | string} [webSocketTransport] @@ -1742,7 +1763,6 @@ declare class Server { * @property {(devServer: Server) => void} [onListening] * @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares] */ - type: string; cli: { negatedDescription: string; }; @@ -1759,75 +1779,6 @@ declare class Server { anyOf: { $ref: string; }[]; - /** - * @typedef {Object} OpenApp - * @property {string} [name] - * @property {string[]} [arguments] - */ - /** - * @typedef {Object} Open - * @property {string | string[] | OpenApp} [app] - * @property {string | string[]} [target] - */ - /** - * @typedef {Object} NormalizedOpen - * @property {string} target - * @property {import("open").Options} options - */ - /** - * @typedef {Object} WebSocketURL - * @property {string} [hostname] - * @property {string} [password] - * @property {string} [pathname] - * @property {number | string} [port] - * @property {string} [protocol] - * @property {string} [username] - */ - /** - * @typedef {Object} ClientConfiguration - * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging] - * @property {boolean | { warnings?: boolean, errors?: boolean }} [overlay] - * @property {boolean} [progress] - * @property {boolean | number} [reconnect] - * @property {"ws" | "sockjs" | string} [webSocketTransport] - * @property {string | WebSocketURL} [webSocketURL] - */ - /** - * @typedef {Array<{ key: string; value: string }> | Record} Headers - */ - /** - * @typedef {{ name?: string, path?: string, middleware: ExpressRequestHandler | ExpressErrorRequestHandler } | ExpressRequestHandler | ExpressErrorRequestHandler} Middleware - */ - /** - * @typedef {Object} Configuration - * @property {boolean | string} [ipc] - * @property {Host} [host] - * @property {Port} [port] - * @property {boolean | "only"} [hot] - * @property {boolean} [liveReload] - * @property {DevMiddlewareOptions} [devMiddleware] - * @property {boolean} [compress] - * @property {boolean} [magicHtml] - * @property {"auto" | "all" | string | string[]} [allowedHosts] - * @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback] - * @property {boolean} [setupExitSignals] - * @property {boolean | Record | BonjourOptions} [bonjour] - * @property {string | string[] | WatchFiles | Array} [watchFiles] - * @property {boolean | string | Static | Array} [static] - * @property {boolean | ServerOptions} [https] - * @property {boolean} [http2] - * @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server] - * @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer] - * @property {ProxyConfigMap | ProxyConfigArrayItem | ProxyConfigArray} [proxy] - * @property {boolean | string | Open | Array} [open] - * @property {boolean} [setupExitSignals] - * @property {boolean | ClientConfiguration} [client] - * @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext) => Headers)} [headers] - * @property {(devServer: Server) => void} [onAfterSetupMiddleware] - * @property {(devServer: Server) => void} [onBeforeSetupMiddleware] - * @property {(devServer: Server) => void} [onListening] - * @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares] - */ description: string; link: string; }; @@ -1837,15 +1788,6 @@ declare class Server { ClientWebSocketTransportString: { type: string; minLength: number; - /** - * @typedef {Object} WebSocketURL - * @property {string} [hostname] - * @property {string} [password] - * @property {string} [pathname] - * @property {number | string} [port] - * @property {string} [protocol] - * @property {string} [username] - */ }; ClientWebSocketURL: { description: string; @@ -1859,6 +1801,36 @@ declare class Server { } | { type: string; + /** + * @typedef {Object} Configuration + * @property {boolean | string} [ipc] + * @property {Host} [host] + * @property {Port} [port] + * @property {boolean | "only"} [hot] + * @property {boolean} [liveReload] + * @property {DevMiddlewareOptions} [devMiddleware] + * @property {boolean} [compress] + * @property {boolean} [magicHtml] + * @property {"auto" | "all" | string | string[]} [allowedHosts] + * @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback] + * @property {boolean} [setupExitSignals] + * @property {boolean | Record | BonjourOptions} [bonjour] + * @property {string | string[] | WatchFiles | Array} [watchFiles] + * @property {boolean | string | Static | Array} [static] + * @property {boolean | ServerOptions} [https] + * @property {boolean} [http2] + * @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server] + * @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer] + * @property {ProxyConfigMap | ProxyConfigArrayItem | ProxyConfigArray} [proxy] + * @property {boolean | string | Open | Array} [open] + * @property {boolean} [setupExitSignals] + * @property {boolean | ClientConfiguration} [client] + * @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext) => Headers)} [headers] + * @property {(devServer: Server) => void} [onAfterSetupMiddleware] + * @property {(devServer: Server) => void} [onBeforeSetupMiddleware] + * @property {(devServer: Server) => void} [onListening] + * @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares] + */ additionalProperties: boolean; properties: { hostname: { @@ -1957,6 +1929,10 @@ declare class Server { cli: { negatedDescription: string; }; + /** + * @private + * @type {RequestHandler[]} + */ }; ca: { anyOf: ( @@ -2052,10 +2028,6 @@ declare class Server { description: string; }; crl: { - /** - * @param {"v4" | "v6"} family - * @returns {Promise} - */ anyOf: ( | { type: string; @@ -2224,7 +2196,7 @@ declare class Server { } | { type: string; - description: string; + /** @type {WebSocketURL} */ description: string; link: string; cli?: undefined /** @typedef {import("express").Request} Request */; } @@ -2238,7 +2210,7 @@ declare class Server { anyOf: ( | { enum: string[]; - type?: undefined; + /** @type {ServerConfiguration} */ type?: undefined; minLength?: undefined; } | { @@ -2339,7 +2311,6 @@ declare class Server { negatedDescription: string; }; }; - /** @type {ClientConfiguration} */ OpenObject: { type: string; additionalProperties: boolean; @@ -2410,6 +2381,12 @@ declare class Server { }; }; }; + /** + * prependEntry Method for webpack 4 + * @param {any} originalEntry + * @param {any} newAdditionalEntries + * @returns {any} + */ OpenString: { type: string; minLength: number; @@ -2464,13 +2441,13 @@ declare class Server { } )[]; description: string; + /** @type {any} */ link: string; }; Server: { anyOf: { $ref: string; }[]; - /** @type {any} */ link: string; description: string; }; @@ -2492,7 +2469,6 @@ declare class Server { }; ServerObject: { type: string; - /** @type {string} */ properties: { type: { anyOf: { @@ -2500,7 +2476,7 @@ declare class Server { }[]; }; options: { - $ref: string /** @type {MultiCompiler} */; + $ref: string; }; }; additionalProperties: boolean; @@ -2513,7 +2489,6 @@ declare class Server { type: string; description: string; }; - /** @type {MultiCompiler} */ requestCert: { type: string; description: string; @@ -2930,7 +2905,7 @@ declare class Server { }; }; WebSocketServerFunction: { - instanceof: string; + instanceof: string /** @type {ServerOptions} */; }; WebSocketServerObject: { type: string; @@ -2942,7 +2917,6 @@ declare class Server { }; options: { type: string; - /** @type {Array} */ additionalProperties: boolean; cli: { exclude: boolean; @@ -2979,7 +2953,6 @@ declare class Server { historyApiFallback: { $ref: string; }; - /** @type {ServerOptions} */ host: { $ref: string; }; @@ -3001,6 +2974,7 @@ declare class Server { magicHtml: { $ref: string; }; + /** @type {any} */ onAfterSetupMiddleware: { $ref: string; }; @@ -3625,6 +3599,7 @@ type ClientConfiguration = { | { warnings?: boolean | undefined; errors?: boolean | undefined; + runtimeErrors?: boolean | undefined; } | undefined; progress?: boolean | undefined;