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(build): show full error stats #2879

Merged
merged 1 commit into from
Nov 7, 2016

Conversation

filipesilva
Copy link
Contributor

Currently, running ng build error reporting for some classes of errors is not very useful.

For example, if you have a reference to an missing styles file in angular-cli.json, this is the output:

kamik@T460p MINGW64 /D/sandbox/master-proj (master)
$ ng build
 10% building modules 2/2 modules 0 activeresolve 'D:\sandbox\master-proj\src\nope.css' in 'D:\work\angular-cli\packages\angular-cli\models'
  using description file: D:\work\angular-cli\packages\angular-cli\package.json (relative path: ./models)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: D:\work\angular-cli\packages\angular-cli\package.json (relative path: ./models)
    using description file: D:\sandbox\master-proj\package.json (relative path: ./src/nope.css)
      as directory
        D:\sandbox\master-proj\src\nope.css doesn't exist
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        D:\sandbox\master-proj\src\nope.css doesn't exist
      .ts
        Field 'browser' doesn't contain a valid alias configuration
        D:\sandbox\master-proj\src\nope.css.ts doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        D:\sandbox\master-proj\src\nope.css.js doesn't exist

D:\work\angular-cli\node_modules\webpack\lib\Compiler.js:220
                                        if(err) return callback(err);
                    ^
TypeError: Cannot read property 'hash' of undefined
    at D:\work\angular-cli\packages\angular-cli\tasks\build-webpack.ts:35:26
    at Compiler.onCompiled (D:\work\angular-cli\node_modules\webpack\lib\Compiler.js:220:21)
    at Compiler.<anonymous> (D:\work\angular-cli\node_modules\webpack\lib\Compiler.js:464:19)
    at D:\work\angular-cli\node_modules\tapable\lib\Tapable.js:148:11
(...)

This PR makes the error reporting similar to the output of ng serve, but still maintaining the error exit code:

kamik@T460p MINGW64 /D/sandbox/master-proj (master)
$ ng build
4800ms building modules
(...)
      index.html  491 bytes          [emitted]
 assets/file.txt    0 bytes          [emitted]
     favicon.ico    5.43 kB          [emitted]
chunk    {0} main.bundle.js, main.map (main) 2 MB {1} [initial] [rendered]
chunk    {1} styles.bundle.js, styles.map (styles) 10.2 kB {2} [initial] [rendered]
chunk    {2} inline.js, inline.map (inline) 0 bytes [entry] [rendered]

ERROR in multi styles
Module not found: Error: Can't resolve 'D:\sandbox\master-proj\src\nope.css' in 'D:\work\angular-cli\packages\angular-cli\models'
 @ multi styles
Child html-webpack-plugin for "index.html":
         Asset     Size  Chunks       Chunk Names
    index.html  2.84 kB       0
    chunk    {0} index.html 372 bytes [entry] [rendered]

kamik@T460p MINGW64 /D/sandbox/master-proj (master)
$ echo $?
1

@chalin
Copy link

chalin commented Oct 25, 2016

Thanks for the PR!
cc @ericjim

@@ -39,21 +36,18 @@ export default <any>Task.extend({

return new Promise((resolve, reject) => {
webpackCompiler.run((err: any, stats: any) => {
if (err) { reject(err); }
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to return from this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure it makes any difference. I can return here and on the final resolve/reject one though, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@valorkin
Copy link
Contributor

this one small, but hides real exception

@filipesilva
Copy link
Contributor Author

@valorkin can you clarify what you mean? In the example I gave it seemed to me that the full exception was actually hiding the error a user would need to fix.

@valorkin
Copy link
Contributor

valorkin commented Nov 7, 2016

I meant that this small fix (by amount of code ) does a great deal. Because previous implementation was hiding real error stack if stats eq null

@hansl
Copy link
Contributor

hansl commented Nov 7, 2016

LGTM

@hansl hansl merged commit d59fa1f into angular:master Nov 7, 2016
@filipesilva filipesilva deleted the better-build-errors branch November 7, 2016 21:16
MRHarrison pushed a commit to MRHarrison/angular-cli that referenced this pull request Feb 9, 2017
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants