angular/packages/core/schematics/migrations/provide-initializer
Paul Gschwendtner 185b7801ee build: migrate packages/core/schematics to ts_project (#61420)
Migrates `packages/core/schematics` to `ts_project`. As part of this,
this commit cleans up some of the mixed module types and tsconfigs in
the folder. A single tsconfig (and it's test variant) are now used.

For the shipped schematics, we explicitly use the `.cjs` extension, so
that the bundles are properly recognized as CommonJS; even if they are
part of the `type: module` `@angular/core` package.

The `package.json` with `type: commonjs` is removed from
`packages/core/schematics` as it's no longer needed given the explicit
extension & caused issues as schematics are compiled with ESM but are
only later bundled for shipping & some tests as ESM.

PR Close #61420
2025-05-16 15:53:27 +00:00
..
BUILD.bazel build: migrate packages/core/schematics to ts_project (#61420) 2025-05-16 15:53:27 +00:00
index.ts feat(core): add syntactic sugar for initializers (#53152) 2024-10-22 09:38:18 -07:00
README.md feat(core): add syntactic sugar for initializers (#53152) 2024-10-22 09:38:18 -07:00
utils.ts docs: update license URL from angular.io to angular.dev and year of license to 2025 (#59407) 2025-01-09 10:27:54 -05:00

Replace APP_INITIALIZER, ENVIRONMENT_INITIALIZER, and PLATFORM_INITIALIZER with provider functions

Replaces APP_INITIALIZER, ENVIRONMENT_INITIALIZER, and PLATFORM_INITIALIZER with their respective provider functions: provideAppInitializer, provideEnvironmentInitializer, and providePlatformInitializer.

Before

import {APP_INITIALIZER} from '@angular/core';

const providers = [
  {
    provide: APP_INITIALIZER,
    useValue: () => { console.log('hello'); },
    multi: true,
  }
];

After

import {provideAppInitializer} from '@angular/core';

const providers = [provideAppInitializer(() => { console.log('hello'); })];