This repository has been archived by the owner on Mar 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Home
Alex Eagle edited this page May 12, 2017
·
1 revision
Closure Compiler is a JavaScript optimizer written and used at Google. We compile most of our Angular apps with it, to produce the smallest JavaScript bundles.
This is part of the "ABC" effort (Angular, Bazel, and Closure). See blog post.
Closure compiler is an advanced tool. We do not recommend using it for most Angular applications, instead please use the Angular CLI.
First, some basic principles:
- Closure compiler is a global program analyzer and optimizer, and is too slow to run in development mode. You should only use it for production builds.
- Optimizers do their best work with code that has not been down-leveled. We pass the highest language that Closure compiler understands (currently ES2015).
- Closure compiler has several compilation levels. In this context, we always want to run with ADVANCED_OPTIMIZATION. Other levels are not an improvement over other tools.
- Code that is bundled by Closure must conform to some extra rules. Right now, developers are responsible for doing this. (We hope to add some static analyses to help with this.)
- Closure compiler bug with files that have no export statements.
https://github.com/google/closure-compiler/issues/2247
This is known to affect files in rxjs. As a workaround, edit the file in
node_modules/rxjs/*.js
and add the lineexports.__CLOSURE_WORKAROUND__ = true;
- Closure compiler requires Java is installed: https://github.com/google/closure-compiler/issues/2412 (Note that the closure-compiler-js version does not work)
- Allow comments in the closure.conf file https://github.com/google/closure-compiler/issues/2413
- Solve closure bug with rxjs files w/o exports https://github.com/google/closure-compiler/issues/2247