Skip to content

Commit eb9c58d

Browse files
authored
chore(client): rename clientOptions to client (#2655)
1 parent e4761bf commit eb9c58d

20 files changed

+89
-103
lines changed

lib/Server.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -634,12 +634,8 @@ class Server {
634634
}
635635
});
636636

637-
if (this.options.clientOptions.logging) {
638-
this.sockWrite(
639-
[connection],
640-
'logging',
641-
this.options.clientOptions.logging
642-
);
637+
if (this.options.client.logging) {
638+
this.sockWrite([connection], 'logging', this.options.client.logging);
643639
}
644640

645641
if (this.options.hot === true || this.options.hot === 'only') {

lib/options.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"bonjour": {
1111
"type": "boolean"
1212
},
13-
"clientOptions": {
13+
"client": {
1414
"type": "object",
1515
"properties": {
1616
"host": {
@@ -390,7 +390,7 @@
390390
"properties": {
391391
"allowedHosts": "should be {Array} (https://webpack.js.org/configuration/dev-server/#devserverallowedhosts)",
392392
"bonjour": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverbonjour)",
393-
"clientOptions": "should be {Object} (https://webpack.js.org/configuration/dev-server/#devserverclientoptions)",
393+
"client": "should be {Object} (https://webpack.js.org/configuration/dev-server/#devserverclient)",
394394
"compress": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devservercompress)",
395395
"contentBase": "should be {Number|String|Array} (https://webpack.js.org/configuration/dev-server/#devservercontentbase)",
396396
"disableHostCheck": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverdisablehostcheck)",

lib/servers/SockJSServer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module.exports = class SockJSServer extends BaseServer {
4747
});
4848

4949
this.socket.installHandlers(this.server.listeningApp, {
50-
prefix: this.server.options.clientOptions.path,
50+
prefix: this.server.options.client.path,
5151
});
5252
}
5353

lib/servers/WebsocketServer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = class WebsocketServer extends BaseServer {
1212

1313
this.wsServer = new ws.Server({
1414
noServer: true,
15-
path: this.server.options.clientOptions.path,
15+
path: this.server.options.client.path,
1616
});
1717

1818
this.server.listeningApp.on('upgrade', (req, sock, head) => {

lib/utils/addEntries.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,16 @@ function addEntries(config, options, server) {
3030
const domain = createDomain(options, app);
3131
/** @type {string} */
3232
const host =
33-
options.clientOptions && options.clientOptions.host
34-
? `&host=${options.clientOptions.host}`
35-
: '';
33+
options.client && options.client.host ? `&host=${options.client.host}` : '';
3634
/** @type {string} */
3735
let path = '';
3836
// only add the path if it is not default
39-
if (
40-
options.clientOptions &&
41-
options.clientOptions.path &&
42-
options.clientOptions.path !== '/ws'
43-
) {
44-
path = `&path=${options.clientOptions.path}`;
37+
if (options.client && options.client.path && options.client.path !== '/ws') {
38+
path = `&path=${options.client.path}`;
4539
}
4640
/** @type {string} */
4741
const port =
48-
options.clientOptions && options.clientOptions.port
49-
? `&port=${options.clientOptions.port}`
50-
: '';
42+
options.client && options.client.port ? `&port=${options.client.port}` : '';
5143
/** @type {string} */
5244
const clientEntry = `${require.resolve(
5345
'../../client/default/'

lib/utils/createConfig.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ function createConfig(config, argv, { port }) {
8181
}
8282

8383
if (argv.clientLogging) {
84-
if (options.clientOptions) {
85-
options.clientOptions.logging = argv.clientLogging;
84+
if (options.client) {
85+
options.client.logging = argv.clientLogging;
8686
} else {
87-
options.clientOptions = {
87+
options.client = {
8888
logging: argv.clientLogging,
8989
};
9090
}

lib/utils/normalizeOptions.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,12 @@ function normalizeOptions(compiler, options) {
4242
}
4343
}
4444

45-
if (!options.clientOptions) {
46-
options.clientOptions = {};
45+
if (!options.client) {
46+
options.client = {};
4747
}
4848

49-
options.clientOptions.path = `/${
50-
options.clientOptions.path
51-
? options.clientOptions.path.replace(/^\/|\/$/g, '')
52-
: 'ws'
49+
options.client.path = `/${
50+
options.client.path ? options.client.path.replace(/^\/|\/$/g, '') : 'ws'
5351
}`;
5452
}
5553

test/__snapshots__/Validation.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ exports[`Validation validation should fail validation for invalid \`writeToDisk\
3131
exports[`Validation validation should fail validation for no additional properties 1`] = `
3232
"Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
3333
- configuration has an unknown property 'additional'. These properties are valid:
34-
object { allowedHosts?, bonjour?, clientOptions?, compress?, contentBasePublicPath?, contentBase?, disableHostCheck?, fs?, headers?, historyApiFallback?, host?, hot?, http2?, https?, index?, injectClient?, injectHot?, liveReload?, mimeTypes?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, openPage?, overlay?, port?, profile?, progress?, proxy?, public?, publicPath?, requestCert?, serveIndex?, serverSideRender?, socket?, staticOptions?, stats?, transportMode?, useLocalIp?, watchContentBase?, watchOptions?, writeToDisk? }"
34+
object { allowedHosts?, bonjour?, client?, compress?, contentBasePublicPath?, contentBase?, disableHostCheck?, fs?, headers?, historyApiFallback?, host?, hot?, http2?, https?, index?, injectClient?, injectHot?, liveReload?, mimeTypes?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, openPage?, overlay?, port?, profile?, progress?, proxy?, public?, publicPath?, requestCert?, serveIndex?, serverSideRender?, socket?, staticOptions?, stats?, transportMode?, useLocalIp?, watchContentBase?, watchOptions?, writeToDisk? }"
3535
`;

test/e2e/ClientOptions.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ describe('sockjs public and client path', () => {
162162
poll: true,
163163
},
164164
public: 'myhost.test',
165-
clientOptions: {
165+
client: {
166166
path: '/foo/test/bar/',
167167
},
168168
};
@@ -203,7 +203,7 @@ describe('sockjs client path and port', () => {
203203
watchOptions: {
204204
poll: true,
205205
},
206-
clientOptions: {
206+
client: {
207207
path: '/foo/test/bar/',
208208
port: port3,
209209
},
@@ -249,7 +249,7 @@ describe('sockjs client port, no path', () => {
249249
watchOptions: {
250250
poll: true,
251251
},
252-
clientOptions: {
252+
client: {
253253
port: port3,
254254
},
255255
};
@@ -288,7 +288,7 @@ describe('sockjs client host', () => {
288288
watchOptions: {
289289
poll: true,
290290
},
291-
clientOptions: {
291+
client: {
292292
host: 'myhost.test',
293293
},
294294
};
@@ -327,7 +327,7 @@ describe('ws client host, port, and path', () => {
327327
watchOptions: {
328328
poll: true,
329329
},
330-
clientOptions: {
330+
client: {
331331
host: 'myhost',
332332
port: port3,
333333
path: '/foo/test/bar/',
@@ -407,7 +407,7 @@ describe('Client console.log', () => {
407407
{
408408
title: 'client logging is none',
409409
options: {
410-
clientOptions: {
410+
client: {
411411
logging: 'none',
412412
},
413413
},

test/options.test.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -130,73 +130,73 @@ describe('options', () => {
130130
success: [false],
131131
failure: [''],
132132
},
133-
clientOptions: {
133+
client: {
134134
success: [
135135
{
136-
clientOptions: {},
136+
client: {},
137137
},
138138
{
139-
clientOptions: {
139+
client: {
140140
host: '',
141141
},
142142
},
143143
{
144-
clientOptions: {
144+
client: {
145145
path: '',
146146
},
147147
},
148148
{
149-
clientOptions: {
149+
client: {
150150
port: '',
151151
},
152152
},
153153
{
154-
clientOptions: {
154+
client: {
155155
logging: 'none',
156156
},
157157
},
158158
{
159-
clientOptions: {
159+
client: {
160160
logging: 'error',
161161
},
162162
},
163163
{
164-
clientOptions: {
164+
client: {
165165
logging: 'warn',
166166
},
167167
},
168168
{
169-
clientOptions: {
169+
client: {
170170
logging: 'info',
171171
},
172172
},
173173
{
174-
clientOptions: {
174+
client: {
175175
logging: 'log',
176176
},
177177
},
178178
{
179-
clientOptions: {
179+
client: {
180180
logging: 'verbose',
181181
},
182182
},
183183
{
184-
clientOptions: {
184+
client: {
185185
host: '',
186186
path: '',
187187
port: 8080,
188188
logging: 'none',
189189
},
190190
},
191191
{
192-
clientOptions: {
192+
client: {
193193
host: '',
194194
path: '',
195195
port: '',
196196
},
197197
},
198198
{
199-
clientOptions: {
199+
client: {
200200
host: '',
201201
path: '',
202202
port: null,
@@ -206,24 +206,24 @@ describe('options', () => {
206206
failure: [
207207
'whoops!',
208208
{
209-
clientOptions: {
209+
client: {
210210
unknownOption: true,
211211
},
212212
},
213213
{
214-
clientOptions: {
214+
client: {
215215
host: true,
216216
path: '',
217217
port: 8080,
218218
},
219219
},
220220
{
221-
clientOptions: {
221+
client: {
222222
logging: 'whoops!',
223223
},
224224
},
225225
{
226-
clientOptions: {
226+
client: {
227227
logging: 'silent',
228228
},
229229
},

0 commit comments

Comments
 (0)