As we all of us know that Google has just released its new version of Angular i.e. 9.0 just a week ago. Angular developers and the community members eagerly wait for the release of this version for a long time. Because, as announced by Google at the time of Angular 8 release, Angular 9 will be released with the features of the IVY renderer engine. So, the expectation is actually is very high for the IVY. Angular 9 is the first major release from Google in the year 2020 which is mainly focused on the toolchain and also making angular easier for the user to create different types of applications along with performance improvements. Except for this, this major version release also contains some new features and upgradation in respect of the previous versions including framework, Angular Material, Angular CLI, etc. Also, Angular 9 supports the typescript version 3.7. So with the help of a new typescript version, it is very much easy to code with faster subsequent build with the incremental flag, type checking for global this and generic type arguments.
New Features of Angular 9
TypeScript 3.7.x Support
Ivy Rendering Engine
- Ivy compiler and runtime offer many benefits over the previous compiler engine i.e. View Engine –
- It will provide a faster compilation.
- It will provide a smaller bundle size.
- With the help of Ivy, we can perform much faster testing operations.
- Provides improved CSS and style bindings
- Much more improved type checking in templates so that we can catch more errors at the build time and prevent the user to face those errors at runtime.
- Smaller bundle size compared to the current compiled bundled size.
- Also, the code generated by the Angular compiler is now much easier human to read and understand.
- The last but most favorite feature of me is that we can debug the templates.
- It provides improved build time and enables AOT mode for building by default.
- {
- "extends": "./tsconfig.json",
- "compilerOptions": {
- "outDir": "./out-tsc/app",
- "types": []
- },
- "files": [
- "src/main.ts",
- "src/polyfills.ts"
- ],
- "include": [
- "src/**/*.d.ts"
- ],
- "angularCompilerOptions": {
- "enableIvy": false
- }
- }
Smaller Bundle Size
- The small application which does not use many Angular features can be benefited mostly from the tree-shaking structure.
- The Large application with a large number of components can also be benefitted from the reduced factory size.
Angular Core Type-Safe Changes
- TestBed.get(ChangeDetectorRef) // any
- TestBed.inject(ChangeDetectorRef) // ChangeDetectorRef
Modules with Providers Support
- @NgModule({ ...})
- export class MyModule { static forRoot(config: SomeConfig): ModuleWithProviders {
- return {
- ngModule: SomeModule,
- providers: [{ provide: SomeConfig, useValue: config }]
- };
- }
- }
- @NgModule({ ...})
- export class MyModule {
- static forRoot(config: SomeConfig): ModuleWithProviders<**SomeModule**>
- {
- return {
- ngModule: SomeModule,
- providers: [{ provide: SomeConfig, useValue: config }]
- };
- }
- }
Changes in Angular Forms
Dependency Injection Changes in Core
- platform – Mentioning providedIn: ‘platform’ option makes the service available in a special singleton platform injector which will be shared by all applications on the page.
- any - Mentioning providedIn: ‘any’ option provides a unique instance in every module (including lazy modules) that injects the token.
i18n Improvements
Need for Faster Mobile Apps
Service Worker Updates
- "assetGroups": [
- {
- "name": "test",
- "resources": {
- "versionedFiles": [
- "/**/*.txt"
- ]
- }
- }
- ]
- "assetGroups": [
- {
- "name": "test",
- "resources": {
- "files": [
- "/**/*.txt"
- ]
- }
- }
- ]
How to Upgrade in Angular 9
- Angular 9 use TypeScript 3.7 so install TypeScript 3.7
- You need to use Node 12 or Later
- Now execute the upgrade command of Angular CLI -> ng update @angular/cli @angular/core
- ng update @angular/cli@8 @angular/core@8
- ng update @angular/cli @angular/core
- ng version
Angular Material now includes a new date range picker.
To use the new date range picker, you can use the mat-date-range-input
and mat-date-range-picker
components.
See this example on StackBlitz.
Learn more about date range selection.
Warnings about CommonJS imports
When you use a dependency that is packaged with CommonJS, it can result in larger slower applications.
Starting with version 10, we now warn you when your build pulls in one of these bundles. If you’ve started seeing these warnings for your dependencies, let your dependency know that you’d prefer an ECMAScript module (ESM) bundle.
Optional Stricter Settings
Version 10 offers a more strict project setup when you create a new workspace with ng new
.
ng new --strict
Enabling this flag initializes your new project with a few new settings that improve maintainability, help you catch bugs ahead of time, and allow the CLI to perform advanced optimizations on your app. Specifically, the strict
flag does the following:
- Enables strict mode in TypeScript
- Turns template type checking to Strict
- Default bundle budgets have been reduced by ~75%
- Configures linting rules to prevent declarations of type
any
- Configures your app as side-effect free to enable more advanced tree-shaking
Keeping Up to Date with the Ecosystem
As usual, we have made a few updates to the dependencies of Angular to stay synchronized with the JavaScript ecosystem.
- TypeScript bumped to TypeScript 3.9
- TSLib has been updated to v2.0
- TSLint has been updated to v6
We’ve also updated our project layout. Starting with version 10 you will see a new tsconfig.base.json
. This additional tsconfig.json
file better supports the way that IDEs and build tooling resolve type and package configurations.
New Default Browser Configuration
We’ve updated the browser configuration for new projects to exclude older and less used browsers.
v9 Defaults
v10 Defaults
This has the side effect of disabling ES5 builds by default for new projects. To enable ES5 builds and differential loading for browsers that require it (such as IE or UC Browser), simply add the browsers you need to support in the .browserslistrc
file.
Angular Team Fixit
We’ve dramatically increased our investment in working with the community. In the last three weeks our open issue count has decreased by over 700 issues across framework, tooling, and components. We’ve touched over 2,000 issues, and we plan to make large investments over the next few months, working with the community to do even more.
Deprecations and Removals
We’ve made several new deprecations and removals from Angular.
The Angular Package Format no longer includes ESM5 or FESM5 bundles, saving you 119MB of download and install time when running yarn
or npm install
for Angular packages and libraries. These formats are no longer needed as any downleveling to support ES5 is done at the end of the build process.
Based on heavy consultation with the community, we are deprecating support for older browsers including IE 9, 10, and Internet Explorer Mobile.
You can read more about our deprecations and removals.
No comments:
Post a Comment