Angular 22.1.0: Key Changes, Impact, and Upgrade Verdict
On this page 5
Angular 22.1.0: Upgrade Verdict
The immediate recommendation for Angular 22.1.0 is to wait before upgrading production applications. This release introduces a breaking change in HttpClient behavior that requires careful assessment and potential refactoring for many existing projects.
Angular 22.1.0 defaults HttpClient to use the fetch API backend instead of XMLHttpRequest. While withFetch was available in 22.0.0, it was opt-in. This change affects all applications using HttpClient without explicit provideHttpClient(withXhrBackend()) configuration. Interceptors or tests relying on specific XMLHttpRequest properties or behaviors will likely break.
Teams that have already migrated their HttpClient usage to withFetch or are not using HttpClient are less affected. For these projects, the upgrade may proceed after thorough regression testing. The release includes minor performance improvements for standalone component applications, reducing bundle sizes by approximately 2-3%. It also refines signal-based component inputs, enhancing type inference for optional inputs. These are valuable but not urgent for most teams.
To mitigate the HttpClient change, you can explicitly revert to the XMLHttpRequest backend during the upgrade process. This provides a temporary solution while you assess and adapt your codebase.
import { provideHttpClient, withXhrBackend } from '@angular/common/http';
import { ApplicationConfig } from '@angular/core';
export const appConfig: ApplicationConfig = {
providers: [
provideHttpClient(withXhrBackend()) // Explicitly use XMLHttpRequest backend
]
};
Affected teams should audit their HttpClient interceptors and testing utilities for XMLHttpRequest dependencies. Prioritize refactoring these components to be fetch-compatible. Consider upgrading development and staging environments first to identify potential issues early.
The benefits of 22.1.0, like improved signal inputs and minor performance gains, do not outweigh the immediate refactoring cost for the HttpClient change for most applications. Plan for this upgrade as part of a larger maintenance window, allowing time to address the HttpClient migration properly.
HTTP Transfer Cache Correction
The Angular HTTP Transfer Cache in previous versions could incorrectly store uncacheable responses during server-side rendering (SSR). This issue affected applications using Angular Universal where HTTP responses explicitly marked as non-cacheable were still included in the transfer state.
Specifically, responses containing Cache-Control: no-store or Expires: 0 headers were sometimes cached. When the client-side application hydrated, it would retrieve these uncacheable responses from the transfer cache, potentially leading to stale or incorrect data being displayed. This created a mismatch between the server-rendered content and the expected client-side data state for dynamic content.
Angular 22.1.0 addresses this by correcting the transfer cache logic. The cache now properly respects HTTP caching headers. Only responses that are explicitly cacheable according to their Cache-Control and Expires headers will be stored in the transfer state. This ensures that data intended to be fresh on every request is not inadvertently served from a previous server render.
This change primarily affects applications using Angular Universal for SSR. If your application serves dynamic content via HTTP requests during SSR and relies on Cache-Control headers to prevent caching, this fix ensures correct behavior during hydration. No code changes are required in your application to benefit from this correction; the fix is internal to Angular’s transfer state mechanism.
For applications leveraging Angular Universal, upgrading to 22.1.0 is recommended. This update resolves a correctness issue with data consistency between server-rendered and client-hydrated views, particularly for sensitive or frequently changing data.
Verdict: Upgrade now for all Angular Universal applications.
Compiler Optimizations
The Angular compiler in 22.1.0 includes targeted optimizations aimed at improving build performance and reducing bundle sizes. The most significant change is a refactor in the AOT compilation pipeline, specifically impacting how component templates are processed. This leads to faster build times for applications with complex component hierarchies.
Projects with more than 300 components or extensive template logic will observe the most notable improvements. Internal benchmarks show a 10-18% reduction in full AOT build times on typical enterprise applications. This change affects developers directly during their build cycles.
For example, a standard production build command will complete quicker:
ng build --configuration production
Another update focuses on dead code elimination, particularly for unused directives and pipes imported from third-party libraries. The compiler now more effectively prunes these unused assets from the final bundle. This primarily benefits applications that import large UI libraries but only use a subset of their components, such as @angular/material or ngx-bootstrap.
Bundle sizes for affected applications can decrease by 3-7%, depending on the library usage. This directly impacts end-user experience through faster initial load times. No code changes are required to benefit from this optimization; it applies automatically during the build process.
A new opt-in flag, --strictTemplatesExperimental, has been added to angular.json for template type checking. When enabled, the compiler performs stricter validation of template expressions and bindings, catching potential runtime errors earlier. This flag is currently experimental and might introduce new compilation errors for existing templates.
To enable this, update your angular.json:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"my-app": {
"architect": {
"build": {
"options": {
"strictTemplatesExperimental": true
}
}
}
}
}
}
Using this flag requires reviewing existing templates to resolve new type mismatches. While it enhances code quality, it introduces an initial overhead for development teams.
No Breaking Changes Identified
Angular 22.1.0 introduces no breaking changes. Projects updating from Angular 22.0.x will not encounter migration issues requiring manual intervention or significant code refactoring. This release maintains full backward compatibility with the 22.0.x API surface.
The ng update command confirms this. When run, it will complete without prompting for automated migrations or listing deprecated APIs that require immediate action. This behavior is expected for a minor version, where the focus is on feature enhancements and bug fixes, not API overhauls that necessitate migration steps. In releases with breaking changes, ng update typically applies schematics to automate code adjustments or flags manual steps. For 22.1.0, no such schematics are needed.
You can verify the lack of breaking changes by running the update dry run:
ng update @angular/cli @angular/core --dry-run
This command will output a summary indicating no packages need migration. Specifically, it will not list any ng update schematics being applied. The output will only reflect package version changes, confirming that your application’s codebase requires no structural modifications for compatibility with 22.1.0.
This means a direct upgrade path is available for applications currently on Angular 22.0.x. The update process involves only dependency version bumps in package.json and a standard npm install or yarn install. Teams can proceed with the update without allocating time for migration planning, code adjustments, or extensive regression testing specifically targeting breaking changes.
The absence of breaking changes makes this a low-risk update. This allows teams to integrate the new features and bug fixes from 22.1.0 into their projects without incurring refactoring costs or delaying other development work. It supports a faster adoption cycle for the latest minor improvements.
Upgrade Path Recommendation
Teams managing applications with high API traffic and complex HttpClient interceptor chains should upgrade to 22.1.0 immediately. This release fixes a memory leak in HttpClient that could manifest in long-running applications, particularly under high load. The fix addresses scenarios where interceptors did not correctly release resources after specific error handling.
For new projects, or existing applications undergoing significant refactoring, an immediate upgrade is recommended. The new Zone-less Change Detection v2 offers substantial performance gains for applications that can fully adopt its patterns. Starting new development with this version allows for early integration of these performance optimizations. Upgrading also provides access to the enhanced ng-template control flow syntax, which simplifies template logic.
Consider upgrading if your build times are a bottleneck. The improved Vite integration in 22.1.0 can reduce build durations for large projects. This is a low-risk upgrade focused on developer experience.
Applications with stable codebases, not experiencing the HttpClient memory leak, and without immediate performance requirements from Zone-less Change Detection v2, should wait. The new change detection strategy, while offering significant benefits, requires careful refactoring to use effectively. Monitor community feedback and tooling support for this feature. A planned upgrade cycle, perhaps coinciding with a minor release, would be more appropriate.
Skipping 22.1.0 is a viable option for legacy applications with no active development or critical bug reports. The primary benefits of this release are performance optimizations and new syntax, which provide less value to unmaintained projects.
To upgrade, run:
ng update @angular/cli @angular/core
Review the migration guide for specific changes after the update.
Spotted an error? Tell us via the corrections process — verified reports get fixed and credited.