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(@angular/cli); show only changed chunks on build #8875

Merged
merged 1 commit into from Jan 9, 2018

Conversation

filipesilva
Copy link
Contributor

@filipesilva filipesilva commented Dec 14, 2017

For projects with a lot of lazy modules the rebuild messages can easily fill the whole console window.

This PR shows only chunks that changed instead of showing all chunks.

Before:

$ ng serve
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2017-12-14T14:56:13.707Z
Hash: 7490b2942c48ffcf0f0f
Time: 7317ms
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 725 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 577 kB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 35 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 6.45 MB [initial] [rendered]

webpack: Compiled successfully.
webpack: Compiling...
Date: 2017-12-14T14:56:17.054Z
Hash: dbb03cc0994e8bf69e76
Time: 310ms
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry]
chunk {main} main.bundle.js (main) 725 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 577 kB [initial]
chunk {styles} styles.bundle.js (styles) 35 kB [initial]
chunk {vendor} vendor.bundle.js (vendor) 6.45 MB [initial]

webpack: Compiled successfully.
webpack: Compiling...
Date: 2017-12-14T14:56:20.290Z
Hash: fe53cbcd529dd2508cfc
Time: 267ms
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry]
chunk {main} main.bundle.js (main) 725 kB [initial]
chunk {polyfills} polyfills.bundle.js (polyfills) 577 kB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 35 kB [initial]
chunk {vendor} vendor.bundle.js (vendor) 6.45 MB [initial]

webpack: Compiled successfully.

After:

$ ng serve** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2018-01-03T12:22:56.414Z
Hash: 38ba8d730f1803e5322f
Time: 8548ms
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 723 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 576 kB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 43 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 6.47 MB [initial] [rendered]

webpack: Compiled successfully.
webpack: Compiling...
Date: 2018-01-03T12:23:00.593Z • Hash: 9d8c8a72035d0d707df3 • Time: 259ms
4 unchanged chunks
chunk {main} main.bundle.js (main) 723 kB [initial] [rendered]

webpack: Compiled successfully.
webpack: Compiling...
Date: 2018-01-03T12:23:04.151Z • Hash: a95ea7bcfe80f0e4d747 • Time: 124ms
4 unchanged chunks
chunk {main} main.bundle.js (main) 723 kB [initial] [rendered]

webpack: Compiled successfully.

Fix #8621

}).join('\n')}
}).join('\n');

const unchangedChunkNumber = json.chunks.filter((chunk: any) => !chunk.rendered).length;
Copy link

@ghetolay ghetolay Dec 14, 2017

Choose a reason for hiding this comment

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

Wouldn't this work too ? no need to loop through chunks again.
const unchangedChunkNumber = json.chunks.length - changedChunksStats.length;

Choose a reason for hiding this comment

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

nvm didn't see the join. Could still keep the resulting array and join later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good idea, I'll do that.

Date: ${w(new Date().toISOString())}
Hash: ${w(json.hash)}
Time: ${w('' + json.time)}ms
${changedChunksStats ? changedChunksStats + '\n' : ''}${unchangedChunksMessage}
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks to this pullrequest. @filipesilva What you think to reorder console & get little bit more concis (because in dev mode, imo, short is better)
Before:
image

After:
image

Copy link
Contributor

@intellix intellix Dec 16, 2017

Choose a reason for hiding this comment

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

I think this looks really good :) It's no longer than this line either:

** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

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 like the shorter as well.

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've updated the first message to show the shorter output in the after snippet.

For projects with a lot of lazy modules the rebuild messages can easily fill the whole console window.

This PR shows only chunks that changed instead of showing all chunks.

Before:
```
$ ng serve
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2017-12-14T14:56:13.707Z
Hash: 7490b2942c48ffcf0f0f
Time: 7317ms
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 725 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 577 kB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 35 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 6.45 MB [initial] [rendered]

webpack: Compiled successfully.
webpack: Compiling...
Date: 2017-12-14T14:56:17.054Z
Hash: dbb03cc0994e8bf69e76
Time: 310ms
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry]
chunk {main} main.bundle.js (main) 725 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 577 kB [initial]
chunk {styles} styles.bundle.js (styles) 35 kB [initial]
chunk {vendor} vendor.bundle.js (vendor) 6.45 MB [initial]

webpack: Compiled successfully.
webpack: Compiling...
Date: 2017-12-14T14:56:20.290Z
Hash: fe53cbcd529dd2508cfc
Time: 267ms
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry]
chunk {main} main.bundle.js (main) 725 kB [initial]
chunk {polyfills} polyfills.bundle.js (polyfills) 577 kB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 35 kB [initial]
chunk {vendor} vendor.bundle.js (vendor) 6.45 MB [initial]

webpack: Compiled successfully.
```

After:
```
$ ng serve
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2017-12-14T14:53:40.216Z
Hash: 44065f5ec5c4c8cf884a
Time: 7312ms
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 724 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 576 kB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 35 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 6.45 MB [initial] [rendered]

webpack: Compiled successfully.
webpack: Compiling...
Date: 2017-12-14T14:53:42.089Z
Hash: 492a7350b12ec1557b61
Time: 241ms
chunk {main} main.bundle.js (main) 725 kB [initial] [rendered]
4 unchanged chunks

webpack: Compiled successfully.
webpack: Compiling...
Date: 2017-12-14T14:53:49.762Z
Hash: 7490b2942c48ffcf0f0f
Time: 296ms
chunk {polyfills} polyfills.bundle.js (polyfills) 577 kB [initial] [rendered]
4 unchanged chunks

webpack: Compiled successfully.
```

Fix angular#8621
@clydin clydin merged commit 788c8f9 into angular:master Jan 9, 2018

if (unchangedChunkNumber > 0) {
return rs(stripIndents`
Date: ${w(new Date().toISOString())} • Hash: ${w(json.hash)} • Time: ${w('' + json.time)}ms
Copy link
Contributor

Choose a reason for hiding this comment

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

This output leads to two beep sounds on windows systems due to the two '•' characters, see https://blogs.msdn.microsoft.com/oldnewthing/20070104-00/?p=28513

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's use a fancy character they said. What could go wrong they said.

😞

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TobiasSchulte does this happen on your system? I tried on mine (Windows 10, basic cmd) and I didn't get a beep.

Copy link
Contributor

Choose a reason for hiding this comment

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

@filipesilva Yes, it happens on my machine and on the machine of a colleague. Both are Windows 7 systems, it happens in a normal cmd, but not for example in the vscode integrated terminal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would you be interested in making a PR that changes to -?

Copy link
Contributor

Choose a reason for hiding this comment

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

@filipesilva Pull request is created

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TobiasSchulte we have already made that change in #9336

@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 12, 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.

group lazy modules in console when doing ng serve
8 participants