diff --git a/bin/cli-flags.js b/bin/cli-flags.js index 1f1376ef75..ab968c5730 100644 --- a/bin/cli-flags.js +++ b/bin/cli-flags.js @@ -121,6 +121,21 @@ module.exports = { simpleType: "boolean", multiple: false, }, + "client-overlay-trusted-types-policy-name": { + configs: [ + { + description: + "The name of a Trusted Types policy for the overlay. Defaults to 'webpack-dev-server#overlay'.", + multiple: false, + path: "client.overlay.trustedTypesPolicyName", + type: "string", + }, + ], + description: + "The name of a Trusted Types policy for the overlay. Defaults to 'webpack-dev-server#overlay'.", + multiple: false, + simpleType: "string", + }, "client-overlay-warnings": { configs: [ { diff --git a/test/cli/__snapshots__/http2-option.test.js.snap.webpack5 b/test/cli/__snapshots__/http2-option.test.js.snap.webpack5 index ec162308f6..02e048a58d 100644 --- a/test/cli/__snapshots__/http2-option.test.js.snap.webpack5 +++ b/test/cli/__snapshots__/http2-option.test.js.snap.webpack5 @@ -1,7 +1,8 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`"http2" CLI option should work using "--http2" 1`] = ` -" [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem +" [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem [webpack-dev-server] Project is running at: Loopback: https://localhost:/, https://:/, https://[]:/ [webpack-dev-server] On Your Network (IPv4): https://:/ diff --git a/test/cli/__snapshots__/https-option.test.js.snap.webpack5 b/test/cli/__snapshots__/https-option.test.js.snap.webpack5 index 759d9931f7..e50636d389 100644 --- a/test/cli/__snapshots__/https-option.test.js.snap.webpack5 +++ b/test/cli/__snapshots__/https-option.test.js.snap.webpack5 @@ -10,7 +10,8 @@ exports[`"https" CLI option should warn using "--https-cacert" and "--https-ca" `; exports[`"https" CLI option should work using "--https" 1`] = ` -" [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem +" [webpack-dev-server] Generating SSL certificate... + [webpack-dev-server] SSL certificate: /node_modules/.cache/webpack-dev-server/server.pem [webpack-dev-server] Project is running at: Loopback: https://localhost:/, https://:/, https://[]:/ [webpack-dev-server] On Your Network (IPv4): https://:/ diff --git a/test/e2e/__snapshots__/hot-and-live-reload.test.js.snap.webpack5 b/test/e2e/__snapshots__/hot-and-live-reload.test.js.snap.webpack5 index 87715569f4..1f46bebeb3 100644 --- a/test/e2e/__snapshots__/hot-and-live-reload.test.js.snap.webpack5 +++ b/test/e2e/__snapshots__/hot-and-live-reload.test.js.snap.webpack5 @@ -54,7 +54,6 @@ exports[`hot and live reload should work and allow to disable live reload using Array [ "[webpack-dev-server] Live Reloading enabled.", "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App updated. Recompiling...", ] `; @@ -267,6 +266,8 @@ Array [ "[webpack-dev-server] App updated. Recompiling...", "[webpack-dev-server] App hot update...", "[HMR] Checking for updates on the server...", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] Nothing changed.", "[HMR] Updated modules:", "[HMR] - ./main.css", "[HMR] - ../../../node_modules/css-loader/dist/cjs.js!./main.css", diff --git a/test/e2e/__snapshots__/overlay.test.js.snap.webpack5 b/test/e2e/__snapshots__/overlay.test.js.snap.webpack5 index c8a56d4012..7c4fdc318b 100644 --- a/test/e2e/__snapshots__/overlay.test.js.snap.webpack5 +++ b/test/e2e/__snapshots__/overlay.test.js.snap.webpack5 @@ -364,6 +364,14 @@ exports[`overlay should not show initially, then show on an error, then show oth " `; +exports[`overlay should not show overlay when Trusted Types are enabled, but policy is not allowed: page html 1`] = ` +" +

webpack-dev-server is running...

+ + +" +`; + exports[`overlay should show a warning after invalidation: overlay html 1`] = ` "
" `; + +exports[`overlay should show overlay when Trusted Types are enabled: overlay html 1`] = ` +" +
+ Compiled with problems:

+
+ ERROR

+
Error from compilation. Can't find 'test' module.
+

+
+
+ +" +`; + +exports[`overlay should show overlay when Trusted Types are enabled: page html 1`] = ` +" +

webpack-dev-server is running...

+ + + + +" +`; diff --git a/test/fixtures/static-config/public/node_modules/index.html b/test/fixtures/static-config/public/node_modules/index.html new file mode 100644 index 0000000000..ba0e162e1c --- /dev/null +++ b/test/fixtures/static-config/public/node_modules/index.html @@ -0,0 +1 @@ +bar \ No newline at end of file diff --git a/types/bin/cli-flags.d.ts b/types/bin/cli-flags.d.ts index fa98132496..ac17b73866 100644 --- a/types/bin/cli-flags.d.ts +++ b/types/bin/cli-flags.d.ts @@ -91,6 +91,17 @@ declare const _exports: { simpleType: string; multiple: boolean; }; + "client-overlay-trusted-types-policy-name": { + configs: { + description: string; + multiple: boolean; + path: string; + type: string; + }[]; + description: string; + multiple: boolean; + simpleType: string; + }; "client-overlay-warnings": { configs: { type: string; diff --git a/types/lib/Server.d.ts b/types/lib/Server.d.ts index 672b7b5413..74cb035570 100644 --- a/types/lib/Server.d.ts +++ b/types/lib/Server.d.ts @@ -393,6 +393,17 @@ declare class Server { simpleType: string; multiple: boolean; }; + "client-overlay-trusted-types-policy-name": { + configs: { + description: string; + multiple: boolean; + path: string; + type: string; + }[]; + description: string; + multiple: boolean; + simpleType: string; + }; "client-overlay-warnings": { configs: { type: string; @@ -417,6 +428,60 @@ 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: ( | { @@ -453,36 +518,6 @@ declare class Server { path: 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] - */ description: string; simpleType: string; multiple: boolean; @@ -539,6 +574,9 @@ declare class Server { path: string; }[]; description: string; + /** + * @type {FSWatcher[]} + */ simpleType: string; multiple: boolean; }; @@ -558,20 +596,12 @@ declare class Server { type: string; } )[]; - /** - * @private - * @type {{ name: string | symbol, listener: (...args: any[]) => void}[] }} - */ description: string; multiple: boolean; simpleType: string; }; "client-web-socket-url-username": { configs: { - /** - * @private - * @type {RequestHandler[]} - */ type: string; multiple: boolean; description: string; @@ -581,6 +611,10 @@ declare class Server { simpleType: string; multiple: boolean; }; + /** + * @param {string} URL + * @returns {boolean} + */ compress: { configs: { type: string; @@ -591,6 +625,10 @@ declare class Server { }[]; description: string; simpleType: string; + /** + * @param {string} gateway + * @returns {string | undefined} + */ multiple: boolean; }; "history-api-fallback": { @@ -623,6 +661,10 @@ declare class Server { )[]; description: string; simpleType: string; + /** + * @param {Host} hostname + * @returns {Promise} + */ multiple: boolean; }; hot: { @@ -632,10 +674,6 @@ declare class Server { multiple: boolean; description: string; negatedDescription: string; - /** - * @param {"v4" | "v6"} family - * @returns {string | undefined} - */ path: string; } | { @@ -662,11 +700,6 @@ declare class Server { simpleType: string; multiple: boolean; }; - /** - * @param {Port} port - * @param {string} host - * @returns {Promise} - */ https: { configs: { type: string; @@ -693,6 +726,9 @@ declare class Server { "https-ca-reset": { configs: { description: string; + /** + * @type {string[]} + */ multiple: boolean; path: string; type: string; @@ -717,7 +753,7 @@ declare class Server { description: string; multiple: boolean; path: string; - type: string /** @type {WebSocketURL} */; + type: string; }[]; description: string; multiple: boolean; @@ -731,7 +767,7 @@ declare class Server { path: string; }[]; description: string; - /** @type {ServerConfiguration} */ simpleType: string; + simpleType: string; multiple: boolean; }; "https-cert-reset": { @@ -827,7 +863,7 @@ declare class Server { type: string; multiple: boolean; description: string; - negatedDescription: string; + /** @type {Object} */ negatedDescription: string; path: string; }[]; description: string; @@ -839,12 +875,13 @@ declare class Server { | { type: string; multiple: boolean; + /** @type {any} */ description: string; path: string; } | { type: string; - values: boolean[]; + /** @type {any} */ values: boolean[]; multiple: boolean; description: string; path: string; @@ -894,7 +931,7 @@ declare class Server { path: string; } )[]; - description: string; + /** @type {Compiler} */ description: string; simpleType: string; multiple: boolean; }; @@ -906,10 +943,6 @@ declare class Server { path: string; }[]; description: string; - /** - * @private - * @returns {Promise} - */ simpleType: string; multiple: boolean; }; @@ -954,13 +987,9 @@ declare class Server { path: string; }[]; description: string; - simpleType: string; + /** @type {NormalizedStatic} */ simpleType: string; multiple: boolean; }; - /** - * @param {string | Static | undefined} [optionsForStatic] - * @returns {NormalizedStatic} - */ "open-target-reset": { configs: { type: string; @@ -1127,14 +1156,15 @@ declare class Server { "server-options-pfx-reset": { configs: { description: string; - /** @type {ServerConfiguration} */ multiple: boolean; + multiple: boolean; path: string; type: string; }[]; description: string; multiple: boolean; - simpleType: string; + simpleType: string /** @type {ServerOptions} */; }; + /** @type {ServerOptions} */ "server-options-request-cert": { configs: { description: string; @@ -1153,10 +1183,10 @@ declare class Server { multiple: boolean; path: string; type: string; - /** @type {ServerOptions} */ values: string[]; + values: string[]; }[]; description: string; - /** @type {Array} */ multiple: boolean; + multiple: boolean; simpleType: string; }; static: { @@ -1170,13 +1200,17 @@ declare class Server { | { type: string; multiple: boolean; + /** + * @param {string | Buffer | undefined} item + * @returns {string | Buffer | undefined} + */ description: string; negatedDescription: string; path: string; } )[]; description: string; - /** @type {ServerOptions} */ simpleType: string; + simpleType: string; multiple: boolean; }; "static-directory": { @@ -1186,7 +1220,7 @@ declare class Server { description: string; path: string; }[]; - description: string; + /** @type {any} */ description: string; simpleType: string; multiple: boolean; }; @@ -1288,12 +1322,14 @@ declare class Server { } | { description: string; - /** @type {ServerOptions & { cacert?: ServerOptions["ca"] }} */ multiple: boolean; + multiple: boolean; path: string; type: string; } )[]; + /** @type {ServerOptions & { cacert?: ServerOptions["ca"] }} */ description: string; + /** @type {ServerOptions} */ simpleType: string; multiple: boolean; }; @@ -1301,7 +1337,6 @@ declare class Server { configs: ( | { description: string; - /** @type {ServerOptions & { cacert?: ServerOptions["ca"] }} */ multiple: boolean; path: string; type: string; @@ -1311,12 +1346,12 @@ declare class Server { description: string; multiple: boolean; path: string; - /** @type {ServerOptions} */ type: string; + type: string; } )[]; description: string; simpleType: string; - /** @type {ServerOptions} */ multiple: boolean; + multiple: boolean; }; }; readonly processArguments: (