概要
Angular 8がリリースされましたね。
Ivy はまだPreview機能での提供になります。
いつも通り、気になった箇所をピックアップして紹介していきます。
Differential Loading by Default
- Modern JS(es2015)、Legacy JS(es5) 向けのビルドを作成して、ブラウザ側で判断してバンドルファイルを取得するようです。
- es2015対応のブラウザではバンドルサイズが7-20%程度削減されます。
Route Configurations use Dynamic Imports
- Route設定のloadChildrenの定義がDynamic importsでの定義に移行しました。
ng updateを使用することで自動的に移行されます。
Removed APIs
以下のAPIが Angular 8 から削除されました。
@angular/httpの全て@angular/http/testingの全て@angular/platform-browserDOCUMENT
@angular/core/testingTestBed.deprecatedOverrideProvider()TestBedStatic.deprecatedOverrideProvider()
基本的には以下のページで移行先のAPIを紹介しています。
@angular/http の廃止は @angular/common/http が提供されてからアナウンスされていたので、やっと廃止されたという印象です。
New Deprecation Guide
- 廃止予定が宣言されてから、メジャーバージョンがN+2までサポート予定になりました。(8で廃止予定になったものは9と10ではサポート)
- https://angular.io/guide/deprecations
- 次のバージョンでは、
<template>とDeprecated*pipesが削除予定です。
@ViewChild ・ @ContentChild の第二引数が必須になった
staticフラグの設定が必須になりました。かなり玄人向けの機能です。{static: true}の場合、ngOnInitから使用可能です。{static: false}の場合、ngAfterViewInitから使用可能です。
TestBed.getの型付推奨
- 文字列トークンではなく、
InjectionTokenをTestBed.getすることが推奨されました。 - https://github.com/angular/angular/blob/8.0.0/CHANGELOG.md#breaking-changes
TypeScriptのバージョンサポート
- TypeScript 3.3以降をサポート
その他軽微なもの
FormArray.clearの追加