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
@ -12,9 +12,9 @@ import {assertArrayOfStrings, assertInterpolationSymbols} from './assertions';
|
||||
import * as cpl from './compile_metadata';
|
||||
import {CompileReflector} from './compile_reflector';
|
||||
import {CompilerConfig} from './config';
|
||||
import {ChangeDetectionStrategy, Component, Directive, Injectable, ModuleWithProviders, Provider, Query, SchemaMetadata, Type, ViewEncapsulation, createAttribute, createComponent, createHost, createInject, createInjectable, createInjectionToken, createOptional, createSelf, createSkipSelf} from './core';
|
||||
import {ChangeDetectionStrategy, Component, Directive, Injectable, ModuleWithProviders, Provider, Query, SchemaMetadata, Type, ViewEncapsulation, createAttribute, createComponent, createHost, createInject, createInjectable, createInjectionToken, createNgModule, createOptional, createSelf, createSkipSelf} from './core';
|
||||
import {DirectiveNormalizer} from './directive_normalizer';
|
||||
import {DirectiveResolver} from './directive_resolver';
|
||||
import {DirectiveResolver, findLast} from './directive_resolver';
|
||||
import {Identifiers} from './identifiers';
|
||||
import {getAllLifecycleHooks} from './lifecycle_reflector';
|
||||
import {HtmlParser} from './ml_parser/html_parser';
|
||||
@ -44,6 +44,7 @@ export class CompileMetadataResolver {
|
||||
private _pipeCache = new Map<Type, cpl.CompilePipeMetadata>();
|
||||
private _ngModuleCache = new Map<Type, cpl.CompileNgModuleMetadata>();
|
||||
private _ngModuleOfTypes = new Map<Type, Type>();
|
||||
private _shallowModuleCache = new Map<Type, cpl.CompileShallowModuleMetadata>();
|
||||
|
||||
constructor(
|
||||
private _config: CompilerConfig, private _htmlParser: HtmlParser,
|
||||
@ -477,6 +478,26 @@ export class CompileMetadataResolver {
|
||||
return Promise.all(loading);
|
||||
}
|
||||
|
||||
getShallowModuleMetadata(moduleType: any): cpl.CompileShallowModuleMetadata|null {
|
||||
let compileMeta = this._shallowModuleCache.get(moduleType);
|
||||
if (compileMeta) {
|
||||
return compileMeta;
|
||||
}
|
||||
|
||||
const ngModuleMeta =
|
||||
findLast(this._reflector.shallowAnnotations(moduleType), createNgModule.isTypeOf);
|
||||
|
||||
compileMeta = {
|
||||
type: this._getTypeMetadata(moduleType),
|
||||
rawExports: ngModuleMeta.exports,
|
||||
rawImports: ngModuleMeta.imports,
|
||||
rawProviders: ngModuleMeta.providers,
|
||||
};
|
||||
|
||||
this._shallowModuleCache.set(moduleType, compileMeta);
|
||||
return compileMeta;
|
||||
}
|
||||
|
||||
getNgModuleMetadata(
|
||||
moduleType: any, throwIfNotFound = true,
|
||||
alreadyCollecting: Set<any>|null = null): cpl.CompileNgModuleMetadata|null {
|
||||
|
Reference in New Issue
Block a user