Skip to content

fix(@angular/cli): not use buildOptimizer for JIT in prod #8346

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

Merged
merged 1 commit into from
Nov 20, 2017

Conversation

trotyl
Copy link
Contributor

@trotyl trotyl commented Nov 4, 2017

fixes #8345

@hansl
Copy link
Contributor

hansl commented Nov 4, 2017

Is this still work in progress?

@hansl
Copy link
Contributor

hansl commented Nov 4, 2017

If you fix the lint issue, we can merge this.

@trotyl
Copy link
Contributor Author

trotyl commented Nov 5, 2017

@hansl It was too late yesterday, just made a placeholder, will work on it soon.

@trotyl trotyl changed the title [WIP] fix(@angular/cli): not use buildOptimizer for JIT in prod fix(@angular/cli): not use buildOptimizer for JIT in prod Nov 5, 2017
@trotyl
Copy link
Contributor Author

trotyl commented Nov 5, 2017

@hansl Do you want me to add some tests against it? Not sure if this one is urgent.
If tests not required, should be ready to merge now.

@clydin
Copy link
Member

clydin commented Nov 5, 2017

Is decorator removal the only problematic pass within the build optimizer? Would it be useful to add an option to the build optimizer loader to disable the pass?

@trotyl
Copy link
Contributor Author

trotyl commented Nov 5, 2017

@clydin Without AOT there can be no tree-shaking or other kinds of dead-code elimination, all types would be referenced in metadata, the only optimization remains is tslib import.

@clydin
Copy link
Member

clydin commented Nov 5, 2017

The build optimizer passes facilitate dead code removal via UglifyJS for a variety of TypeScript output code structures. There is most definitely a benefit even without AOT enabled.

@trotyl
Copy link
Contributor Author

trotyl commented Nov 5, 2017

The build optimizer passes facilitate dead code removal via UglifyJS for a variety of TypeScript output code structures.

The code-wrapping or annotation will only help when the identifier itself is removable, so it's only true for non-Angular related TypeScript libraries, but for all Angular libraries there can be little help as nothing can be removed.

@clydin
Copy link
Member

clydin commented Nov 5, 2017

Which would demonstrate a benefit to leaving it in place. A significantly reduced benefit currently, but a benefit nonetheless.

@clydin
Copy link
Member

clydin commented Nov 5, 2017

Also of note is the following result of a simple application in JIT mode with decorator removal disabled:

0.bundle.js: 814 -> 19762 bytes (2327.76%), 474 -> 5803 bytes gzipped (1124.26%)
1.bundle.js: 20367 -> 499 bytes (-97.55%), 6057 -> 314 bytes gzipped (-94.82%)
main.bundle.js: 663919 -> 614389 bytes (-7.46%), 161742 -> 150118 bytes gzipped (-7.19%)
polyfills.bundle.js: 55243 -> 55243 bytes (0%), 17953 -> 17953 bytes gzipped (0%)
Total: 740343 -> 689893 bytes (-6.81%), 186226 -> 174188 bytes gzipped (-6.46%)

And an AIO test application with the same setup:

0.bundle.js: 14879 -> 14879 bytes (0%), 6633 -> 6633 bytes gzipped (0%)
main.bundle.js: 1230957 -> 1047748 bytes (-14.88%), 278220 -> 242911 bytes gzipped (-12.69%)
polyfills.bundle.js: 55243 -> 55243 bytes (0%), 17953 -> 17953 bytes gzipped (0%)
Total: 1301079 -> 1117870 bytes (-14.08%), 302806 -> 267497 bytes gzipped (-11.66%)

@trotyl
Copy link
Contributor Author

trotyl commented Nov 5, 2017

You're right, indeed what getPrefixClassesTransformer saves is a little higher than getScrubFileTransformer.

Copy link
Contributor

@filipesilva filipesilva left a comment

Choose a reason for hiding this comment

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

I think the PR at the moment is correct. While it is true that there are benefits to be had even in JIT, the intended behaviour was always that Build Optimizer can only be used with AOT (see the validateBuildOptions method). That it was possible to use it in JIT was an oversight of how defaults are processed.

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

ng build --no-aot --prod does not work in angular-cli 1.5
5 participants