feat(compiler): mark @NgModules in provider lists for identification at runtime (#22005)

All of the providers in a module get compiled into a module definition in the
factory file. Some of these providers are for the actual module types, as those
are available for injection in Angular. For tree-shakeable tokens, the runtime
needs to be able to distinguish which modules are present in an injector.

This change adds a NodeFlag which tags those module providers for later
identification.

PR Close #22005
This commit is contained in:
Alex Rickabaugh
2018-02-02 09:31:58 -08:00
committed by Miško Hevery
parent 647b8595d0
commit 2d5e7d1b52
7 changed files with 28 additions and 10 deletions

View File

@ -29,6 +29,9 @@ export function providerDef(ctx: OutputContext, providerAst: ProviderAst): {
if (providerAst.providerType === ProviderAstType.PrivateService) {
flags |= NodeFlags.PrivateProvider;
}
if (providerAst.isModule) {
flags |= NodeFlags.TypeModuleProvider;
}
providerAst.lifecycleHooks.forEach((lifecycleHook) => {
// for regular providers, we only support ngOnDestroy
if (lifecycleHook === LifecycleHooks.OnDestroy ||