Skip to content

Commit 5e05e48

Browse files
feat: enable overlay by default (#3108)
Co-authored-by: Rishabh Chawla <[email protected]>
1 parent 45b698d commit 5e05e48

File tree

5 files changed

+51
-4
lines changed

5 files changed

+51
-4
lines changed

lib/utils/normalizeOptions.js

+5
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ function normalizeOptions(compiler, options) {
9898
options.client = {};
9999
}
100100

101+
// Enable client overlay by default
102+
if (typeof options.client.overlay === 'undefined') {
103+
options.client.overlay = true;
104+
}
105+
101106
options.client.path = `/${
102107
options.client.path ? options.client.path.replace(/^\/|\/$/g, '') : 'ws'
103108
}`;

test/e2e/__snapshots__/TransportMode.test.js.snap

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Array [
66
"open",
77
"liveReload",
88
"[webpack-dev-server] Live Reloading enabled.",
9+
"overlay",
910
"hash",
1011
"ok",
1112
"close",

test/server/clientOptions-option.test.js

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ describe('client option', () => {
3434
).toBeTruthy();
3535
});
3636

37+
it('overlay true by default', () => {
38+
expect(server.options.client.overlay).toBe(true);
39+
});
40+
3741
it('responds with a 200', (done) => {
3842
req.get('/ws').expect(200, done);
3943
});

test/server/transportMode-option.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -482,14 +482,14 @@ describe('transportMode', () => {
482482
expect(MockWebsocketServer.mock.calls[0][0].options.port).toEqual(port);
483483

484484
expect(mockServerInstance.onConnection.mock.calls).toMatchSnapshot();
485-
expect(mockServerInstance.send.mock.calls.length).toEqual(4);
485+
expect(mockServerInstance.send.mock.calls.length).toEqual(5);
486486
// call 0 to the send() method is hot
487487
expect(mockServerInstance.send.mock.calls[0]).toMatchSnapshot();
488488
// call 1 to the send() method is liveReload
489489
expect(mockServerInstance.send.mock.calls[1]).toMatchSnapshot();
490-
// call 2 to the send() method is hash data, so we skip it
491-
// call 3 to the send() method is the "ok" message
492-
expect(mockServerInstance.send.mock.calls[3]).toMatchSnapshot();
490+
// call 3 to the send() method is hash data, so we skip it
491+
// call 4 to the send() method is the "ok" message
492+
expect(mockServerInstance.send.mock.calls[4]).toMatchSnapshot();
493493
// close should not be called because the server never forcefully closes
494494
// a successful client connection
495495
expect(mockServerInstance.close.mock.calls.length).toEqual(0);

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

+37
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ exports[`normalizeOptions client host and port should set correct options 1`] =
44
Object {
55
"client": Object {
66
"host": "my.host",
7+
"overlay": true,
78
"path": "/ws",
89
"port": 9000,
910
},
@@ -35,6 +36,7 @@ Object {
3536
exports[`normalizeOptions client path should set correct options 1`] = `
3637
Object {
3738
"client": Object {
39+
"overlay": true,
3840
"path": "/custom/path",
3941
},
4042
"dev": Object {},
@@ -65,6 +67,7 @@ Object {
6567
exports[`normalizeOptions client path without leading/ending slashes should set correct options 1`] = `
6668
Object {
6769
"client": Object {
70+
"overlay": true,
6871
"path": "/custom/path",
6972
},
7073
"dev": Object {},
@@ -95,6 +98,7 @@ Object {
9598
exports[`normalizeOptions dev is set should set correct options 1`] = `
9699
Object {
97100
"client": Object {
101+
"overlay": true,
98102
"path": "/ws",
99103
},
100104
"dev": Object {
@@ -127,6 +131,7 @@ Object {
127131
exports[`normalizeOptions firewall is set should set correct options 1`] = `
128132
Object {
129133
"client": Object {
134+
"overlay": true,
130135
"path": "/ws",
131136
},
132137
"dev": Object {},
@@ -157,6 +162,7 @@ Object {
157162
exports[`normalizeOptions hot is false should set correct options 1`] = `
158163
Object {
159164
"client": Object {
165+
"overlay": true,
160166
"path": "/ws",
161167
},
162168
"dev": Object {},
@@ -187,6 +193,7 @@ Object {
187193
exports[`normalizeOptions hot is only should set correct options 1`] = `
188194
Object {
189195
"client": Object {
196+
"overlay": true,
190197
"path": "/ws",
191198
},
192199
"dev": Object {},
@@ -217,6 +224,7 @@ Object {
217224
exports[`normalizeOptions hot is true should set correct options 1`] = `
218225
Object {
219226
"client": Object {
227+
"overlay": true,
220228
"path": "/ws",
221229
},
222230
"dev": Object {},
@@ -247,6 +255,7 @@ Object {
247255
exports[`normalizeOptions liveReload is false should set correct options 1`] = `
248256
Object {
249257
"client": Object {
258+
"overlay": true,
250259
"path": "/ws",
251260
},
252261
"dev": Object {},
@@ -277,6 +286,7 @@ Object {
277286
exports[`normalizeOptions liveReload is true should set correct options 1`] = `
278287
Object {
279288
"client": Object {
289+
"overlay": true,
280290
"path": "/ws",
281291
},
282292
"dev": Object {},
@@ -307,6 +317,7 @@ Object {
307317
exports[`normalizeOptions multi compiler watchOptions is set should set correct options 1`] = `
308318
Object {
309319
"client": Object {
320+
"overlay": true,
310321
"path": "/ws",
311322
},
312323
"dev": Object {},
@@ -339,6 +350,7 @@ Object {
339350
exports[`normalizeOptions no options should set correct options 1`] = `
340351
Object {
341352
"client": Object {
353+
"overlay": true,
342354
"path": "/ws",
343355
},
344356
"dev": Object {},
@@ -369,6 +381,7 @@ Object {
369381
exports[`normalizeOptions single compiler watchOptions is object should set correct options 1`] = `
370382
Object {
371383
"client": Object {
384+
"overlay": true,
372385
"path": "/ws",
373386
},
374387
"dev": Object {},
@@ -401,6 +414,7 @@ Object {
401414
exports[`normalizeOptions single compiler watchOptions is object with static watch overriding it should set correct options 1`] = `
402415
Object {
403416
"client": Object {
417+
"overlay": true,
404418
"path": "/ws",
405419
},
406420
"dev": Object {},
@@ -433,6 +447,7 @@ Object {
433447
exports[`normalizeOptions single compiler watchOptions is object with static watch true should set correct options 1`] = `
434448
Object {
435449
"client": Object {
450+
"overlay": true,
436451
"path": "/ws",
437452
},
438453
"dev": Object {},
@@ -465,6 +480,7 @@ Object {
465480
exports[`normalizeOptions single compiler watchOptions is object with watch false should set correct options 1`] = `
466481
Object {
467482
"client": Object {
483+
"overlay": true,
468484
"path": "/ws",
469485
},
470486
"dev": Object {},
@@ -495,6 +511,7 @@ Object {
495511
exports[`normalizeOptions static is an array of static objects should set correct options 1`] = `
496512
Object {
497513
"client": Object {
514+
"overlay": true,
498515
"path": "/ws",
499516
},
500517
"dev": Object {},
@@ -536,6 +553,7 @@ Object {
536553
exports[`normalizeOptions static is an array of strings and static objects should set correct options 1`] = `
537554
Object {
538555
"client": Object {
556+
"overlay": true,
539557
"path": "/ws",
540558
},
541559
"dev": Object {},
@@ -577,6 +595,7 @@ Object {
577595
exports[`normalizeOptions static is an array of strings should set correct options 1`] = `
578596
Object {
579597
"client": Object {
598+
"overlay": true,
580599
"path": "/ws",
581600
},
582601
"dev": Object {},
@@ -618,6 +637,7 @@ Object {
618637
exports[`normalizeOptions static is an object should set correct options 1`] = `
619638
Object {
620639
"client": Object {
640+
"overlay": true,
621641
"path": "/ws",
622642
},
623643
"dev": Object {},
@@ -648,6 +668,7 @@ Object {
648668
exports[`normalizeOptions static is false should set correct options 1`] = `
649669
Object {
650670
"client": Object {
671+
"overlay": true,
651672
"path": "/ws",
652673
},
653674
"dev": Object {},
@@ -666,6 +687,7 @@ Object {
666687
exports[`normalizeOptions static is string should set correct options 1`] = `
667688
Object {
668689
"client": Object {
690+
"overlay": true,
669691
"path": "/ws",
670692
},
671693
"dev": Object {},
@@ -696,6 +718,7 @@ Object {
696718
exports[`normalizeOptions static is true should set correct options 1`] = `
697719
Object {
698720
"client": Object {
721+
"overlay": true,
699722
"path": "/ws",
700723
},
701724
"dev": Object {},
@@ -726,6 +749,7 @@ Object {
726749
exports[`normalizeOptions static publicPath is a string should set correct options 1`] = `
727750
Object {
728751
"client": Object {
752+
"overlay": true,
729753
"path": "/ws",
730754
},
731755
"dev": Object {},
@@ -756,6 +780,7 @@ Object {
756780
exports[`normalizeOptions static publicPath is an array should set correct options 1`] = `
757781
Object {
758782
"client": Object {
783+
"overlay": true,
759784
"path": "/ws",
760785
},
761786
"dev": Object {},
@@ -787,6 +812,7 @@ Object {
787812
exports[`normalizeOptions static serveIndex is an object should set correct options 1`] = `
788813
Object {
789814
"client": Object {
815+
"overlay": true,
790816
"path": "/ws",
791817
},
792818
"dev": Object {},
@@ -817,6 +843,7 @@ Object {
817843
exports[`normalizeOptions static serveIndex is false should set correct options 1`] = `
818844
Object {
819845
"client": Object {
846+
"overlay": true,
820847
"path": "/ws",
821848
},
822849
"dev": Object {},
@@ -845,6 +872,7 @@ Object {
845872
exports[`normalizeOptions static serveIndex is true should set correct options 1`] = `
846873
Object {
847874
"client": Object {
875+
"overlay": true,
848876
"path": "/ws",
849877
},
850878
"dev": Object {},
@@ -875,6 +903,7 @@ Object {
875903
exports[`normalizeOptions static watch is an object should set correct options 1`] = `
876904
Object {
877905
"client": Object {
906+
"overlay": true,
878907
"path": "/ws",
879908
},
880909
"dev": Object {},
@@ -907,6 +936,7 @@ Object {
907936
exports[`normalizeOptions static watch is false should set correct options 1`] = `
908937
Object {
909938
"client": Object {
939+
"overlay": true,
910940
"path": "/ws",
911941
},
912942
"dev": Object {},
@@ -937,6 +967,7 @@ Object {
937967
exports[`normalizeOptions static watch is true should set correct options 1`] = `
938968
Object {
939969
"client": Object {
970+
"overlay": true,
940971
"path": "/ws",
941972
},
942973
"dev": Object {},
@@ -967,6 +998,7 @@ Object {
967998
exports[`normalizeOptions transportMode custom client path should set correct options 1`] = `
968999
Object {
9691000
"client": Object {
1001+
"overlay": true,
9701002
"path": "/ws",
9711003
},
9721004
"dev": Object {},
@@ -997,6 +1029,7 @@ Object {
9971029
exports[`normalizeOptions transportMode custom server class should set correct options 1`] = `
9981030
Object {
9991031
"client": Object {
1032+
"overlay": true,
10001033
"path": "/ws",
10011034
},
10021035
"dev": Object {},
@@ -1027,6 +1060,7 @@ Object {
10271060
exports[`normalizeOptions transportMode custom server path should set correct options 1`] = `
10281061
Object {
10291062
"client": Object {
1063+
"overlay": true,
10301064
"path": "/ws",
10311065
},
10321066
"dev": Object {},
@@ -1057,6 +1091,7 @@ Object {
10571091
exports[`normalizeOptions transportMode sockjs string should set correct options 1`] = `
10581092
Object {
10591093
"client": Object {
1094+
"overlay": true,
10601095
"path": "/ws",
10611096
},
10621097
"dev": Object {},
@@ -1087,6 +1122,7 @@ Object {
10871122
exports[`normalizeOptions transportMode ws object should set correct options 1`] = `
10881123
Object {
10891124
"client": Object {
1125+
"overlay": true,
10901126
"path": "/ws",
10911127
},
10921128
"dev": Object {},
@@ -1117,6 +1153,7 @@ Object {
11171153
exports[`normalizeOptions transportMode ws string should set correct options 1`] = `
11181154
Object {
11191155
"client": Object {
1156+
"overlay": true,
11201157
"path": "/ws",
11211158
},
11221159
"dev": Object {},

0 commit comments

Comments
 (0)