Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Exit status code for fatal Webpack exceptions #1754

Merged
merged 4 commits into from Dec 17, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/spotty-singers-sleep.md
@@ -0,0 +1,5 @@
---
'preact-cli': patch
---

Corrects status code when there is a fatal Webpack error in production builds
10 changes: 5 additions & 5 deletions packages/cli/src/lib/webpack/run-webpack.js
Expand Up @@ -78,14 +78,14 @@ async function prodBuild(env) {
}

function runCompiler(compiler) {
return new Promise((res, rej) => {
return new Promise(res => {
compiler.run((err, stats) => {
showStats(stats, true);

if (err || (stats && stats.hasErrors())) {
rej(`${red('\n\nBuild failed! \n\n')} ${err || ''}`);
if (err) {
error(err, 1);
}

showStats(stats, true);

Comment on lines -83 to +88
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

showStats(), in production builds, will also immediately exit upon coming across any errors; as such, there's no reason to ever reject this promise as we've already exited.

res(stats);
});
});
Expand Down