Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: config group to pure function and move away from group design #1811

Merged
merged 9 commits into from
Sep 21, 2020
2 changes: 0 additions & 2 deletions packages/serve/__tests__/__snapshots__/parseArgs.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Object {
},
"webpackArgs": Object {
"color": true,
"config": Array [],
"hot": true,
"mode": "production",
},
Expand Down Expand Up @@ -41,7 +40,6 @@ Object {
},
"webpackArgs": Object {
"color": true,
"config": Array [],
"mode": "development",
},
}
Expand Down
15 changes: 5 additions & 10 deletions packages/webpack-cli/__tests__/ConfigGroup/ConfigGroup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const promiseConfig = require('./webpack.promise.config.cjs');

describe('ConfigGroup', function () {
it('should handle merge properly', async () => {
const group = new ConfigGroup([
const result = await ConfigGroup([
{
merge: true,
},
Expand All @@ -16,7 +16,6 @@ describe('ConfigGroup', function () {
},
]);

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

it('should return array for multiple config', async () => {
const group = new ConfigGroup([
const result = await ConfigGroup([
{ config: [resolve(__dirname, './webpack.config1.cjs'), resolve(__dirname, './webpack.config2.cjs')] },
]);
const result = await group.run();
const expectedOptions = [config1, config2];
expect(result.options).toEqual(expectedOptions);
expect(result.outputOptions).toEqual({});
});

it('should return config object for single config', async () => {
const group = new ConfigGroup([{ config: [resolve(__dirname, './webpack.config1.cjs')] }]);
const result = await group.run();
const result = await ConfigGroup([{ config: [resolve(__dirname, './webpack.config1.cjs')] }]);
expect(result.options).toEqual(config1);
expect(result.outputOptions).toEqual({});
});

it('should return resolved config object for promise config', async () => {
const group = new ConfigGroup([{ config: [resolve(__dirname, './webpack.promise.config.cjs')] }]);
const result = await group.run();
const result = await ConfigGroup([{ config: [resolve(__dirname, './webpack.promise.config.cjs')] }]);
const expectedOptions = await promiseConfig();
expect(result.options).toEqual(expectedOptions);
expect(result.outputOptions).toEqual({});
});

it('should handle configs returning different types', async () => {
const group = new ConfigGroup([
const result = await ConfigGroup([
{ config: [resolve(__dirname, './webpack.promise.config.cjs'), resolve(__dirname, './webpack.config.cjs')] },
]);
const result = await group.run();
const resolvedPromiseConfig = await promiseConfig();
const expectedOptions = [resolvedPromiseConfig, ...arrayConfig];
expect(result.options).toEqual(expectedOptions);
Expand Down
9 changes: 0 additions & 9 deletions packages/webpack-cli/__tests__/GroupHelper.test.js

This file was deleted.

Loading