Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Accelerating Angular Development with Ivy

You're reading from   Accelerating Angular Development with Ivy A practical guide to building faster and more testable Angular apps with the new Ivy engine

Arrow left icon
Product type Paperback
Published in Oct 2021
Publisher Packt
ISBN-13 9781800205215
Length 242 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
Lars Gyrup Brink Nielsen Lars Gyrup Brink Nielsen
Author Profile Icon Lars Gyrup Brink Nielsen
Lars Gyrup Brink Nielsen
Jacob Andresen Jacob Andresen
Author Profile Icon Jacob Andresen
Jacob Andresen
Mateus Carniatto Mateus Carniatto
Author Profile Icon Mateus Carniatto
Mateus Carniatto
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Chapter 1: Discovering New APIs and Language Syntax 2. Chapter 2: Boosting Developer Productivity Through Tooling, Configuration, and Convenience FREE CHAPTER 3. Chapter 3: Introducing CSS Custom Properties and New Provider Scopes 4. Chapter 4: Exploring Angular Components Features 5. Chapter 5: Using CSS Custom Properties 6. Chapter 6: Using Angular Components 7. Chapter 7: Component Harnesses 8. Chapter 8: Additional Provider Scopes 9. Chapter 9: Debugging with the New Ivy Runtime APIs 10. Chapter 10: Using the Angular Compatibility Compiler 11. Chapter 11: Migrating Your Angular Application from View Engine to Ivy 12. Chapter 12: Embracing Ahead-of-Time Compilation 13. Other Books You May Enjoy

What this book covers

Chapter 1, Discovering New APIs and Language Syntax, first dives into three important additions to TypeScript in versions supported by Angular Ivy. The optional chaining and nullish coalescing operators are discussed and shown in a business context separately. Perhaps more importantly, their powerful combination is demonstrated.

This chapter goes on to optimize regional support through Angular Ivy's improved globalization APIs, briefly discussing how to configure the Angular CLI to bundle locale data and translation files. Together, we implement a bi-directional media directive for art direction and combine it with a locale picker that lazily loads any locale supported by Angular. This is a testament to the power of combining Angular with browser APIs.

Testability is an important concern for Angular. This chapter is where we uncover how Angular's TestBed.inject method adds stronger typing to tests by exploring its API and a simple example. Additionally, we use an example to learn about Angular Material's FakeMatIconRegistry stub service and how it is provided in an Angular testing module.

Chapter 2, Boosting Developer Productivity Through Tooling, Configuration, and Convenience, discusses Angular Ivy's style binding precedence rules and how they make style evaluation predictable. An elaborate example lets us explore these rules.

This chapter discusses which metadata can be shared through directive and component inheritance. This is covered through examples that demonstrate realistic use cases.

The Angular Ahead-of-Time compiler and the Angular Compatibility Compiler are introduced as an integral part of Angular Ivy, affecting all phases of development.

This chapter also discusses Angular Ivy's Strict mode and related compiler options. We also cover TypeScript's error-expecting compiler annotations, which are useful for unit tests.

Finally, Angular Ivy's improved compilation errors are demonstrated and compared to those of Angular View Engine. Additionally, we discuss tooltips added to the Angular Language Service by Ivy.

Chapter 3, Introducing CSS Custom Properties and New Provider Scopes, introduces CSS Custom Properties and their scoping before demonstrating novel techniques for interacting with CSS Custom Properties through Angular data binding.

Angular Ivy introduces the any and platform provider scopes. Both new provider scopes have limited but important and advanced use cases. Each of them is discussed in detail and example dependency hierarchies are visualized to facilitate understanding. To understand an important use case of the any provider scope, a web API configuration example is covered step by step. The platform provider scope is useful for Angular Elements web components and Angular microfrontends. A partial microfrontend is introduced to demonstrate how dependency injection works when using the platform provider scope.

Chapter 4, Exploring Angular Components Features, covers novel APIs and packages introduced by Ivy to Angular's UI packages owned by the Angular Components team. Through extensive API references and basic examples, you will learn about the Angular YouTube Player and the most common parts of the Angular Google Maps components package. The Clipboard API is added to Angular CDK by Ivy. We discuss the directive, service, and class it contains.

Finally, Angular's new test-as-a-user API, known as component harnesses, is explored. The basic concepts harness environments, harness loaders, and component harnesses are introduced. We walk through the Angular Material Button component harness API before using it in practice for an example component that also relies on the Angular Material Select component harness.

Chapter 5, Using CSS Custom Properties, introduces the Angular Academy app and shows how to create a theme component that can control the look and feel of the app using CSS Custom Properties. Furthermore, the chapter discusses how to use CSS Custom Properties for a flexible grid layout.

Chapter 6, Using Angular Components, walks through how the Angular Academy app is structured and shows how to implement and use the new Angular components in a modular fashion.

Chapter 7, Component Harnesses, further dives into the details of the Angular testing harnesses and how to apply the Material testing harnesses in the context of the Angular Academy app. A custom Video Test harness is introduced to illustrate how to approach layered testing in the context of the Angular Academy app.

Chapter 8, Additional Provider Scopes, illustrates how to use the any provider scope to implement a configurable ThemeService in the context of the Angular Academy app. Additionally, we show how to share information across applications using the platform provider scope.

Chapter 9, Debugging with the New Ivy Runtime APIs, first describes Angular Ivy's debugging API in full. However, it is the most widely applicable debugging utility functions, ng.applyChanges, ng.getComponent, ng.getContext, and ng.getListeners, that are covered in detail by debugging a component and its related directive. This will teach you how to inspect an active component as well as its event listeners and embedded view context. These are important techniques to master when developing Angular applications.

Chapter 10, Using the Angular Compatibility Compiler, introduces the Angular Compatibility Compiler and discusses its role as a temporary part of Angular Ivy throughout the Angular View Engine to Ivy transition period. Significant parameters for its CLI are described before recommendations are made to optimize the compiler for local development.

This chapter further discusses Angular Compatibility Compiler optimization techniques for CI/CD workflows and monorepo workspaces as a result of extensive research, experiments, and measurements.

Chapter 11, Migrating Your Angular Application from View Engine to Ivy, is a unique and extensive migration guide for Angular Ivy. First, we discuss the phases and tools used in the Angular update process and how to manage Angular dependencies. Next, we discuss how to perform automated Angular Ivy migrations and how to review the most significant during or after Ivy migration. Additionally, an optional but recommended migration is described.

This chapter recommends manual Ivy migrations to future-proof your Angular application. These migrations are related to navigation, change detection, and unit tests.

Chapter 12, Embracing Ahead-of-Time Compilation, focuses on the Ahead-of-Time Angular compiler. We discuss its impact on all phases of developing your Angular application before introducing techniques for dealing with concrete limitations and edge cases of Ahead-of-Time compilation.

This chapter contains a unique section that introduces two techniques for initializing asynchronous dependencies. We use feature flags as a case study for this.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime