-
Notifications
You must be signed in to change notification settings - Fork 615
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
Fail stencil bundle on Webpack compile errors #1457
Conversation
Thanks to @carsonreinke which first reported the issue. |
@jbruni thanks for the PR. This is awesome. Can you also add a changelog entry to the PR. |
@jbruni I think this should:
But at least now you can see the the failure when bundling. |
I agree if we have warning we should console log it. We shouldn't exit or fail the bundle but atleast notify the developer. |
In my opinion, we shall first ensure Cornerstone out-of-the-box won't raise warnings, and then we can include the Webpack warning report. |
@junedkazi - Please take a look at this commit which I pushed here: jbruni@e86e9b2
Related documentation here: If these changes look good to you, I can add that commit to this PR branch. |
@jbruni they look good. |
@junedkazi - Ok. 👍 I've just pushed the other commit to this PR branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbruni thank you for the awesome work on this PR 👏.
What?
When Webpack compilation fails,
stencil bundle
blindly ignores it.As a result, the generated theme ZIP file does not contain the
assets/dist
folder (just like in issue bigcommerce/stencil-cli#379)How to reproduce
Step-by-step from fresh Cornerstone, below.
In this example, we will simply add a line of JavaScript code which Babel will fail to understand:
In our real-world scenario, the Webpack build failed for other reasons, and we didn't need to shut up ESLint as in this example (the code passed in ESLint checks). Our scenario is more complex to reproduce. It requires other Webpack loaders and configurations.
The aim with this easy-to-reproduce example is to show how a Webpack build failure is ignored.
Later we learned that this happens when an exception is thrown from a Webpack loader (comment from sepo-one at webpack/webpack#708).
Solution
The callback for Webpack's
run
is(err, [stats](#stats-object))
Currently,
err
is considered, butstats
is ignored.Problem is that even when there is no
err
, errors may have happened in Webpack compilation, and they are available at thestats
object. Screenshot below is from Webpack documentation:This resembles Ajax error handling... there, we have "two layers" of possible errors... one of the Ajax call failing itself... and the other of the Ajax call returning an error code, or even some "error" code/message contained in an HTTP
200
response (terrible practice, but we can find it out there).Likewise, we have something similar in Webpack's
run
... anerr
for when the overall compile itself fails... and the other (stats
) of the compiler completing its work and returning an error code/message...Tickets / Documentation
run
method documentationstats
object documentationstats.toString()
methodScreenshots
Before changes from this PR,
stencil bundle
fails silently:After changes from this PR, we can see Webpack error message, and the bundle is interrupted: