-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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 build on compiler error, after printing a useful message #13255
Conversation
/to @cramforce |
/to @erwinmombay @choumx |
console.error(red(err.message)); | ||
} | ||
// Drop the node_modules call stack, which begins with ' at'. | ||
const message = err.stack.replace(/ at[^]*/, '').trim(); |
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.
why do we want to drop it?
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.
The stack has nothing to do with the actual syntax error, and gets cumbersome to read. For example, here's what I see when I print the entire stack:
SyntaxError: /usr/local/google/home/rsimha/src/amphtml/src/service-worker/kill.js: Unexpected token (28:6)
26 | });
27 | if (foo)
> 28 | bar(;
| ^
29 |
30 | self.addEventListener('activate', function(event) {
31 | // Usually after waiting for a navigation, it has to wait for all other
at Parser.pp$5.raise (/usr/local/google/home/rsimha/src/amphtml/node_modules/babylon/lib/index.js:4454:13)
at Parser.pp.unexpected (/usr/local/google/home/rsimha/src/amphtml/node_modules/babylon/lib/index.js:1761:8)
at Parser.pp$3.parseExprAtom (/usr/local/google/home/rsimha/src/amphtml/node_modules/babylon/lib/index.js:3750:12)
at Parser.pp$3.parseExprSubscripts (/usr/local/google/home/rsimha/src/amphtml/node_modules/babylon/lib/index.js:3494:19)
at Parser.pp$3.parseMaybeUnary (/usr/local/google/home/rsimha/src/amphtml/node_modules/babylon/lib/index.js:3474:19)
at Parser.pp$3.parseExprOps (/usr/local/google/home/rsimha/src/amphtml/node_modules/babylon/lib/index.js:3404:19)
at Parser.pp$3.parseMaybeConditional (/usr/local/google/home/rsimha/src/amphtml/node_modules/babylon/lib/index.js:3381:19)
at Parser.pp$3.parseMaybeAssign (/usr/local/google/home/rsimha/src/amphtml/node_modules/babylon/lib/index.js:3344:19)
at Parser.pp$3.parseExprListItem (/usr/local/google/home/rsimha/src/amphtml/node_modules/babylon/lib/index.js:4312:16)
at Parser.pp$3.parseCallExpressionArguments (/usr/local/google/home/rsimha/src/amphtml/node_modules/babylon/lib/index.js:3573:20)
at Parser.pp$3.parseSubscripts (/usr/local/google/home/rsimha/src/amphtml/node_modules/babylon/lib/index.js:3533:31)
at Parser.pp$3.parseExprSubscripts (/usr/local/google/home/rsimha/src/amphtml/node_modules/babylon/lib/index.js:3504:15)
at Parser.pp$3.parseMaybeUnary (/usr/local/google/home/rsimha/src/amphtml/node_modules/babylon/lib/index.js:3474:19)
at Parser.pp$3.parseExprOps (/usr/local/google/home/rsimha/src/amphtml/node_modules/babylon/lib/index.js:3404:19)
at Parser.pp$3.parseMaybeConditional (/usr/local/google/home/rsimha/src/amphtml/node_modules/babylon/lib/index.js:3381:19)
at Parser.pp$3.parseMaybeAssign (/usr/local/google/home/rsimha/src/amphtml/node_modules/babylon/lib/index.js:3344:19)
@rsimha-amp this error message is awesome. One (unintended?) result is that if I am running Is this the intended behavior? |
@calebcordry Good catch, that wasn't intentional. I think we should exit if there's a syntax error during I'll send you a PR. Edit: Sent out #13312 |
SGTM. Thanks! |
This PR causes the build to fail after a compiler error, after printing a useful message.
Syntax error:
Other errors, like bad imports:
Fixes #1213