feat(ivy): @NgModule -> ngInjectorDef compilation (#22458)
This adds compilation of @NgModule providers and imports into ngInjectorDef statements in generated code. All @NgModule annotations will be compiled and the @NgModule decorators removed from the resultant js output. All @Injectables will also be compiled in Ivy mode, and the decorator removed. PR Close #22458
This commit is contained in:

committed by
Miško Hevery

parent
688096b7a3
commit
6ef9f2278f
@ -8,7 +8,7 @@
|
||||
|
||||
import {Type} from '../type';
|
||||
|
||||
import {InjectableDef, defineInjectable} from './injectable';
|
||||
import {InjectableDef, defineInjectable} from './defs';
|
||||
|
||||
/**
|
||||
* Creates a token that can be used in a DI Provider.
|
||||
@ -26,8 +26,24 @@ import {InjectableDef, defineInjectable} from './injectable';
|
||||
* // myInterface is inferred to be MyInterface.
|
||||
* ```
|
||||
*
|
||||
* When creating an `InjectionToken`, you can optionally specify a factory function which returns
|
||||
* (possibly by creating) a default value of the parameterized type `T`. This sets up the
|
||||
* `InjectionToken` using this factory as a provider as if it was defined explicitly in the
|
||||
* application's root injector. If the factory function, which takes zero arguments, needs to inject
|
||||
* dependencies, it can do so using the `inject` function. See below for an example.
|
||||
*
|
||||
* Additionally, if a `factory` is specified you can also specify the `providedIn` option, which
|
||||
* overrides the above behavior and marks the token as belonging to a particular `@NgModule`. As
|
||||
* mentioned above, `'root'` is the default value for `providedIn`.
|
||||
*
|
||||
* ### Example
|
||||
*
|
||||
* #### Tree-shakeable InjectionToken
|
||||
*
|
||||
* {@example core/di/ts/injector_spec.ts region='ShakeableInjectionToken'}
|
||||
*
|
||||
* #### Plain InjectionToken
|
||||
*
|
||||
* {@example core/di/ts/injector_spec.ts region='InjectionToken'}
|
||||
*
|
||||
* @stable
|
||||
@ -54,3 +70,7 @@ export class InjectionToken<T> {
|
||||
|
||||
toString(): string { return `InjectionToken ${this._desc}`; }
|
||||
}
|
||||
|
||||
export interface InjectableDefToken<T> extends InjectionToken<T> {
|
||||
ngInjectableDef: InjectableDef<T>;
|
||||
}
|
||||
|
Reference in New Issue
Block a user