question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support Closure Compiler with --compilation_level=ADVANCED_OPTIMIZATIONS

See original GitHub issue

In Angular prior to version 10.0 it was possible to use Closure Compiler with --compilation_level=ADVANCED_OPTIMIZATIONS flag, but the result of using Angular with these advanced optimizations were mixed.

In TypeScript 3.9 a change (microsoft/TypeScript#32011) was introduced that broke Closure Compiler support with this flag, and as a result of this we removed the remains of the Closure Compiler support from Angular via #37221.

This change affected only the ecosystem outside of Google, and had no effect on the usage of Angular with Closure Compiler inside of Google where we had more flexibility to work around the issue introduced by TypeScript 3.9. You can check out microsoft/TypeScript#38374 for one potential solution.

There is still a lot of value in bringing Closure Compiler support back to Angular in the non-Google ecosystem, but it’s unclear how much interest is there for this feature. We also don’t know, who if anyone, successfully used Closure Compiler with advanced optimizations and Angular outside of Google prior to Angular v10.0.

This issue is here to collect feedback from any existing developers that used Closure Compiler with Angular prior to Angular v10.0, as well as any developers not currently using Closure Compiler but interested in us supporting it.

If you are interesting in Angular supporting Closure Compiler with advanced optimizations, please share with us the following info via a comment on this issue:

  • Do you have prior successful experience with using Closure Compiler and --compilation_level=ADVANCED_OPTIMIZATIONS?
  • Does this experience come from projects outside of Google’s internal monorepo?
  • Why do you need this level of optimizations?
  • Do you currently use Angular CLI?
  • If you don’t use Angular CLI, what do you use to build your application?
  • Do you use any other npm libraries that are compiled with your application and end up in your application build artifacts? Please list them. (e.g. @angular/material, @ng-bootstrap/ng-bootstrap, @ngrx/*, etc)
  • What is our bundle size? (in KB before compression)
  • Do you use lazy loading / code splitting in your application?
  • What version of Angular you are currently on?
  • Any other input for us to consider?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:24
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
IgorMinarcommented, May 22, 2020

@DavidANeil thanks for the info! this is awesome! I’m quite confident that we’ll find some solution for you as long as we work together on this and we understand your requirements and constraints.

Angular must remain Closure compatible at its core because that’s how it’s used at Google. However I think that the npm packages themselves should not optimize for Closure consumption because 99.999% of our users don’t use Closure Compiler.

Besides consuming Angular from sources, another alternative is for us to deploy closure compatible packages into a private npm repo, or a git repo, similar how we already deploy pre-release build snapshots at https://github.com/angular/core-builds.

I see that we have a meeting scheduled for next week, so let’s chat about all the options. In the meantime, you might want to weigh in on ~microsoft/TypeScript#32011~ microsoft/TypeScript#38374 to let the TS team know that the TS 3.9 emit change affects people outside of Google as well.

1reaction
dunxencommented, Dec 23, 2020

I was actually investigating using Closure’s advanced optimizations for all the projects in our fairly large Angular codebase prior to upgrading to Angular 10. So was sad to see the support dropped, but understand it comes from TypeScript. Would love to see support again to continue on with our investigation! 🙂

  • Do you have prior successful experience with using Closure Compiler and --compilation_level=ADVANCED_OPTIMIZATIONS?

Only in the experimental phase with one application. We never shipped this.

  • Does this experience come from projects outside of Google’s internal monorepo?

Yes

  • Why do you need this level of optimizations?

Some of our applications are compute intensive & we do end up fighting first party code size. So we are looking for joint ways to improve overall efficiency and size, web workers and Closure compiler being some.

  • Do you currently use Angular CLI?

Yes

  • Do you use any other npm libraries that are compiled with your application and end up in your application build artifacts? Please list them. (e.g. @angular/material, @ng-bootstrap/ng-bootstrap, @ngrx/*, etc)
  • What is our bundle size? (in KB before compression)

4 300 KB - 8 000 KB uncompressed (range between our different applications).

  • Do you use lazy loading / code splitting in your application?

Yes

  • What version of Angular you are currently on?

10

Read more comments on GitHub >

github_iconTop Results From Across the Web

Closure Compiler Compilation Levels - Google Developers
The Closure Compiler lets you choose from three levels of compilation, ranging from simple removal of whitespace and comments to aggressive code ...
Read more >
Flags and Options · google/closure-compiler Wiki - GitHub
Instructs the compiler to replace dynamic imports expressions with a function call using the specified name. Allows dynamic import expressions ...
Read more >
Closure Compiler Service
Example: http://www.example.com/bigfile.js. Optimization: Whitespace only. Simple Advanced. Which optimization is right for my code? Formatting:
Read more >
How do I force the native version of google-closure-compiler ...
I think I've made some progress on this by looking at what's going on in the cli.js and util.js files inside ...
Read more >
google-closure-compiler
The gulp plugin supports gulp sourcemaps. var closureCompiler = require('google-closure-compiler').gulp ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found