Skip to content

Use Closure Compiler with offline template compiler #8550

@alexeagle

Description

@alexeagle

Angular's new offline compiler was demo'ed at ng-conf day 2 keynote by @robwormald. It generates tree-shakable ES6 code. Four steps are then required:

  • run a tree-shaker to remove ES6 modules not reachable from the entry point, in our demo we showed rollup
  • run a bundler to reduce down the module imports into a declarations in a single file; we showed system.js
  • down-level to ES5 - we showed this with TypeScript
  • minify to shorten symbol names, we used uglify.

This produced a 49k JS file, but requires a lot of configuration.

Google's Closure Compiler (https://developers.google.com/closure/compiler/) produces very small JS. It does all four steps required above, so the configuration should be a lot simpler. We also suspect we can get a smaller binary size for ng2-hello-world, around 36k.

Wiring this up requires:

  • add tsickle's closure annotation helper to `ngc
  • modify Angular's ES6 distribution to be closure-compiler compatible
  • ?? modify ES6 distro of our dependencies (rxjs, zone.js) to be closure-compiler compatible
  • figure out a minimal build (maybe a shell script) that successfully compiles the application together with the framework and its dependencies
  • document how we did it so others can repro
  • bundle externs with Angular to allow Protractor testing (the BrowserNodeGlobal type)

Metadata

Metadata

Assignees

Labels

area: packagingIssues related to Angular's creation of npm packagesfeatureLabel used to distinguish feature request from other issuesfreq2: medium

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions