Skip to content

Commit

Permalink
fix(server): ignore stats objects that are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
knagaitsev committed Jun 30, 2020
1 parent 80a34c1 commit 3319b0b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/utils/getStatsOption.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
'use strict';

function getStatsOption(configArr) {
const isEmptyObject = (val) =>
typeof val === 'object' && Object.keys(val).length === 0;

// in webpack@4 stats will not be defined if not provided,
// but in webpack@5 it will be an empty object
const statsConfig = configArr.find(
(conf) => typeof conf === 'object' && conf.stats
(conf) =>
typeof conf === 'object' && conf.stats && !isEmptyObject(conf.stats)
);
return statsConfig ? statsConfig.stats : {};
}
Expand Down
3 changes: 3 additions & 0 deletions test/server/utils/getStatsOption.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ describe('getStatsOption', () => {
{
entry: './index.js',
},
{
stats: {},
},
{
stats: 'errors-only',
},
Expand Down

0 comments on commit 3319b0b

Please sign in to comment.