Skip to content

Commit 39a07e4

Browse files
authored
refactor!: rename client.transport to client.webSocketTransport (#3525)
1 parent 9a1edc1 commit 39a07e4

19 files changed

+139
-136
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Options:
9999
--no-client-overlay-warnings Negative 'client-overlay-warnings' option.
100100
--client-progress Prints compilation progress in percentage in the browser.
101101
--no-client-progress Negative 'client-progress' option.
102-
--client-transport <value> Allows to set custom transport to communicate with dev server.
102+
--client-web-socket-transport <value> Allows to set custom web socket transport to communicate with dev server.
103103
--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).
104104
--client-web-socket-url-hostname <value> Tells clients connected to devServer to use the provided hostname.
105105
--client-web-socket-url-pathname <value> Tells clients connected to devServer to use the provided path to connect.

bin/cli-flags.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,26 @@ module.exports = {
5656
simpleType: 'boolean',
5757
multiple: false,
5858
},
59-
'client-transport': {
59+
'client-web-socket-transport': {
6060
configs: [
6161
{
6262
type: 'enum',
6363
values: ['sockjs', 'ws'],
6464
multiple: false,
6565
description:
66-
'Allows to set custom transport to communicate with dev server.',
67-
path: 'client.transport',
66+
'Allows to set custom web socket transport to communicate with dev server.',
67+
path: 'client.webSocketTransport',
6868
},
6969
{
7070
type: 'string',
7171
multiple: false,
7272
description:
73-
'Allows to set custom transport to communicate with dev server.',
74-
path: 'client.transport',
73+
'Allows to set custom web socket transport to communicate with dev server.',
74+
path: 'client.webSocketTransport',
7575
},
7676
],
7777
description:
78-
'Allows to set custom transport to communicate with dev server.',
78+
'Allows to set custom web socket transport to communicate with dev server.',
7979
simpleType: 'string',
8080
multiple: false,
8181
},

lib/options.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
"progress": {
5656
"$ref": "#/definitions/ClientProgress"
5757
},
58-
"transport": {
59-
"$ref": "#/definitions/ClientTransport"
58+
"webSocketTransport": {
59+
"$ref": "#/definitions/ClientWebSocketTransport"
6060
},
6161
"webSocketURL": {
6262
"$ref": "#/definitions/ClientWebSocketURL"
@@ -95,21 +95,21 @@
9595
"description": "Prints compilation progress in percentage in the browser.",
9696
"type": "boolean"
9797
},
98-
"ClientTransport": {
98+
"ClientWebSocketTransport": {
9999
"anyOf": [
100100
{
101-
"$ref": "#/definitions/ClientTransportEnum"
101+
"$ref": "#/definitions/ClientWebSocketTransportEnum"
102102
},
103103
{
104-
"$ref": "#/definitions/ClientTransportString"
104+
"$ref": "#/definitions/ClientWebSocketTransportString"
105105
}
106106
],
107-
"description": "Allows to set custom transport to communicate with dev server."
107+
"description": "Allows to set custom web socket transport to communicate with dev server."
108108
},
109-
"ClientTransportEnum": {
109+
"ClientWebSocketTransportEnum": {
110110
"enum": ["sockjs", "ws"]
111111
},
112-
"ClientTransportString": {
112+
"ClientWebSocketTransportString": {
113113
"type": "string",
114114
"minLength": 1
115115
},

lib/utils/DevServerPlugin.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class DevServerPlugin {
2525
let clientTransport;
2626

2727
if (this.options.client) {
28-
if (typeof this.options.client.transport !== 'undefined') {
29-
clientTransport = this.options.client.transport;
28+
if (typeof this.options.client.webSocketTransport !== 'undefined') {
29+
clientTransport = this.options.client.webSocketTransport;
3030
} else if (isKnownWebSocketServerImplementation) {
3131
clientTransport = this.options.webSocketServer.type;
3232
}
@@ -62,9 +62,9 @@ class DevServerPlugin {
6262
throw new Error(
6363
`${
6464
!isKnownWebSocketServerImplementation
65-
? 'When you use custom web socket implementation you must explicitly specify client.transport. '
65+
? 'When you use custom web socket implementation you must explicitly specify client.webSocketTransport. '
6666
: ''
67-
}client.transport must be a string denoting a default implementation (e.g. 'sockjs', 'ws') or a full path to a JS file via require.resolve(...) which exports a class `
67+
}client.webSocketTransport must be a string denoting a default implementation (e.g. 'sockjs', 'ws') or a full path to a JS file via require.resolve(...) which exports a class `
6868
);
6969
}
7070

test/__snapshots__/validate-options.test.js.snap.webpack4

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ exports[`options validate should throw an error on the "client" option with '{"l
7676
exports[`options validate should throw an error on the "client" option with '{"overlay":""}' value 1`] = `
7777
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
7878
- options.client should be one of these:
79-
false | object { logging?, overlay?, progress?, transport?, webSocketURL? }
79+
false | object { logging?, overlay?, progress?, webSocketTransport?, webSocketURL? }
8080
-> Allows to specify options for client script in the browser or disable client script. https://webpack.js.org/configuration/dev-server/#devserverclient
8181
Details:
8282
* options.client.overlay should be one of these:
@@ -112,25 +112,25 @@ exports[`options validate should throw an error on the "client" option with '{"p
112112
-> Prints compilation progress in percentage in the browser."
113113
`;
114114

115-
exports[`options validate should throw an error on the "client" option with '{"transport":true}' value 1`] = `
115+
exports[`options validate should throw an error on the "client" option with '{"unknownOption":true}' value 1`] = `
116+
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
117+
- options.client has an unknown property 'unknownOption'. These properties are valid:
118+
object { logging?, overlay?, progress?, webSocketTransport?, webSocketURL? }"
119+
`;
120+
121+
exports[`options validate should throw an error on the "client" option with '{"webSocketTransport":true}' value 1`] = `
116122
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
117123
- options.client should be one of these:
118-
false | object { logging?, overlay?, progress?, transport?, webSocketURL? }
124+
false | object { logging?, overlay?, progress?, webSocketTransport?, webSocketURL? }
119125
-> Allows to specify options for client script in the browser or disable client script. https://webpack.js.org/configuration/dev-server/#devserverclient
120126
Details:
121-
* options.client.transport should be one of these:
127+
* options.client.webSocketTransport should be one of these:
122128
\\"sockjs\\" | \\"ws\\" | non-empty string
123-
-> Allows to set custom transport to communicate with dev server.
129+
-> Allows to set custom web socket transport to communicate with dev server.
124130
Details:
125-
* options.client.transport should be one of these:
131+
* options.client.webSocketTransport should be one of these:
126132
\\"sockjs\\" | \\"ws\\"
127-
* options.client.transport should be a non-empty string."
128-
`;
129-
130-
exports[`options validate should throw an error on the "client" option with '{"unknownOption":true}' value 1`] = `
131-
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
132-
- options.client has an unknown property 'unknownOption'. These properties are valid:
133-
object { logging?, overlay?, progress?, transport?, webSocketURL? }"
133+
* options.client.webSocketTransport should be a non-empty string."
134134
`;
135135

136136
exports[`options validate should throw an error on the "client" option with '{"webSocketURL":{"hostname":""}}' value 1`] = `
@@ -159,7 +159,7 @@ exports[`options validate should throw an error on the "client" option with '{"w
159159
exports[`options validate should throw an error on the "client" option with '{"webSocketURL":{"port":true}}' value 1`] = `
160160
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
161161
- options.client should be one of these:
162-
false | object { logging?, overlay?, progress?, transport?, webSocketURL? }
162+
false | object { logging?, overlay?, progress?, webSocketTransport?, webSocketURL? }
163163
-> Allows to specify options for client script in the browser or disable client script. https://webpack.js.org/configuration/dev-server/#devserverclient
164164
Details:
165165
* options.client.webSocketURL.port should be one of these:
@@ -173,7 +173,7 @@ exports[`options validate should throw an error on the "client" option with '{"w
173173
exports[`options validate should throw an error on the "client" option with '{"webSocketURL":{"username":123,"password":976}}' value 1`] = `
174174
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
175175
- options.client should be one of these:
176-
false | object { logging?, overlay?, progress?, transport?, webSocketURL? }
176+
false | object { logging?, overlay?, progress?, webSocketTransport?, webSocketURL? }
177177
-> Allows to specify options for client script in the browser or disable client script. https://webpack.js.org/configuration/dev-server/#devserverclient
178178
Details:
179179
* options.client.webSocketURL.password should be a string.
@@ -185,12 +185,12 @@ exports[`options validate should throw an error on the "client" option with '{"w
185185
exports[`options validate should throw an error on the "client" option with 'whoops!' value 1`] = `
186186
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
187187
- options.client should be one of these:
188-
false | object { logging?, overlay?, progress?, transport?, webSocketURL? }
188+
false | object { logging?, overlay?, progress?, webSocketTransport?, webSocketURL? }
189189
-> Allows to specify options for client script in the browser or disable client script. https://webpack.js.org/configuration/dev-server/#devserverclient
190190
Details:
191191
* options.client should be false.
192192
* options.client should be an object:
193-
object { logging?, overlay?, progress?, transport?, webSocketURL? }"
193+
object { logging?, overlay?, progress?, webSocketTransport?, webSocketURL? }"
194194
`;
195195

196196
exports[`options validate should throw an error on the "compress" option with '' value 1`] = `

test/__snapshots__/validate-options.test.js.snap.webpack5

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ exports[`options validate should throw an error on the "client" option with '{"l
7676
exports[`options validate should throw an error on the "client" option with '{"overlay":""}' value 1`] = `
7777
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
7878
- options.client should be one of these:
79-
false | object { logging?, overlay?, progress?, transport?, webSocketURL? }
79+
false | object { logging?, overlay?, progress?, webSocketTransport?, webSocketURL? }
8080
-> Allows to specify options for client script in the browser or disable client script. https://webpack.js.org/configuration/dev-server/#devserverclient
8181
Details:
8282
* options.client.overlay should be one of these:
@@ -112,25 +112,25 @@ exports[`options validate should throw an error on the "client" option with '{"p
112112
-> Prints compilation progress in percentage in the browser."
113113
`;
114114

115-
exports[`options validate should throw an error on the "client" option with '{"transport":true}' value 1`] = `
115+
exports[`options validate should throw an error on the "client" option with '{"unknownOption":true}' value 1`] = `
116+
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
117+
- options.client has an unknown property 'unknownOption'. These properties are valid:
118+
object { logging?, overlay?, progress?, webSocketTransport?, webSocketURL? }"
119+
`;
120+
121+
exports[`options validate should throw an error on the "client" option with '{"webSocketTransport":true}' value 1`] = `
116122
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
117123
- options.client should be one of these:
118-
false | object { logging?, overlay?, progress?, transport?, webSocketURL? }
124+
false | object { logging?, overlay?, progress?, webSocketTransport?, webSocketURL? }
119125
-> Allows to specify options for client script in the browser or disable client script. https://webpack.js.org/configuration/dev-server/#devserverclient
120126
Details:
121-
* options.client.transport should be one of these:
127+
* options.client.webSocketTransport should be one of these:
122128
\\"sockjs\\" | \\"ws\\" | non-empty string
123-
-> Allows to set custom transport to communicate with dev server.
129+
-> Allows to set custom web socket transport to communicate with dev server.
124130
Details:
125-
* options.client.transport should be one of these:
131+
* options.client.webSocketTransport should be one of these:
126132
\\"sockjs\\" | \\"ws\\"
127-
* options.client.transport should be a non-empty string."
128-
`;
129-
130-
exports[`options validate should throw an error on the "client" option with '{"unknownOption":true}' value 1`] = `
131-
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
132-
- options.client has an unknown property 'unknownOption'. These properties are valid:
133-
object { logging?, overlay?, progress?, transport?, webSocketURL? }"
133+
* options.client.webSocketTransport should be a non-empty string."
134134
`;
135135

136136
exports[`options validate should throw an error on the "client" option with '{"webSocketURL":{"hostname":""}}' value 1`] = `
@@ -159,7 +159,7 @@ exports[`options validate should throw an error on the "client" option with '{"w
159159
exports[`options validate should throw an error on the "client" option with '{"webSocketURL":{"port":true}}' value 1`] = `
160160
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
161161
- options.client should be one of these:
162-
false | object { logging?, overlay?, progress?, transport?, webSocketURL? }
162+
false | object { logging?, overlay?, progress?, webSocketTransport?, webSocketURL? }
163163
-> Allows to specify options for client script in the browser or disable client script. https://webpack.js.org/configuration/dev-server/#devserverclient
164164
Details:
165165
* options.client.webSocketURL.port should be one of these:
@@ -173,7 +173,7 @@ exports[`options validate should throw an error on the "client" option with '{"w
173173
exports[`options validate should throw an error on the "client" option with '{"webSocketURL":{"username":123,"password":976}}' value 1`] = `
174174
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
175175
- options.client should be one of these:
176-
false | object { logging?, overlay?, progress?, transport?, webSocketURL? }
176+
false | object { logging?, overlay?, progress?, webSocketTransport?, webSocketURL? }
177177
-> Allows to specify options for client script in the browser or disable client script. https://webpack.js.org/configuration/dev-server/#devserverclient
178178
Details:
179179
* options.client.webSocketURL.password should be a string.
@@ -185,12 +185,12 @@ exports[`options validate should throw an error on the "client" option with '{"w
185185
exports[`options validate should throw an error on the "client" option with 'whoops!' value 1`] = `
186186
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
187187
- options.client should be one of these:
188-
false | object { logging?, overlay?, progress?, transport?, webSocketURL? }
188+
false | object { logging?, overlay?, progress?, webSocketTransport?, webSocketURL? }
189189
-> Allows to specify options for client script in the browser or disable client script. https://webpack.js.org/configuration/dev-server/#devserverclient
190190
Details:
191191
* options.client should be false.
192192
* options.client should be an object:
193-
object { logging?, overlay?, progress?, transport?, webSocketURL? }"
193+
object { logging?, overlay?, progress?, webSocketTransport?, webSocketURL? }"
194194
`;
195195

196196
exports[`options validate should throw an error on the "compress" option with '' value 1`] = `

test/cli/__snapshots__/basic.test.js.snap.webpack4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Options:
4242
--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'). https://webpack.js.org/configuration/dev-server/#devserverallowedhosts
4343
--bonjour Allows to broadcasts dev server via ZeroConf networking on start. https://webpack.js.org/configuration/dev-server/#devserverbonjour
4444
--no-bonjour Disallows to broadcasts dev server via ZeroConf networking on start. https://webpack.js.org/configuration/dev-server/#devserverbonjour
45-
--client-transport <value> Allows to set custom transport to communicate with dev server.
45+
--client-web-socket-transport <value> Allows to set custom web socket transport to communicate with dev server.
4646
--no-client Negative 'client' option.
4747
--client-logging <value> Allows to specify options for client script in the browser or disable client script. https://webpack.js.org/configuration/dev-server/#devserverclient
4848
--client-progress Prints compilation progress in percentage in the browser.

test/cli/__snapshots__/basic.test.js.snap.webpack5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Options:
5353
--no-client-overlay-warnings Negative 'client-overlay-warnings' option.
5454
--client-progress Prints compilation progress in percentage in the browser.
5555
--no-client-progress Negative 'client-progress' option.
56-
--client-transport <value> Allows to set custom transport to communicate with dev server.
56+
--client-web-socket-transport <value> Allows to set custom web socket transport to communicate with dev server.
5757
--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).
5858
--client-web-socket-url-hostname <value> Tells clients connected to devServer to use the provided hostname.
5959
--client-web-socket-url-pathname <value> Tells clients connected to devServer to use the provided path to connect.

test/cli/client-option.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ const { testBin } = require('../helpers/test-bin');
44
const port = require('../ports-map')['cli-client'];
55

66
describe('"client" CLI option', () => {
7-
it('should work using "--client-transport sockjs"', async () => {
7+
it('should work using "--client-web-socket-transport sockjs"', async () => {
88
const { exitCode } = await testBin([
99
'--port',
1010
port,
11-
'--client-transport',
11+
'--client-web-socket-transport',
1212
'sockjs',
1313
]);
1414

1515
expect(exitCode).toEqual(0);
1616
});
1717

18-
it('should work using "--client-transport ws"', async () => {
18+
it('should work using "--client-web-socket-transport ws"', async () => {
1919
const { exitCode } = await testBin([
2020
'--port',
2121
port,
22-
'--client-transport',
22+
'--client-web-socket-transport',
2323
'ws',
2424
]);
2525

0 commit comments

Comments
 (0)