From 963e1e756982d2b44e265e78092a1df990ccde3f Mon Sep 17 00:00:00 2001 From: Damian Pieczynski Date: Fri, 23 Oct 2020 09:08:03 +0200 Subject: [PATCH] fix: compiler.options can be undefined in webpack 4 --- packages/webpack-cli/lib/webpack-cli.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index e2b329d50b1..9afb777a51b 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -299,9 +299,11 @@ class WebpackCLI extends GroupHelper { return stats; }; + const getStatsOptionsFromCompiler = (compiler) => getStatsOptions(compiler.options ? compiler.options.stats : undefined); + const foundStats = compiler.compilers - ? { children: compiler.compilers.map((compiler) => getStatsOptions(compiler.options.stats)) } - : getStatsOptions(compiler.options.stats); + ? { children: compiler.compilers.map(getStatsOptionsFromCompiler) } + : getStatsOptionsFromCompiler(compiler); if (outputOptions.json === true) { process.stdout.write(JSON.stringify(stats.toJson(foundStats), null, 2) + '\n');