Merge pull request #9306 from jamesgeorge007/hotfix/refactor

Handle cryptic error message being thrown
This commit is contained in:
Tobias Koppers 2019-06-19 19:45:31 +02:00 committed by GitHub
commit 494e16bd8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -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);

View File

@ -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."
`)
);
});