From d1d8062924b3f3368890f4a35e79c5dd0774f599 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 2 Nov 2021 00:54:44 -0700 Subject: [PATCH 1/7] feat: add `--web-socket-server-type` --- lib/Server.js | 1 + lib/options.json | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/Server.js b/lib/Server.js index 6fe00da346..4c891d1c33 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -1607,6 +1607,7 @@ class Server { }); } + // TODO: remove `--web-socket-server` in favor of `--web-socket-server-type` createWebSocketServer() { this.webSocketServer = new (this.getServerTransport())(this); this.webSocketServer.implementation.on("connection", (client, request) => { diff --git a/lib/options.json b/lib/options.json index dd6d7f5e8c..9d85746a2f 100644 --- a/lib/options.json +++ b/lib/options.json @@ -1033,9 +1033,6 @@ }, "WebSocketServerObject": { "type": "object", - "cli": { - "exclude": true - }, "properties": { "type": { "anyOf": [ @@ -1052,7 +1049,10 @@ }, "options": { "type": "object", - "additionalProperties": true + "additionalProperties": true, + "cli": { + "exclude": true + } } }, "additionalProperties": false From 1be4193e1e35293afcb35877947f4f879073367f Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 2 Nov 2021 00:58:14 -0700 Subject: [PATCH 2/7] feat: add `--web-socket-server-type` --- README.md | 1 + bin/cli-flags.js | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/README.md b/README.md index bac6ca3bc0..803883361b 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,7 @@ Options: --client-web-socket-url-password Tells clients connected to devServer to use the provided password to authenticate. --web-socket-server Allows to set web socket server and options (by default 'ws'). --no-web-socket-server Negative 'web-socket-server' option. + --web-socket-server-type Allows to set web socket server and options (by default 'ws'). --compress Enables gzip compression for everything served. --no-compress Disables gzip compression for everything served. --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. diff --git a/bin/cli-flags.js b/bin/cli-flags.js index da2c2bf227..03d9106ecc 100644 --- a/bin/cli-flags.js +++ b/bin/cli-flags.js @@ -349,6 +349,30 @@ module.exports = { simpleType: "string", multiple: false, }, + "web-socket-server-type": { + configs: [ + { + description: + "Allows to set web socket server and options (by default 'ws').", + multiple: false, + path: "webSocketServer.type", + type: "enum", + values: ["sockjs", "ws"], + }, + { + description: + "Allows to set web socket server and options (by default 'ws').", + multiple: false, + path: "webSocketServer.type", + type: "string", + }, + ], + + description: + "Allows to set web socket server and options (by default 'ws').", + simpleType: "string", + multiple: false, + }, compress: { configs: [ { From 80fdd05bff834328dff801e8e0374df33661c0e3 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 2 Nov 2021 00:59:15 -0700 Subject: [PATCH 3/7] test: update snapshots --- test/cli/__snapshots__/basic.test.js.snap.webpack4 | 1 + test/cli/__snapshots__/basic.test.js.snap.webpack5 | 1 + 2 files changed, 2 insertions(+) diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack4 b/test/cli/__snapshots__/basic.test.js.snap.webpack4 index 447853a050..f6eff79016 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack4 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack4 @@ -80,6 +80,7 @@ Options: --client-web-socket-url-password Tells clients connected to devServer to use the provided password to authenticate. --web-socket-server Allows to set web socket server and options (by default 'ws'). --no-web-socket-server Negative 'web-socket-server' option. + --web-socket-server-type Allows to set web socket server and options (by default 'ws'). --compress Enables gzip compression for everything served. --no-compress Disables gzip compression for everything served. --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. diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack5 b/test/cli/__snapshots__/basic.test.js.snap.webpack5 index db8a66fbee..d5a220c075 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack5 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack5 @@ -149,6 +149,7 @@ Options: --watch-files-reset Clear all items provided in 'watchFiles' configuration. Allows to configure list of globs/directories/files to watch for file changes. --web-socket-server Allows to set web socket server and options (by default 'ws'). --no-web-socket-server Negative 'web-socket-server' option. + --web-socket-server-type Allows to set web socket server and options (by default 'ws'). Global options: --color Enable colors on console. From 35a527f6e437ae234e9edfce66124b8374f42120 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 2 Nov 2021 01:08:55 -0700 Subject: [PATCH 4/7] test: add cases for `--web-socket-server-type` --- test/cli/webSocketServer-option.test.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/cli/webSocketServer-option.test.js b/test/cli/webSocketServer-option.test.js index 51f0f14826..2aba5b98eb 100644 --- a/test/cli/webSocketServer-option.test.js +++ b/test/cli/webSocketServer-option.test.js @@ -25,4 +25,26 @@ describe('"webSocketServer" CLI option', () => { expect(exitCode).toEqual(0); }); + + it('should work using "--web-socket-server-type ws"', async () => { + const { exitCode } = await testBin([ + "--port", + port, + "--web-socket-server-type", + "ws", + ]); + + expect(exitCode).toEqual(0); + }); + + it('should work using "--web-socket-server-type sockjs"', async () => { + const { exitCode } = await testBin([ + "--port", + port, + "--web-socket-server-type", + "sockjs", + ]); + + expect(exitCode).toEqual(0); + }); }); From 5300e335dfb5157250c90c7f505186b77a8d2248 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Thu, 4 Nov 2021 18:25:08 -0700 Subject: [PATCH 5/7] fix: update description for `--web-socket-server` option --- README.md | 2 +- bin/cli-flags.js | 6 +++--- lib/options.json | 3 ++- test/cli/__snapshots__/basic.test.js.snap.webpack4 | 2 +- test/cli/__snapshots__/basic.test.js.snap.webpack5 | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 803883361b..84a705bc03 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ Options: --client-web-socket-url-protocol Tells clients connected to devServer to use the provided protocol. --client-web-socket-url-username Tells clients connected to devServer to use the provided username to authenticate. --client-web-socket-url-password Tells clients connected to devServer to use the provided password to authenticate. - --web-socket-server Allows to set web socket server and options (by default 'ws'). + --web-socket-server Deprecated: please use '--web-socket-server-type' option. Allows to set web socket server and options (by default 'ws'). --no-web-socket-server Negative 'web-socket-server' option. --web-socket-server-type Allows to set web socket server and options (by default 'ws'). --compress Enables gzip compression for everything served. diff --git a/bin/cli-flags.js b/bin/cli-flags.js index 03d9106ecc..c1cd9a1f55 100644 --- a/bin/cli-flags.js +++ b/bin/cli-flags.js @@ -321,7 +321,7 @@ module.exports = { configs: [ { description: - "Allows to set web socket server and options (by default 'ws').", + "Deprecated: please use '--web-socket-server-type' option.", multiple: false, path: "webSocketServer", type: "enum", @@ -329,7 +329,7 @@ module.exports = { }, { description: - "Allows to set web socket server and options (by default 'ws').", + "Deprecated: please use '--web-socket-server-type' option.", multiple: false, path: "webSocketServer", type: "enum", @@ -345,7 +345,7 @@ module.exports = { ], description: - "Allows to set web socket server and options (by default 'ws').", + "Deprecated: please use '--web-socket-server-type' option. Allows to set web socket server and options (by default 'ws').", simpleType: "string", multiple: false, }, diff --git a/lib/options.json b/lib/options.json index 9d85746a2f..ca1eb85816 100644 --- a/lib/options.json +++ b/lib/options.json @@ -1026,7 +1026,8 @@ { "$ref": "#/definitions/WebSocketServerType" } - ] + ], + "description": "Deprecated: please use '--web-socket-server-type' option." }, "WebSocketServerFunction": { "instanceof": "Function" diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack4 b/test/cli/__snapshots__/basic.test.js.snap.webpack4 index f6eff79016..8fb386bb68 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack4 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack4 @@ -78,7 +78,7 @@ Options: --client-web-socket-url-protocol Tells clients connected to devServer to use the provided protocol. --client-web-socket-url-username Tells clients connected to devServer to use the provided username to authenticate. --client-web-socket-url-password Tells clients connected to devServer to use the provided password to authenticate. - --web-socket-server Allows to set web socket server and options (by default 'ws'). + --web-socket-server Deprecated: please use '--web-socket-server-type' option. Allows to set web socket server and options (by default 'ws'). --no-web-socket-server Negative 'web-socket-server' option. --web-socket-server-type Allows to set web socket server and options (by default 'ws'). --compress Enables gzip compression for everything served. diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack5 b/test/cli/__snapshots__/basic.test.js.snap.webpack5 index d5a220c075..c019ddfb20 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack5 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack5 @@ -147,7 +147,7 @@ Options: --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. --watch-files Allows to configure list of globs/directories/files to watch for file changes. --watch-files-reset Clear all items provided in 'watchFiles' configuration. Allows to configure list of globs/directories/files to watch for file changes. - --web-socket-server Allows to set web socket server and options (by default 'ws'). + --web-socket-server Deprecated: please use '--web-socket-server-type' option. Allows to set web socket server and options (by default 'ws'). --no-web-socket-server Negative 'web-socket-server' option. --web-socket-server-type Allows to set web socket server and options (by default 'ws'). From 1f838d86d6ec2fa76f75fff1e563c4d0219034fd Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Thu, 4 Nov 2021 18:31:35 -0700 Subject: [PATCH 6/7] fix: update description --- bin/cli-flags.js | 6 +++--- lib/options.json | 2 +- test/__snapshots__/validate-options.test.js.snap.webpack4 | 2 ++ test/__snapshots__/validate-options.test.js.snap.webpack5 | 2 ++ test/cli/__snapshots__/basic.test.js.snap.webpack4 | 2 +- test/cli/__snapshots__/basic.test.js.snap.webpack5 | 2 +- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/bin/cli-flags.js b/bin/cli-flags.js index c1cd9a1f55..01a5219d27 100644 --- a/bin/cli-flags.js +++ b/bin/cli-flags.js @@ -321,7 +321,7 @@ module.exports = { configs: [ { description: - "Deprecated: please use '--web-socket-server-type' option.", + "Deprecated: please use 'webSocketServer.type'/'--web-socket-server-type' option.", multiple: false, path: "webSocketServer", type: "enum", @@ -329,7 +329,7 @@ module.exports = { }, { description: - "Deprecated: please use '--web-socket-server-type' option.", + "Deprecated: please use 'webSocketServer.type'/'--web-socket-server-type' option.", multiple: false, path: "webSocketServer", type: "enum", @@ -345,7 +345,7 @@ module.exports = { ], description: - "Deprecated: please use '--web-socket-server-type' option. Allows to set web socket server and options (by default 'ws').", + "Deprecated: please use 'webSocketServer.type'/'--web-socket-server-type' option. Allows to set web socket server and options (by default 'ws').", simpleType: "string", multiple: false, }, diff --git a/lib/options.json b/lib/options.json index ca1eb85816..6ed93c9078 100644 --- a/lib/options.json +++ b/lib/options.json @@ -1027,7 +1027,7 @@ "$ref": "#/definitions/WebSocketServerType" } ], - "description": "Deprecated: please use '--web-socket-server-type' option." + "description": "Deprecated: please use 'webSocketServer.type'/'--web-socket-server-type' option." }, "WebSocketServerFunction": { "instanceof": "Function" diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack4 b/test/__snapshots__/validate-options.test.js.snap.webpack4 index 646e103f06..5650232a05 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack4 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack4 @@ -864,6 +864,7 @@ exports[`options validate should throw an error on the "webSocketServer" option Details: * options.webSocketServer should be one of these: false | \\"sockjs\\" | \\"ws\\" + -> Deprecated: please use 'webSocketServer.type'/'--web-socket-server-type' option. Details: * options.webSocketServer should be false. * options.webSocketServer should be one of these: @@ -883,6 +884,7 @@ exports[`options validate should throw an error on the "webSocketServer" option Details: * options.webSocketServer should be one of these: false | \\"sockjs\\" | \\"ws\\" + -> Deprecated: please use 'webSocketServer.type'/'--web-socket-server-type' option. Details: * options.webSocketServer should be false. * options.webSocketServer should be one of these: diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack5 b/test/__snapshots__/validate-options.test.js.snap.webpack5 index 646e103f06..5650232a05 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack5 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack5 @@ -864,6 +864,7 @@ exports[`options validate should throw an error on the "webSocketServer" option Details: * options.webSocketServer should be one of these: false | \\"sockjs\\" | \\"ws\\" + -> Deprecated: please use 'webSocketServer.type'/'--web-socket-server-type' option. Details: * options.webSocketServer should be false. * options.webSocketServer should be one of these: @@ -883,6 +884,7 @@ exports[`options validate should throw an error on the "webSocketServer" option Details: * options.webSocketServer should be one of these: false | \\"sockjs\\" | \\"ws\\" + -> Deprecated: please use 'webSocketServer.type'/'--web-socket-server-type' option. Details: * options.webSocketServer should be false. * options.webSocketServer should be one of these: diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack4 b/test/cli/__snapshots__/basic.test.js.snap.webpack4 index 8fb386bb68..89940feb4e 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack4 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack4 @@ -78,7 +78,7 @@ Options: --client-web-socket-url-protocol Tells clients connected to devServer to use the provided protocol. --client-web-socket-url-username Tells clients connected to devServer to use the provided username to authenticate. --client-web-socket-url-password Tells clients connected to devServer to use the provided password to authenticate. - --web-socket-server Deprecated: please use '--web-socket-server-type' option. Allows to set web socket server and options (by default 'ws'). + --web-socket-server Deprecated: please use 'webSocketServer.type'/'--web-socket-server-type' option. Allows to set web socket server and options (by default 'ws'). --no-web-socket-server Negative 'web-socket-server' option. --web-socket-server-type Allows to set web socket server and options (by default 'ws'). --compress Enables gzip compression for everything served. diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack5 b/test/cli/__snapshots__/basic.test.js.snap.webpack5 index c019ddfb20..9b339a91a8 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack5 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack5 @@ -147,7 +147,7 @@ Options: --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. --watch-files Allows to configure list of globs/directories/files to watch for file changes. --watch-files-reset Clear all items provided in 'watchFiles' configuration. Allows to configure list of globs/directories/files to watch for file changes. - --web-socket-server Deprecated: please use '--web-socket-server-type' option. Allows to set web socket server and options (by default 'ws'). + --web-socket-server Deprecated: please use 'webSocketServer.type'/'--web-socket-server-type' option. Allows to set web socket server and options (by default 'ws'). --no-web-socket-server Negative 'web-socket-server' option. --web-socket-server-type Allows to set web socket server and options (by default 'ws'). From 452ff49c63bed2a0919409113621b61fa8ab05ce Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Thu, 4 Nov 2021 18:32:19 -0700 Subject: [PATCH 7/7] docs: update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 84a705bc03..649010cc4d 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ Options: --client-web-socket-url-protocol Tells clients connected to devServer to use the provided protocol. --client-web-socket-url-username Tells clients connected to devServer to use the provided username to authenticate. --client-web-socket-url-password Tells clients connected to devServer to use the provided password to authenticate. - --web-socket-server Deprecated: please use '--web-socket-server-type' option. Allows to set web socket server and options (by default 'ws'). + --web-socket-server Deprecated: please use 'webSocketServer.type'/'--web-socket-server-type' option. Allows to set web socket server and options (by default 'ws'). --no-web-socket-server Negative 'web-socket-server' option. --web-socket-server-type Allows to set web socket server and options (by default 'ws'). --compress Enables gzip compression for everything served.