From 3321f3138e554d41ffca1ac880803dfd2ac1e105 Mon Sep 17 00:00:00 2001 From: James George Date: Wed, 19 Jun 2019 20:05:43 +0530 Subject: [PATCH 1/3] Handle cryptic error message being thrown misconfigured config file --- lib/webpack.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/webpack.js b/lib/webpack.js index 2362951c4d9..f8dffa72f43 100644 --- a/lib/webpack.js +++ b/lib/webpack.js @@ -32,7 +32,7 @@ const webpack = (options, callback) => { } let compiler; if (Array.isArray(options)) { - compiler = new MultiCompiler(options.map(options => webpack(options))); + compiler = new MultiCompiler(Array.from(options).map(options => webpack(options))); } else if (typeof options === "object") { options = new WebpackOptionsDefaulter().process(options); From 0109d687a67aa3bd717ce36ce3fd88c1e6aa1af7 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Wed, 19 Jun 2019 20:29:37 +0530 Subject: [PATCH 2/3] Linting fix --- lib/webpack.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/webpack.js b/lib/webpack.js index f8dffa72f43..3e121f41fa9 100644 --- a/lib/webpack.js +++ b/lib/webpack.js @@ -32,7 +32,9 @@ const webpack = (options, callback) => { } let compiler; if (Array.isArray(options)) { - compiler = new MultiCompiler(Array.from(options).map(options => webpack(options))); + compiler = new MultiCompiler( + Array.from(options).map(options => webpack(options)) + ); } else if (typeof options === "object") { options = new WebpackOptionsDefaulter().process(options); From 226e8ce8fd9fee33e8d8b37dd4d7d9c24483b4f9 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 19 Jun 2019 18:55:27 +0200 Subject: [PATCH 3/3] add test case for holey array --- test/Validation.test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/Validation.test.js b/test/Validation.test.js index e82f8de54fa..694dcd39b33 100644 --- a/test/Validation.test.js +++ b/test/Validation.test.js @@ -404,6 +404,25 @@ describe("Validation", () => { - configuration.mode should be one of these: \\"development\\" | \\"production\\" | \\"none\\" -> Enable production optimizations or development hints." +`) + ); + + createTestCase( + "holey array", + // eslint-disable-next-line no-sparse-arrays + [ + { + mode: "production" + }, + , + { + mode: "development" + } + ], + msg => + expect(msg).toMatchInlineSnapshot(` +"Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. + - configuration should be an object." `) ); });