Skip to content

Commit

Permalink
chore: handle undefined configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabh3112 committed Sep 4, 2021
1 parent eaf9f36 commit 2328313
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 9 additions & 1 deletion packages/webpack-cli/lib/webpack-cli.js
Expand Up @@ -67,10 +67,18 @@ class WebpackCLI {
}

// For babel/typescript
if (result.default) {
if (result && result.default) {
result = result.default;
}

// Treat undefined configuration for zero-config
if (!result) {
this.logger.info(
"Configuration file provided didn't export any configuration, using defaults to build.",
);
result = {};
}

return result;
}

Expand Down
2 changes: 0 additions & 2 deletions test/build/config/undefined/undefined.test.js
Expand Up @@ -9,8 +9,6 @@ describe("config flag with undefined export config file", () => {
resolve(__dirname, "webpack.config.js"),
]);

console.log({ stdout, stderr, exitCode });

expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toBeTruthy();
Expand Down

0 comments on commit 2328313

Please sign in to comment.