Skip to content

Commit 242d2ec

Browse files
authored
refactor: config group to pure function and move away from group design (#1811)
* chore: remove default value from config/entry flag * refactor: ConfigGroup remove from group design
1 parent 6140b24 commit 242d2ec

9 files changed

Lines changed: 195 additions & 196 deletions

File tree

packages/serve/__tests__/__snapshots__/parseArgs.test.ts.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Object {
1111
},
1212
"webpackArgs": Object {
1313
"color": true,
14-
"config": Array [],
1514
"hot": true,
1615
"mode": "production",
1716
},
@@ -41,7 +40,6 @@ Object {
4140
},
4241
"webpackArgs": Object {
4342
"color": true,
44-
"config": Array [],
4543
"mode": "development",
4644
},
4745
}

packages/webpack-cli/__tests__/ConfigGroup/ConfigGroup.test.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const promiseConfig = require('./webpack.promise.config.cjs');
77

88
describe('ConfigGroup', function () {
99
it('should handle merge properly', async () => {
10-
const group = new ConfigGroup([
10+
const result = await ConfigGroup([
1111
{
1212
merge: true,
1313
},
@@ -16,7 +16,6 @@ describe('ConfigGroup', function () {
1616
},
1717
]);
1818

19-
const result = await group.run();
2019
const expectedOptions = {
2120
output: { filename: './dist-commonjs.js', libraryTarget: 'commonjs' },
2221
entry: './a.js',
@@ -30,35 +29,31 @@ describe('ConfigGroup', function () {
3029
});
3130

3231
it('should return array for multiple config', async () => {
33-
const group = new ConfigGroup([
32+
const result = await ConfigGroup([
3433
{ config: [resolve(__dirname, './webpack.config1.cjs'), resolve(__dirname, './webpack.config2.cjs')] },
3534
]);
36-
const result = await group.run();
3735
const expectedOptions = [config1, config2];
3836
expect(result.options).toEqual(expectedOptions);
3937
expect(result.outputOptions).toEqual({});
4038
});
4139

4240
it('should return config object for single config', async () => {
43-
const group = new ConfigGroup([{ config: [resolve(__dirname, './webpack.config1.cjs')] }]);
44-
const result = await group.run();
41+
const result = await ConfigGroup([{ config: [resolve(__dirname, './webpack.config1.cjs')] }]);
4542
expect(result.options).toEqual(config1);
4643
expect(result.outputOptions).toEqual({});
4744
});
4845

4946
it('should return resolved config object for promise config', async () => {
50-
const group = new ConfigGroup([{ config: [resolve(__dirname, './webpack.promise.config.cjs')] }]);
51-
const result = await group.run();
47+
const result = await ConfigGroup([{ config: [resolve(__dirname, './webpack.promise.config.cjs')] }]);
5248
const expectedOptions = await promiseConfig();
5349
expect(result.options).toEqual(expectedOptions);
5450
expect(result.outputOptions).toEqual({});
5551
});
5652

5753
it('should handle configs returning different types', async () => {
58-
const group = new ConfigGroup([
54+
const result = await ConfigGroup([
5955
{ config: [resolve(__dirname, './webpack.promise.config.cjs'), resolve(__dirname, './webpack.config.cjs')] },
6056
]);
61-
const result = await group.run();
6257
const resolvedPromiseConfig = await promiseConfig();
6358
const expectedOptions = [resolvedPromiseConfig, ...arrayConfig];
6459
expect(result.options).toEqual(expectedOptions);

packages/webpack-cli/__tests__/GroupHelper.test.js

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

0 commit comments

Comments
 (0)