Skip to content

Commit 353a1af

Browse files
authored
Merge branch 'master' into fix/non-web-target
2 parents 790f08f + 2496110 commit 353a1af

12 files changed

+53
-51
lines changed

package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"tcp-port-used": "^1.0.2",
109109
"typescript": "^4.2.3",
110110
"url-loader": "^4.1.1",
111-
"webpack": "^5.26.2",
111+
"webpack": "^5.27.1",
112112
"webpack-cli": "^4.5.0",
113113
"webpack-merge": "^5.7.3"
114114
},

test/e2e/DevServer.test.js

+12-16
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe('DevServer', () => {
77
const webpack5Test = isWebpack5 ? it : it.skip;
88

99
it('should add devServer entry points to a single entry point', (done) => {
10-
testBin('--config ./test/fixtures/dev-server/default-config.js')
10+
testBin(null, './test/fixtures/dev-server/default-config.js')
1111
.then((output) => {
1212
expect(output.exitCode).toEqual(0);
1313
expect(output.stdout).toContain('client/default/index.js?');
@@ -19,9 +19,7 @@ describe('DevServer', () => {
1919
webpack5Test(
2020
'should add devServer entry points to a multi entry point object',
2121
(done) => {
22-
testBin(
23-
'--config ./test/fixtures/dev-server/multi-entry.js --stats=verbose'
24-
)
22+
testBin('--stats=verbose', './test/fixtures/dev-server/multi-entry.js')
2523
.then((output) => {
2624
expect(output.exitCode).toEqual(0);
2725
expect(output.stdout).toContain('client/default/index.js?');
@@ -35,7 +33,7 @@ describe('DevServer', () => {
3533
webpack5Test(
3634
'should add devServer entry points to an empty entry object',
3735
(done) => {
38-
testBin('--config ./test/fixtures/dev-server/empty-entry.js')
36+
testBin(null, './test/fixtures/dev-server/empty-entry.js')
3937
.then((output) => {
4038
expect(output.exitCode).toEqual(0);
4139
expect(output.stdout).toContain('client/default/index.js?');
@@ -47,7 +45,8 @@ describe('DevServer', () => {
4745

4846
webpack5Test('should supports entry as descriptor', (done) => {
4947
testBin(
50-
'--config ./test/fixtures/entry-as-descriptor/webpack.config --stats detailed'
48+
'--stats detailed',
49+
'./test/fixtures/entry-as-descriptor/webpack.config'
5150
)
5251
.then((output) => {
5352
expect(output.exitCode).toEqual(0);
@@ -58,9 +57,7 @@ describe('DevServer', () => {
5857
});
5958

6059
it('should only prepends devServer entry points to "web" target', (done) => {
61-
testBin(
62-
'--config ./test/fixtures/dev-server/default-config.js --target web'
63-
)
60+
testBin('--target web', './test/fixtures/dev-server/default-config.js')
6461
.then((output) => {
6562
expect(output.exitCode).toEqual(0);
6663
expect(output.stdout).toContain('client/default/index.js?');
@@ -71,9 +68,7 @@ describe('DevServer', () => {
7168
});
7269

7370
it('should not prepend devServer entry points to "node" target', (done) => {
74-
testBin(
75-
'--config ./test/fixtures/dev-server/default-config.js --target node'
76-
)
71+
testBin('--target node', './test/fixtures/dev-server/default-config.js')
7772
.then((output) => {
7873
expect(output.exitCode).toEqual(0);
7974
expect(output.stdout).not.toContain('client/default/index.js?');
@@ -85,7 +80,8 @@ describe('DevServer', () => {
8580

8681
it('should prepends the hot runtime to "node" target as well', (done) => {
8782
testBin(
88-
'--config ./test/fixtures/dev-server/default-config.js --target node --hot'
83+
'--target node --hot',
84+
'./test/fixtures/dev-server/default-config.js'
8985
)
9086
.then((output) => {
9187
expect(output.exitCode).toEqual(0);
@@ -112,7 +108,7 @@ describe('DevServer', () => {
112108
});
113109

114110
it('does not use client.path when default', (done) => {
115-
testBin('--config ./test/fixtures/dev-server/client-default-path-config.js')
111+
testBin(null, './test/fixtures/dev-server/client-default-path-config.js')
116112
.then((output) => {
117113
expect(output.exitCode).toEqual(0);
118114
expect(output.stdout).not.toContain('&path=/ws');
@@ -122,7 +118,7 @@ describe('DevServer', () => {
122118
});
123119

124120
it('should use client.path when custom', (done) => {
125-
testBin('--config ./test/fixtures/dev-server/client-custom-path-config.js')
121+
testBin(null, './test/fixtures/dev-server/client-custom-path-config.js')
126122
.then((output) => {
127123
expect(output.exitCode).toEqual(0);
128124
expect(output.stdout).toContain('&path=/custom/path');
@@ -134,7 +130,7 @@ describe('DevServer', () => {
134130
webpack5Test(
135131
'should prepend devServer entry points depending on targetProperties',
136132
(done) => {
137-
testBin('--config ./test/fixtures/dev-server/target-config.js')
133+
testBin(null, './test/fixtures/dev-server/target-config.js')
138134
.then((output) => {
139135
expect(output.exitCode).toEqual(0);
140136
expect(output.stdout).toContain('client/default/index.js');

test/fixtures/cli/webpack.config.js

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
11
'use strict';
22

3+
const ExitOnDonePlugin = require('../../helpers/ExitOnDonePlugin');
4+
35
module.exports = {
46
mode: 'development',
57
stats: 'detailed',
68
context: __dirname,
79
entry: './foo.js',
8-
plugins: [
9-
{
10-
apply(compiler) {
11-
compiler.hooks.done.tap('webpack-dev-server', (stats) => {
12-
let exitCode = 0;
13-
if (stats.hasErrors()) {
14-
exitCode = 1;
15-
}
16-
setTimeout(() => process.exit(exitCode));
17-
});
18-
},
19-
},
20-
],
10+
plugins: [ExitOnDonePlugin],
2111
};

test/fixtures/dev-server/client-custom-path-config.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const { resolve } = require('path');
4+
const ExitOnDonePlugin = require('../../helpers/ExitOnDonePlugin');
45

56
module.exports = {
67
mode: 'development',
@@ -15,4 +16,5 @@ module.exports = {
1516
client: 'sockjs',
1617
},
1718
},
19+
plugins: [ExitOnDonePlugin],
1820
};

test/fixtures/dev-server/client-default-path-config.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const { resolve } = require('path');
4+
const ExitOnDonePlugin = require('../../helpers/ExitOnDonePlugin');
45

56
module.exports = {
67
mode: 'development',
@@ -15,4 +16,5 @@ module.exports = {
1516
client: 'sockjs',
1617
},
1718
},
19+
plugins: [ExitOnDonePlugin],
1820
};

test/fixtures/dev-server/default-config.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const { resolve } = require('path');
4+
const ExitOnDonePlugin = require('../../helpers/ExitOnDonePlugin');
45

56
module.exports = {
67
mode: 'development',
@@ -15,4 +16,5 @@ module.exports = {
1516
client: 'sockjs',
1617
},
1718
},
19+
plugins: [ExitOnDonePlugin],
1820
};
+4-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
'use strict';
22

3+
const ExitOnDonePlugin = require('../../helpers/ExitOnDonePlugin');
4+
35
module.exports = {
46
mode: 'development',
5-
stats: 'detailed',
7+
stats: { orphanModules: true, preset: 'detailed' },
68
entry: {},
79
devServer: {
810
transportMode: {
911
server: 'sockjs',
1012
client: 'sockjs',
1113
},
1214
},
15+
plugins: [ExitOnDonePlugin],
1316
};

test/fixtures/dev-server/multi-entry.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const { resolve } = require('path');
4+
const ExitOnDonePlugin = require('../../helpers/ExitOnDonePlugin');
45

56
module.exports = {
67
mode: 'development',
@@ -16,4 +17,5 @@ module.exports = {
1617
client: 'sockjs',
1718
},
1819
},
20+
plugins: [ExitOnDonePlugin],
1921
};

test/fixtures/dev-server/target-config.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const { resolve } = require('path');
4+
const ExitOnDonePlugin = require('../../helpers/ExitOnDonePlugin');
45

56
module.exports = {
67
mode: 'development',
@@ -21,4 +22,5 @@ module.exports = {
2122
client: 'sockjs',
2223
},
2324
},
25+
plugins: [ExitOnDonePlugin],
2426
};

test/fixtures/entry-as-descriptor/webpack.config.js

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const ExitOnDonePlugin = require('../../helpers/ExitOnDonePlugin');
4+
35
module.exports = {
46
mode: 'development',
57
context: __dirname,
@@ -8,19 +10,7 @@ module.exports = {
810
import: './foo.js',
911
},
1012
},
11-
plugins: [
12-
{
13-
apply(compiler) {
14-
compiler.hooks.done.tap('webpack-dev-server', (stats) => {
15-
let exitCode = 0;
16-
if (stats.hasErrors()) {
17-
exitCode = 1;
18-
}
19-
setTimeout(() => process.exit(exitCode));
20-
});
21-
},
22-
},
23-
],
13+
plugins: [ExitOnDonePlugin],
2414
infrastructureLogging: {
2515
level: 'warn',
2616
},

test/helpers/ExitOnDonePlugin.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
module.exports = {
4+
apply(compiler) {
5+
compiler.hooks.done.tap('webpack-dev-server', (stats) => {
6+
let exitCode = 0;
7+
if (stats.hasErrors()) {
8+
exitCode = 1;
9+
}
10+
setTimeout(() => process.exit(exitCode));
11+
});
12+
},
13+
};

0 commit comments

Comments
 (0)