Skip to content

Commit ecf2fe1

Browse files
authored
refactor: remove CLI progress and move progress option into client (#2857)
1 parent 98c68bf commit ecf2fe1

File tree

15 files changed

+42
-301
lines changed

15 files changed

+42
-301
lines changed

bin/cli-flags.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,25 @@ module.exports = {
2121
negative: true,
2222
},
2323
{
24-
name: 'profile',
24+
name: 'client-progress',
2525
type: Boolean,
26-
describe: 'Print compilation profile data for progress steps',
27-
},
28-
{
29-
name: 'progress',
30-
type: Boolean,
31-
describe: 'Print compilation progress in percentage',
26+
describe: 'Print compilation progress in percentage in the browser',
3227
group: BASIC_GROUP,
28+
processor(opts) {
29+
opts.client = opts.client || {};
30+
opts.client.progress = opts.clientProgress;
31+
delete opts.clientProgress;
32+
},
3333
},
3434
{
3535
name: 'hot-only',
3636
type: Boolean,
3737
describe: 'Do not refresh page if HMR fails',
3838
group: ADVANCED_GROUP,
39+
processor(opts) {
40+
opts.hot = 'only';
41+
delete opts.hotOnly;
42+
},
3943
},
4044
{
4145
name: 'setup-exit-signals',
@@ -73,6 +77,11 @@ module.exports = {
7377
group: DISPLAY_GROUP,
7478
describe:
7579
'Log level in the browser (none, error, warn, info, log, verbose)',
80+
processor(opts) {
81+
opts.client = opts.client || {};
82+
opts.client.logging = opts.clientLogging;
83+
delete opts.clientLogging;
84+
},
7685
},
7786
{
7887
name: 'https',
@@ -106,7 +115,6 @@ module.exports = {
106115
describe: 'Enable gzip compression',
107116
group: RESPONSE_GROUP,
108117
},
109-
// findPort is currently not set up
110118
{
111119
name: 'port',
112120
type: Number,

bin/options.js

Lines changed: 0 additions & 114 deletions
This file was deleted.

examples/cli/progress/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { setup } = require('../../util');
77
module.exports = setup({
88
context: __dirname,
99
entry: './app.js',
10-
devServer: {
10+
client: {
1111
progress: true,
1212
},
1313
});

lib/Server.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Server {
5858
this.options
5959
);
6060

61-
if (this.options.progress) {
61+
if (this.options.client.progress) {
6262
this.setupProgressPlugin();
6363
}
6464
this.setupHooks();
@@ -83,12 +83,6 @@ class Server {
8383
}
8484

8585
setupProgressPlugin() {
86-
// for CLI output
87-
new webpack.ProgressPlugin({
88-
profile: !!this.options.profile,
89-
}).apply(this.compiler);
90-
91-
// for browser console output
9286
new webpack.ProgressPlugin((percent, msg, addInfo) => {
9387
percent = Math.floor(percent * 100);
9488

@@ -569,8 +563,8 @@ class Server {
569563
this.sockWrite([connection], 'liveReload');
570564
}
571565

572-
if (this.options.progress) {
573-
this.sockWrite([connection], 'progress', this.options.progress);
566+
if (this.options.client.progress) {
567+
this.sockWrite([connection], 'progress', this.options.client.progress);
574568
}
575569

576570
if (this.options.clientOverlay) {

lib/options.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@
8383
},
8484
"logging": {
8585
"enum": ["none", "error", "warn", "info", "log", "verbose"]
86+
},
87+
"progress": {
88+
"type": "boolean"
8689
}
8790
},
8891
"additionalProperties": false
@@ -292,12 +295,6 @@
292295
}
293296
]
294297
},
295-
"profile": {
296-
"type": "boolean"
297-
},
298-
"progress": {
299-
"type": "boolean"
300-
},
301298
"proxy": {
302299
"anyOf": [
303300
{
@@ -408,8 +405,6 @@
408405
"openPage": "should be {String|Array} (https://webpack.js.org/configuration/dev-server/#devserveropenpage)",
409406
"overlay": "should be {Boolean|Object} (https://webpack.js.org/configuration/dev-server/#devserveroverlay)",
410407
"port": "should be {Number|String|Null} (https://webpack.js.org/configuration/dev-server/#devserverport)",
411-
"profile": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverprofile)",
412-
"progress": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverprogress---cli-only)",
413408
"proxy": "should be {Object|Array} (https://webpack.js.org/configuration/dev-server/#devserverproxy)",
414409
"public": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserverpublic)",
415410
"setupExitSignals": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserversetupexitsignals)",

test/__snapshots__/Validation.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ exports[`Validation validation should fail validation for invalid \`static\` con
3939
exports[`Validation validation should fail validation for no additional properties 1`] = `
4040
"Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
4141
- configuration has an unknown property 'additional'. These properties are valid:
42-
object { bonjour?, client?, compress?, dev?, firewall?, headers?, historyApiFallback?, host?, hot?, http2?, https?, injectClient?, injectHot?, liveReload?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, openPage?, overlay?, port?, profile?, progress?, proxy?, public?, setupExitSignals?, static?, stdin?, transportMode?, useLocalIp? }"
42+
object { bonjour?, client?, compress?, dev?, firewall?, headers?, historyApiFallback?, host?, hot?, http2?, https?, injectClient?, injectHot?, liveReload?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, openPage?, overlay?, port?, proxy?, public?, setupExitSignals?, static?, stdin?, transportMode?, useLocalIp? }"
4343
`;

test/cli/cli.test.js

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -98,31 +98,6 @@ runCLITest('CLI', () => {
9898
.catch(done);
9999
});
100100

101-
it('--progress', (done) => {
102-
testBin('--progress')
103-
.then((output) => {
104-
expect(output.exitCode).toEqual(0);
105-
expect(output.stderr).toContain('100%');
106-
// should not profile
107-
expect(output.stderr).not.toContain(
108-
'ms after chunk modules optimization'
109-
);
110-
done();
111-
})
112-
.catch(done);
113-
});
114-
115-
it('--progress --profile', (done) => {
116-
testBin('--progress --profile')
117-
.then((output) => {
118-
expect(output.exitCode).toEqual(0);
119-
// should profile
120-
expect(output.stderr).toContain('after chunk modules optimization');
121-
done();
122-
})
123-
.catch(done);
124-
});
125-
126101
it('--bonjour', (done) => {
127102
testBin('--bonjour')
128103
.then((output) => {

test/client/utils/__snapshots__/createSocketUrl.test.js.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
exports[`createSocketUrl should return the url when __resourceQuery is ?test 1`] = `"/ws"`;
44

5+
exports[`createSocketUrl should return the url when __resourceQuery is file://filename 1`] = `"file://filename/ws"`;
6+
57
exports[`createSocketUrl should return the url when __resourceQuery is http://0.0.0.0 1`] = `"http://localhost/ws"`;
68

79
exports[`createSocketUrl should return the url when __resourceQuery is http://127.0.0.1 1`] = `"http://127.0.0.1/ws"`;
@@ -22,6 +24,8 @@ exports[`createSocketUrl should return the url when __resourceQuery is undefined
2224

2325
exports[`createSocketUrl should return the url when the current script source is ?test 1`] = `"/ws"`;
2426

27+
exports[`createSocketUrl should return the url when the current script source is file://filename 1`] = `"file://filename/ws"`;
28+
2529
exports[`createSocketUrl should return the url when the current script source is http://0.0.0.0 1`] = `"http://localhost/ws"`;
2630

2731
exports[`createSocketUrl should return the url when the current script source is http://127.0.0.1 1`] = `"http://127.0.0.1/ws"`;

test/client/utils/createSocketUrl.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ describe('createSocketUrl', () => {
1111
'https://localhost:123',
1212
'http://user:pass@[::]:8080',
1313
'http://127.0.0.1',
14-
// TODO: comment out after the major release
15-
// https://github.com/webpack/webpack-dev-server/pull/1954#issuecomment-498043376
16-
// 'file://filename',
14+
'file://filename',
1715
// eslint-disable-next-line no-undefined
1816
undefined,
1917
];

test/e2e/Progress.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ describe('client progress', () => {
3737
port,
3838
host: '0.0.0.0',
3939
hot: true,
40-
progress: true,
40+
client: {
41+
progress: true,
42+
},
4143
};
4244

4345
// we need a delay between file writing and the start

test/fixtures/schema/webpack.config.no-dev-stats.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ module.exports = {
88
devServer: {
99
host: '_foo',
1010
public: '_public',
11-
progress: '_progress',
1211
publicPath: '_publicPath',
1312
hot: '_hot',
1413
clientLogging: '_clientLogging',

test/options.test.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ describe('options', () => {
202202
port: null,
203203
},
204204
},
205+
{
206+
client: {
207+
progress: false,
208+
},
209+
},
205210
],
206211
failure: [
207212
'whoops!',
@@ -227,6 +232,11 @@ describe('options', () => {
227232
logging: 'silent',
228233
},
229234
},
235+
{
236+
client: {
237+
progress: '',
238+
},
239+
},
230240
],
231241
},
232242
compress: {
@@ -355,14 +365,6 @@ describe('options', () => {
355365
success: ['', 0, null],
356366
failure: [false],
357367
},
358-
profile: {
359-
success: [false],
360-
failure: [''],
361-
},
362-
progress: {
363-
success: [false],
364-
failure: [''],
365-
},
366368
proxy: {
367369
success: [
368370
{

test/ports-map.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ const portsList = {
3737
WebsocketServer: 1,
3838
TransportMode: 1,
3939
Progress: 1,
40-
'progress-option': 1,
41-
'profile-option': 1,
4240
Iframe: 1,
4341
SocketInjection: 1,
4442
'static-publicPath-option': 1,

0 commit comments

Comments
 (0)