Contact

Angular 5.0 November Release

Introducing ...

Angular 5.0.0, code-named “pentagonal-donut,” was released on November 1, 2017.

Following the semantic versioning policies of the Angular project, the “5” in the version number signals that this is a major release. Angular 5.0 follows in the footsteps of the Angular 4.0 “invisible-makeover” version that was released on March 23, 2017.

Ahead-of-Time Compilation Improvements

Significant improvements to the Angular compiler were introduced within the pentagonal-donut release, as well as many improvements to the compilation performance, especially as it relates to the Ahead-of-Time (AOT) compiler processing options. AOT is often compared and contrasted with Just-in-Time (JIT) compilation, but, as the Angular documentation notes:

“There is actually only one Angular compiler. The difference between AOT and JIT is a matter of timing and tooling. With AOT, the compiler runs once at build time using one set of libraries; with JIT it runs every time for every user at runtime using a different set of libraries.”

AOT can dramatically impact the rendering time for an Angular application because the web browser interacts with a pre-compiled version of the application, rather than having to JIT-compile the application at the time of the request.

However, during development, using AOT often resulted in longer build times. During internal tests of the build time (using the AOT compilation option and the angular.io site source) the Angular 5.0 release blog entry reports a reduction of the total build time from “…more than 40 seconds to less than 2 seconds.”

Compilation as a TypeScript Transform

Commencing with the TypeScript 2.3 release, a public Transformation and Emit API was provided within TypeScript. This TypeScript Transformation and Emit API enables API consumers to alter the Abstract Syntax Tree (AST) before the target source code is emitted.

Angular 5.0.0 has leveraged the TypeScript transforms that the Transformation and Emit API enables to tie into the TypeScript compilation pipeline. In this manner, incremental rebuilds are completed faster.

The Angular CLI (Command Line Interface) “ng serve” command which builds the Angular application and launches a web server now supports an additional flag, “–aot” to trigger an AOT build. The Angular team intends to make this the default compilation option in a future release.

Note that the Angular compiler now requires TypeScript 2.4.x – a breaking change.

Build Optimizer Enabled by Default

The purpose of the Angular CLI build optimizer is to reduce the size of bundles by reducing code size and by removing Angular decorators. Commencing with Angular 5.0, the build optimizer will be enabled by default for production builds generated using the Angular CLI.

To help accomplish the goal of reducing code size, the build optimizer contains transform steps that mark functions as “pure” (without side effects). Then, during the “Tree Shake” portion of the AOT compilation, the application’s dependency graph is walked to determine what parts of the JavaScript code are unused. Thus, if a pure function’s result isn’t used, the function may be safely removed.

In addition, Angular Decorators (implemented using the experimental TypeScript feature) are special functions prefixed with the “@” character that provide information about a class, parameter, or method. Because Decorators are consumed during the compilation process, after compilation, they may be removed to reduce code size.

In Conclusion ...

Angular 5.0.0 is a major release that brings significant enhancements to developer production, compilation performance, and application bootstrapping performance.

For more information please refer to the following resources:

 

TechArk is here to keep you up-to-date on the latest advancements in technology, including updates to the Angular application.