webpack: Using --bail makes module build errors more cryptic.
We use --bail
so that webpack will report errors to our build script (without --bail, it doesn’t give an error exit code).
Unfortunately, when you use --bail
, the error result from unparseable JavaScript loses the line that tells you what file the error occurred in.
Example output without --bail
:
Hash: 91ed442d775c1a722525
Version: webpack 1.4.13
Time: 3094ms
Asset Size Chunks Chunk Names
<snip>
+ 286 hidden modules
ERROR in ./pages/MyPage.js
Module build failed: Error: Parse Error: Line 7: Unexpected token ;
at throwError (/Users/sashaaickin/code/main/corvair/node_modules/jsx-loader/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:2644:21)
at throwUnexpected (/Users/sashaaickin/code/main/corvair/node_modules/jsx-loader/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:2706:9)
<snip>
at parseProgramElement (/Users/sashaaickin/code/main/corvair/node_modules/jsx-loader/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:6185:16)
@ ./target-entrypoints/MyPageEntry.js 4:17-68
With --bail
, the output looks like:
ModuleBuildError: Module build failed: Error: Parse Error: Line 7: Unexpected token ;
at throwError (/Users/sashaaickin/code/main/corvair/node_modules/jsx-loader/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:2644:21)
at throwUnexpected (/Users/sashaaickin/code/main/corvair/node_modules/jsx-loader/node_modules/react-tools/node_modules/jstransform/node_modules/esprima-fb/esprima.js:2706:9)
<snip>
at /Users/sashaaickin/code/main/corvair/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:270:15
at runSyncOrAsync (/Users/sashaaickin/code/main/corvair/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:158:12)
Note that without --bail, the file with the syntax error (MyPage.js) is named, but not in the latter. This makes it hard to debug problems that come from our build script, because the error log does not tell us what file the problem is in.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 12
- Comments: 15 (3 by maintainers)
Commits related to this issue
- Bump tslint-loader to 2.1.3 which includes a workaround for the --bail bug https://github.com/webpack/webpack/issues/711 — committed to jhuntoo/angular2-webpack-starter by jhuntoo 8 years ago
- [CSL-818] Webpack hack to get detailed error and exit code See https://github.com/webpack/webpack/issues/711#issuecomment-282084702 — committed to input-output-hk/cardano-sl by jmitchell 7 years ago
- Bump tslint-loader to 2.1.3 which includes a workaround for the --bail bug https://github.com/webpack/webpack/issues/711 — committed to DevStar0804/star by DevStar0804 4 years ago
- Bump tslint-loader to 2.1.3 which includes a workaround for the --bail bug https://github.com/webpack/webpack/issues/711 — committed to DevStar0804/star by DevStar0804 4 years ago
- Bump tslint-loader to 2.1.3 which includes a workaround for the --bail bug https://github.com/webpack/webpack/issues/711 — committed to eagerbeaver0353/invoice-app-electron-angular by eagerbeaver0353 8 years ago
- Bump tslint-loader to 2.1.3 which includes a workaround for the --bail bug https://github.com/webpack/webpack/issues/711 — committed to leonhiat/MFE-starter by leonhiat 8 years ago
Any progress about this request? We will never build two times just to improve the logs…