diff --git a/lib/webpack.js b/lib/webpack.js index 2362951c4d9..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(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); 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." `) ); });