mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
The manual replacement logic had a flaw and was inserting the imports several times.
For example:
```ts
import { APP_INITIALIZER, ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
import { InitService } from './init.service';
export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }),
{
provide: APP_INITIALIZER,
useFactory: (initService: InitService) => initService.init(),
deps: [InitService],
multi: true
},
{
provide: APP_INITIALIZER,
useFactory: (initService: InitService) => initService.init(),
deps: [InitService],
multi: true
}
]
};
```
produced:
```ts
import { ApplicationConfig, provideZoneChangeDetection, inject, provideAppInitializer }{ ApplicationConfig, provideZoneChangeDetection, inject, provideAppInitializer } from '@angular/core';
import { InitService } from './init.service';
export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }),
provideAppInitializer(() => { return ((initService: InitService) => initService.init())(inject(InitService)); }),
provideAppInitializer(() => { return ((initService: InitService) => initService.init())(inject(InitService)); })
]
};
```
It now produces proper imports:
```ts
import { ApplicationConfig, provideZoneChangeDetection, inject, provideAppInitializer } from '@angular/core';
```
PR Close #58456
20 lines
851 B
JSON
20 lines
851 B
JSON
{
|
|
"schematics": {
|
|
"explicit-standalone-flag": {
|
|
"version": "19.0.0",
|
|
"description": "Updates non-standalone Directives, Component and Pipes to 'standalone:false' and removes 'standalone:true' from those who are standalone",
|
|
"factory": "./bundles/explicit-standalone-flag#migrate"
|
|
},
|
|
"pending-tasks": {
|
|
"version": "19.0.0",
|
|
"description": "Updates ExperimentalPendingTasks to PendingTasks",
|
|
"factory": "./bundles/pending-tasks#migrate"
|
|
},
|
|
"provide-initializer": {
|
|
"version": "19.0.0",
|
|
"description": "Replaces `APP_INITIALIZER`, `ENVIRONMENT_INITIALIZER` & `PLATFORM_INITIALIZER` respectively with `provideAppInitializer`, `provideEnvironmentInitializer` & `providePlatformInitializer`.",
|
|
"factory": "./bundles/provide-initializer#migrate",
|
|
"optional": true
|
|
}
|
|
}
|
|
}
|