Skip to content

Commit 012c2d0

Browse files
committed
fix(server): revert "union sock options (#2047)"
1 parent fe80fa4 commit 012c2d0

File tree

9 files changed

+51
-76
lines changed

9 files changed

+51
-76
lines changed

lib/Server.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,10 @@ class Server {
9191
this.hot = this.options.hot || this.options.hotOnly;
9292
this.watchOptions = options.watchOptions || {};
9393

94-
if (!this.options.clientSocketOptions) {
95-
this.options.clientSocketOptions = {};
96-
}
97-
9894
// Replace leading and trailing slashes to normalize path
9995
this.sockPath = `/${
100-
this.options.clientSocketOptions.path
101-
? this.options.clientSocketOptions.path.replace(/^\/|\/$/g, '')
96+
this.options.sockPath
97+
? this.options.sockPath.replace(/^\/|\/$/g, '')
10298
: 'sockjs-node'
10399
}`;
104100

lib/options.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,6 @@
3939
"clientLogLevel": {
4040
"enum": ["info", "warn", "error", "debug", "trace", "silent"]
4141
},
42-
"clientSocketOptions": {
43-
"type": "object",
44-
"properties": {
45-
"host": {
46-
"type": "string"
47-
},
48-
"path": {
49-
"type": "string"
50-
},
51-
"port": {
52-
"anyOf": [
53-
{
54-
"type": "string"
55-
},
56-
{
57-
"type": "number"
58-
}
59-
]
60-
}
61-
}
62-
},
6342
"compress": {
6443
"type": "boolean"
6544
},
@@ -318,6 +297,25 @@
318297
"setup": {
319298
"instanceof": "Function"
320299
},
300+
"sockHost": {
301+
"type": "string"
302+
},
303+
"sockPath": {
304+
"type": "string"
305+
},
306+
"sockPort": {
307+
"anyOf": [
308+
{
309+
"type": "number"
310+
},
311+
{
312+
"type": "string"
313+
},
314+
{
315+
"type": "null"
316+
}
317+
]
318+
},
321319
"socket": {
322320
"type": "string"
323321
},
@@ -405,7 +403,6 @@
405403
"ca": "should be {String|Buffer}",
406404
"cert": "should be {String|Buffer}",
407405
"clientLogLevel": "should be {String} and equal to one of the allowed values\n\n [ 'silent', 'info', 'debug', 'trace', 'error', 'warn' ]\n\n (https://webpack.js.org/configuration/dev-server/#devserverclientloglevel)",
408-
"clientSocketOptions": "should be {Object} (https://webpack.js.org/configuration/dev-server/#devserverclientsocketoptions)",
409406
"compress": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devservercompress)",
410407
"contentBase": "should be {Number|String|Array} (https://webpack.js.org/configuration/dev-server/#devservercontentbase)",
411408
"disableHostCheck": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverdisablehostcheck)",
@@ -449,6 +446,9 @@
449446
"serveIndex": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverserveindex)",
450447
"serverSideRender": "should be {Boolean} (https://github.com/webpack/webpack-dev-middleware#serversiderender)",
451448
"setup": "should be {Function} (https://webpack.js.org/configuration/dev-server/#devserversetup)",
449+
"sockHost": "should be {String|Null} (https://webpack.js.org/configuration/dev-server/#devserversockhost)",
450+
"sockPath": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserversockpath)",
451+
"sockPort": "should be {Number|String|Null} (https://webpack.js.org/configuration/dev-server/#devserversockport)",
452452
"socket": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserversocket)",
453453
"staticOptions": "should be {Object} (https://webpack.js.org/configuration/dev-server/#devserverstaticoptions)",
454454
"stats": "should be {Object|Boolean} (https://webpack.js.org/configuration/dev-server/#devserverstats-)",

lib/utils/addEntries.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,14 @@ function addEntries(config, options, server) {
2727
},
2828
};
2929

30-
if (!options.clientSocketOptions) {
31-
options.clientSocketOptions = {};
32-
}
33-
3430
/** @type {string} */
3531
const domain = createDomain(options, app);
3632
/** @type {string} */
37-
const sockHost = options.clientSocketOptions.host ? `&sockHost=${options.clientSocketOptions.host}` : '';
33+
const sockHost = options.sockHost ? `&sockHost=${options.sockHost}` : '';
3834
/** @type {string} */
39-
const sockPath = options.clientSocketOptions.path ? `&sockPath=${options.clientSocketOptions.path}` : '';
35+
const sockPath = options.sockPath ? `&sockPath=${options.sockPath}` : '';
4036
/** @type {string} */
41-
const sockPort = options.clientSocketOptions.port ? `&sockPort=${options.clientSocketOptions.port}` : '';
37+
const sockPort = options.sockPort ? `&sockPort=${options.sockPort}` : '';
4238
/** @type {string} */
4339
const clientEntry = `${require.resolve(
4440
'../../client/'

lib/utils/createConfig.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,16 @@ function createConfig(config, argv, { port }) {
3131
options.socket = argv.socket;
3232
}
3333

34-
if (
35-
(argv.sockHost || argv.sockPath || argv.sockPort) &&
36-
!options.clientSocketOptions
37-
) {
38-
options.clientSocketOptions = {};
39-
}
40-
4134
if (argv.sockHost) {
42-
options.clientSocketOptions.host = argv.sockHost;
35+
options.sockHost = argv.sockHost;
4336
}
4437

4538
if (argv.sockPath) {
46-
options.clientSocketOptions.path = argv.sockPath;
39+
options.sockPath = argv.sockPath;
4740
}
4841

4942
if (argv.sockPort) {
50-
options.clientSocketOptions.port = argv.sockPort;
43+
options.sockPort = argv.sockPort;
5144
}
5245

5346
if (argv.liveReload === false) {

test/e2e/ClientOptions.test.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ describe('Client complex inline script path', () => {
9696
poll: true,
9797
},
9898
public: 'myhost.test',
99-
clientSocketOptions: {
100-
path: '/foo/test/bar/',
101-
},
99+
sockPath: '/foo/test/bar/',
102100
quiet: true,
103101
};
104102
testServer.startAwaitingCompilation(config, options, done);
@@ -140,10 +138,8 @@ describe('Client complex inline script path with sockPort', () => {
140138
watchOptions: {
141139
poll: true,
142140
},
143-
clientSocketOptions: {
144-
path: '/foo/test/bar/',
145-
port: port3,
146-
},
141+
sockPath: '/foo/test/bar/',
142+
sockPort: port3,
147143
quiet: true,
148144
};
149145
testServer.startAwaitingCompilation(config, options, done);
@@ -189,9 +185,7 @@ describe('Client complex inline script path with sockPort, no sockPath', () => {
189185
watchOptions: {
190186
poll: true,
191187
},
192-
clientSocketOptions: {
193-
port: port3,
194-
},
188+
sockPort: port3,
195189
quiet: true,
196190
};
197191
testServer.startAwaitingCompilation(config, options, done);
@@ -231,9 +225,7 @@ describe('Client complex inline script path with sockHost', () => {
231225
watchOptions: {
232226
poll: true,
233227
},
234-
clientSocketOptions: {
235-
host: 'myhost.test',
236-
},
228+
sockHost: 'myhost.test',
237229
quiet: true,
238230
};
239231
testServer.startAwaitingCompilation(config, options, done);

test/options.test.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,16 @@ describe('options', () => {
290290
success: [''],
291291
failure: [false],
292292
},
293-
clientSocketOptions: {
294-
success: [{}],
293+
sockHost: {
294+
success: [''],
295+
failure: [false],
296+
},
297+
sockPath: {
298+
success: [''],
299+
failure: [false],
300+
},
301+
sockPort: {
302+
success: ['', 0, null],
295303
failure: [false],
296304
},
297305
staticOptions: {

test/server/sockPath-option.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ describe('sockPath options', () => {
3737
server = testServer.start(
3838
config,
3939
{
40-
clientSocketOptions: {
41-
path: '/foo/test/bar/',
42-
},
40+
sockPath: '/foo/test/bar/',
4341
port,
4442
},
4543
done

test/server/transportMode-option.test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,7 @@ describe('transportMode', () => {
195195
config,
196196
{
197197
port,
198-
clientSocketOptions: {
199-
path: '/foo/test/bar/',
200-
},
198+
sockPath: '/foo/test/bar/',
201199
transportMode: {
202200
server: class MySockJSServer extends BaseServer {
203201
constructor(serv) {
@@ -219,7 +217,7 @@ describe('transportMode', () => {
219217
prefix: this.server.sockPath,
220218
});
221219

222-
sockPath = server.options.clientSocketOptions.path;
220+
sockPath = server.options.sockPath;
223221
}
224222

225223
send(connection, message) {

test/server/utils/__snapshots__/createConfig.test.js.snap

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,14 +1202,12 @@ Object {
12021202

12031203
exports[`createConfig sockHost option 1`] = `
12041204
Object {
1205-
"clientSocketOptions": Object {
1206-
"host": true,
1207-
},
12081205
"hot": true,
12091206
"hotOnly": false,
12101207
"noInfo": true,
12111208
"port": 8080,
12121209
"publicPath": "/",
1210+
"sockHost": true,
12131211
"stats": Object {
12141212
"cached": false,
12151213
"cachedAssets": false,
@@ -1219,14 +1217,12 @@ Object {
12191217

12201218
exports[`createConfig sockPath option 1`] = `
12211219
Object {
1222-
"clientSocketOptions": Object {
1223-
"path": "path",
1224-
},
12251220
"hot": true,
12261221
"hotOnly": false,
12271222
"noInfo": true,
12281223
"port": 8080,
12291224
"publicPath": "/",
1225+
"sockPath": "path",
12301226
"stats": Object {
12311227
"cached": false,
12321228
"cachedAssets": false,
@@ -1236,14 +1232,12 @@ Object {
12361232

12371233
exports[`createConfig sockPort option 1`] = `
12381234
Object {
1239-
"clientSocketOptions": Object {
1240-
"port": "port",
1241-
},
12421235
"hot": true,
12431236
"hotOnly": false,
12441237
"noInfo": true,
12451238
"port": 8080,
12461239
"publicPath": "/",
1240+
"sockPort": "port",
12471241
"stats": Object {
12481242
"cached": false,
12491243
"cachedAssets": false,

0 commit comments

Comments
 (0)