2016-06-23 09:47:54 -07:00
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
2016-07-04 09:37:30 -07:00
import { AppModuleFactory , AppModuleMetadata , Compiler , ComponentFactory , ComponentResolver , ComponentStillLoadingError , Injectable , Injector , OptionalMetadata , Provider , SkipSelfMetadata } from '@angular/core' ;
2016-07-08 13:40:54 -07:00
import { Console } from '../core_private' ;
2016-04-28 17:50:03 -07:00
import { BaseException } from '../src/facade/exceptions' ;
2016-06-24 08:46:43 -07:00
import { ConcreteType , IS_DART , Type , isBlank , isString , stringify } from '../src/facade/lang' ;
2016-06-08 16:38:52 -07:00
import { ListWrapper ,} from '../src/facade/collection' ;
2016-04-28 17:50:03 -07:00
import { PromiseWrapper } from '../src/facade/async' ;
2016-06-08 16:38:52 -07:00
import { createHostComponentMeta , CompileDirectiveMetadata , CompilePipeMetadata , CompileIdentifierMetadata } from './compile_metadata' ;
import { TemplateAst ,} from './template_ast' ;
2016-06-24 08:46:43 -07:00
import { StyleCompiler , StylesCompileDependency , CompiledStylesheet } from './style_compiler' ;
import { ViewCompiler , ViewCompileResult , ViewFactoryDependency , ComponentFactoryDependency } from './view_compiler/view_compiler' ;
2016-06-28 09:54:42 -07:00
import { AppModuleCompiler } from './app_module_compiler' ;
2016-01-06 14:13:44 -08:00
import { TemplateParser } from './template_parser' ;
2016-06-28 09:54:42 -07:00
import { DirectiveNormalizer } from './directive_normalizer' ;
2016-02-18 10:53:21 -08:00
import { CompileMetadataResolver } from './metadata_resolver' ;
2016-01-06 14:13:44 -08:00
import { CompilerConfig } from './config' ;
import * as ir from './output/output_ast' ;
import { jitStatements } from './output/output_jit' ;
import { interpretStatements } from './output/output_interpreter' ;
2016-06-28 09:54:42 -07:00
import { SyncAsyncResult } from './util' ;
2016-01-06 14:13:44 -08:00
/**
* An internal module of the Angular compiler that begins with component types,
* extracts templates, and eventually produces a compiled version of the component
* ready for linking into an application.
2016-06-28 11:01:35 -07:00
*
* @security When compiling templates at runtime, you must ensure that the entire template comes
* from a trusted source. Attacker-controlled data introduced by a template could expose your
* application to XSS risks. For more detail, see the [Security Guide](http://g.co/ng/security).
2016-01-06 14:13:44 -08:00
*/
2015-10-01 10:07:49 -07:00
@Injectable ()
2016-06-24 08:46:43 -07:00
export class RuntimeCompiler implements ComponentResolver , Compiler {
2016-06-28 09:54:42 -07:00
private _compiledTemplateCache = new Map < Type , CompiledTemplate >();
private _compiledHostTemplateCache = new Map < Type , CompiledTemplate >();
private _compiledAppModuleCache = new Map < Type , AppModuleFactory < any >>();
2016-01-06 14:13:44 -08:00
2016-07-08 13:40:54 -07:00
private _warnOnComponentResolver = true ;
2016-06-08 16:38:52 -07:00
constructor (
2016-07-04 09:37:30 -07:00
private _injector : Injector , private _metadataResolver : CompileMetadataResolver ,
2016-06-08 16:38:52 -07:00
private _templateNormalizer : DirectiveNormalizer , private _templateParser : TemplateParser ,
2016-06-24 08:46:43 -07:00
private _styleCompiler : StyleCompiler , private _viewCompiler : ViewCompiler ,
2016-07-08 13:40:54 -07:00
private _appModuleCompiler : AppModuleCompiler , private _genConfig : CompilerConfig ,
private _console : Console ) {
const flatDeprecatedPlatformDirectives =
ListWrapper . flatten ( _genConfig . deprecatedPlatformDirectives );
if ( flatDeprecatedPlatformDirectives . length > 0 ) {
this . _console . warn (
`Providing platform directives via the PLATFORM_DIRECTIVES provider or the "CompilerConfig" is deprecated. Provide platform directives via an @AppModule instead. Directives: ` +
flatDeprecatedPlatformDirectives . map ( stringify ));
}
const flatDeprecatedPlatformPipes = ListWrapper . flatten ( _genConfig . deprecatedPlatformPipes );
if ( flatDeprecatedPlatformPipes . length > 0 ) {
this . _console . warn (
`Providing platform pipes via the PLATFORM_PIPES provider or the "CompilerConfig" is deprecated. Provide platform pipes via an @AppModule instead. Pipes: ` +
flatDeprecatedPlatformPipes . map ( stringify ));
}
}
2015-10-01 10:07:49 -07:00
2016-07-04 09:37:30 -07:00
get injector () : Injector { return this . _injector ; }
2016-05-03 16:45:30 -07:00
resolveComponent ( component : Type | string ) : Promise < ComponentFactory < any >> {
if ( isString ( component )) {
2016-06-08 16:38:52 -07:00
return PromiseWrapper . reject (
new BaseException ( `Cannot resolve component using ' ${ component } '.` ), null );
2016-05-03 16:45:30 -07:00
}
2016-07-08 13:40:54 -07:00
if ( this . _warnOnComponentResolver ) {
this . _console . warn ( ComponentResolver . DynamicCompilationDeprecationMsg );
this . _warnOnComponentResolver = false ;
}
2016-06-24 08:46:43 -07:00
return this . compileComponentAsync (< ConcreteType < any >> component );
}
2016-06-28 09:54:42 -07:00
compileAppModuleSync < T >( moduleType : ConcreteType < T >, metadata : AppModuleMetadata = null ) :
AppModuleFactory < T > {
return this . _compileAppModule ( moduleType , true , metadata ). syncResult ;
}
compileAppModuleAsync < T >( moduleType : ConcreteType < T >, metadata : AppModuleMetadata = null ) :
Promise < AppModuleFactory < T >> {
return this . _compileAppModule ( moduleType , false , metadata ). asyncResult ;
}
private _compileAppModule < T >(
moduleType : ConcreteType < T >, isSync : boolean ,
metadata : AppModuleMetadata = null ) : SyncAsyncResult < AppModuleFactory < T >> {
// Only cache if we read the metadata via the reflector,
// as we use the moduleType as cache key.
let useCache = ! metadata ;
let appModuleFactory = this . _compiledAppModuleCache . get ( moduleType );
let componentCompilePromises : Promise < any >[] = [];
if ( ! appModuleFactory || ! useCache ) {
var compileModuleMeta = this . _metadataResolver . getAppModuleMetadata ( moduleType , metadata );
2016-07-04 09:37:30 -07:00
let boundCompilerFactory = ( parentResolver : ComponentResolver ) => new BoundCompiler (
2016-06-30 13:07:17 -07:00
this , compileModuleMeta . directives . map ( dir => dir . type . runtime ),
2016-07-04 09:37:30 -07:00
compileModuleMeta . pipes . map (( pipe ) => pipe . type . runtime ), parentResolver );
// Always provide a bound Compiler and ComponentResolver
compileModuleMeta . providers . push (
this . _metadataResolver . getProviderMetadata ( new Provider ( Compiler , {
useFactory : boundCompilerFactory ,
deps : [[ new OptionalMetadata (), new SkipSelfMetadata (), ComponentResolver ]]
})));
2016-06-30 13:07:17 -07:00
compileModuleMeta . providers . push ( this . _metadataResolver . getProviderMetadata (
new Provider ( ComponentResolver , { useExisting : Compiler })));
2016-06-28 09:54:42 -07:00
var compileResult = this . _appModuleCompiler . compile ( compileModuleMeta );
compileResult . dependencies . forEach (( dep ) => {
let compileResult = this . _compileComponent (
dep . comp . runtime , isSync ,
compileModuleMeta . directives . map ( compileType => < any > compileType . runtime ),
compileModuleMeta . pipes . map ( compileType => < any > compileType . runtime ));
dep . placeholder . runtime = compileResult . syncResult ;
componentCompilePromises . push ( compileResult . asyncResult );
dep . placeholder . name = `compFactory_ ${ dep . comp . name } ` ;
});
if ( IS_DART || ! this . _genConfig . useJit ) {
appModuleFactory =
interpretStatements ( compileResult . statements , compileResult . appModuleFactoryVar );
} else {
appModuleFactory = jitStatements (
` ${ compileModuleMeta . type . name } .ngfactory.js` , compileResult . statements ,
compileResult . appModuleFactoryVar );
}
if ( useCache ) {
this . _compiledAppModuleCache . set ( moduleType , appModuleFactory );
}
}
return new SyncAsyncResult (
appModuleFactory , Promise . all ( componentCompilePromises ). then (() => appModuleFactory ));
}
2016-06-30 13:07:17 -07:00
compileComponentAsync < T >( compType : ConcreteType < T >) : Promise < ComponentFactory < T >> {
return this . _compileComponent ( compType , false , [], []). asyncResult ;
2016-06-28 09:54:42 -07:00
}
2016-06-30 13:07:17 -07:00
compileComponentSync < T >( compType : ConcreteType < T >) : ComponentFactory < T > {
return this . _compileComponent ( compType , true , [], []). syncResult ;
2016-06-28 09:54:42 -07:00
}
2016-06-30 13:07:17 -07:00
/**
* @internal
*/
_compileComponent < T >(
2016-06-28 09:54:42 -07:00
compType : ConcreteType < T >, isSync : boolean , moduleDirectives : ConcreteType < any >[],
modulePipes : ConcreteType < any >[]) : SyncAsyncResult < ComponentFactory < T >> {
var templates =
this . _getTransitiveCompiledTemplates ( compType , true , moduleDirectives , modulePipes );
2016-06-24 08:46:43 -07:00
var loadingPromises : Promise < any >[] = [];
templates . forEach (( template ) => {
if ( template . loading ) {
2016-06-28 09:54:42 -07:00
if ( isSync ) {
2016-07-04 09:37:30 -07:00
throw new ComponentStillLoadingError ( template . compType . runtime );
2016-06-28 09:54:42 -07:00
} else {
loadingPromises . push ( template . loading );
}
2016-06-24 08:46:43 -07:00
}
});
2016-07-13 11:01:32 -07:00
const compile =
() => { templates . forEach (( template ) => { this . _compileTemplate ( template ); }); };
2016-06-28 09:54:42 -07:00
if ( isSync ) {
compile ();
}
let result = this . _compiledHostTemplateCache . get ( compType ). proxyComponentFactory ;
return new SyncAsyncResult ( result , Promise . all ( loadingPromises ). then (() => {
compile ();
return result ;
}));
2016-06-24 08:46:43 -07:00
}
2016-06-28 09:54:42 -07:00
clearCacheFor ( type : Type ) {
this . _compiledAppModuleCache . delete ( type );
this . _metadataResolver . clearCacheFor ( type );
this . _compiledHostTemplateCache . delete ( type );
var compiledTemplate = this . _compiledTemplateCache . get ( type );
2016-06-24 08:46:43 -07:00
if ( compiledTemplate ) {
this . _templateNormalizer . clearCacheFor ( compiledTemplate . normalizedCompMeta );
2016-06-28 09:54:42 -07:00
this . _compiledTemplateCache . delete ( type );
2016-06-24 08:46:43 -07:00
}
2016-06-22 14:06:23 -07:00
}
2016-05-03 16:45:30 -07:00
2016-06-22 14:06:23 -07:00
clearCache () : void {
2016-06-24 08:46:43 -07:00
this . _metadataResolver . clearCache ();
2016-06-22 14:06:23 -07:00
this . _compiledTemplateCache . clear ();
2016-06-24 08:46:43 -07:00
this . _compiledHostTemplateCache . clear ();
this . _templateNormalizer . clearCache ();
2016-06-28 09:54:42 -07:00
this . _compiledAppModuleCache . clear ();
2016-06-22 14:06:23 -07:00
}
2016-06-28 09:54:42 -07:00
private _createCompiledHostTemplate ( type : Type ) : CompiledTemplate {
2016-06-24 08:46:43 -07:00
var compiledTemplate = this . _compiledHostTemplateCache . get ( type );
2016-01-06 14:13:44 -08:00
if ( isBlank ( compiledTemplate )) {
2016-06-24 08:46:43 -07:00
var compMeta = this . _metadataResolver . getDirectiveMetadata ( type );
assertComponent ( compMeta );
var hostMeta = createHostComponentMeta ( compMeta . type , compMeta . selector );
compiledTemplate = new CompiledTemplate (
true , compMeta . selector , compMeta . type , [], [ type ], [], [],
this . _templateNormalizer . normalizeDirective ( hostMeta ));
this . _compiledHostTemplateCache . set ( type , compiledTemplate );
2016-01-06 14:13:44 -08:00
}
return compiledTemplate ;
}
2016-06-28 09:54:42 -07:00
private _createCompiledTemplate (
type : Type , moduleDirectives : ConcreteType < any >[],
modulePipes : ConcreteType < any >[]) : CompiledTemplate {
2016-06-24 08:46:43 -07:00
var compiledTemplate = this . _compiledTemplateCache . get ( type );
if ( isBlank ( compiledTemplate )) {
2016-07-13 11:01:32 -07:00
const compMeta = this . _metadataResolver . getDirectiveMetadata ( type );
2016-06-24 08:46:43 -07:00
assertComponent ( compMeta );
2016-07-13 11:01:32 -07:00
const viewDirectives : CompileDirectiveMetadata [] = [];
2016-06-28 09:54:42 -07:00
moduleDirectives . forEach (
( type ) => viewDirectives . push ( this . _metadataResolver . getDirectiveMetadata ( type )));
2016-07-13 11:01:32 -07:00
const viewComponentTypes : Type [] = [];
2016-06-24 08:46:43 -07:00
this . _metadataResolver . getViewDirectivesMetadata ( type ). forEach ( dirOrComp => {
if ( dirOrComp . isComponent ) {
viewComponentTypes . push ( dirOrComp . type . runtime );
} else {
viewDirectives . push ( dirOrComp );
2016-06-22 14:06:23 -07:00
}
2016-06-24 08:46:43 -07:00
});
2016-07-13 11:01:32 -07:00
const precompileComponentTypes = compMeta . precompile . map (( typeMeta ) => typeMeta . runtime );
const pipes = [
2016-06-28 09:54:42 -07:00
... modulePipes . map (( type ) => this . _metadataResolver . getPipeMetadata ( type )),
... this . _metadataResolver . getViewPipesMetadata ( type )
];
2016-06-24 08:46:43 -07:00
compiledTemplate = new CompiledTemplate (
false , compMeta . selector , compMeta . type , viewDirectives , viewComponentTypes ,
precompileComponentTypes , pipes , this . _templateNormalizer . normalizeDirective ( compMeta ));
this . _compiledTemplateCache . set ( type , compiledTemplate );
}
return compiledTemplate ;
}
private _getTransitiveCompiledTemplates (
2016-06-28 09:54:42 -07:00
compType : Type , isHost : boolean , moduleDirectives : ConcreteType < any >[],
modulePipes : ConcreteType < any >[],
2016-06-24 08:46:43 -07:00
target : Set < CompiledTemplate > = new Set < CompiledTemplate >()) : Set < CompiledTemplate > {
2016-07-13 11:01:32 -07:00
const template = isHost ? this . _createCompiledHostTemplate ( compType ) :
this . _createCompiledTemplate ( compType , moduleDirectives , modulePipes );
2016-06-24 08:46:43 -07:00
if ( ! target . has ( template )) {
target . add ( template );
2016-06-28 09:54:42 -07:00
template . viewComponentTypes . forEach (( compType ) => {
this . _getTransitiveCompiledTemplates (
compType , false , moduleDirectives , modulePipes , target );
});
template . precompileHostComponentTypes . forEach (( compType ) => {
this . _getTransitiveCompiledTemplates ( compType , true , moduleDirectives , modulePipes , target );
});
2016-06-24 08:46:43 -07:00
}
return target ;
}
private _compileTemplate ( template : CompiledTemplate ) {
if ( template . isCompiled ) {
return ;
}
2016-07-13 11:01:32 -07:00
const compMeta = template . normalizedCompMeta ;
const externalStylesheetsByModuleUrl = new Map < string , CompiledStylesheet >();
const stylesCompileResult = this . _styleCompiler . compileComponent ( compMeta );
2016-06-24 08:46:43 -07:00
stylesCompileResult . externalStylesheets . forEach (
( r ) => { externalStylesheetsByModuleUrl . set ( r . meta . moduleUrl , r ); });
this . _resolveStylesCompileResult (
stylesCompileResult . componentStylesheet , externalStylesheetsByModuleUrl );
2016-07-13 11:01:32 -07:00
const viewCompMetas = template . viewComponentTypes . map (
2016-06-28 09:54:42 -07:00
( compType ) => this . _compiledTemplateCache . get ( compType ). normalizedCompMeta );
2016-07-13 11:01:32 -07:00
const parsedTemplate = this . _templateParser . parse (
2016-06-24 08:46:43 -07:00
compMeta , compMeta . template . template , template . viewDirectives . concat ( viewCompMetas ),
template . viewPipes , compMeta . type . name );
2016-07-13 11:01:32 -07:00
const compileResult = this . _viewCompiler . compileComponent (
2016-06-24 08:46:43 -07:00
compMeta , parsedTemplate , ir . variable ( stylesCompileResult . componentStylesheet . stylesVar ),
template . viewPipes );
2016-07-13 11:01:32 -07:00
compileResult . dependencies . forEach (( dep ) => {
2016-06-24 08:46:43 -07:00
let depTemplate : CompiledTemplate ;
if ( dep instanceof ViewFactoryDependency ) {
2016-06-29 10:26:45 -07:00
let vfd = < ViewFactoryDependency > dep ;
2016-06-28 09:54:42 -07:00
depTemplate = this . _compiledTemplateCache . get ( vfd . comp . runtime );
2016-06-29 10:26:45 -07:00
vfd . placeholder . runtime = depTemplate . proxyViewFactory ;
vfd . placeholder . name = `viewFactory_ ${ vfd . comp . name } ` ;
2016-06-22 14:06:23 -07:00
} else if ( dep instanceof ComponentFactoryDependency ) {
2016-06-29 10:26:45 -07:00
let cfd = < ComponentFactoryDependency > dep ;
2016-06-28 09:54:42 -07:00
depTemplate = this . _compiledHostTemplateCache . get ( cfd . comp . runtime );
2016-06-29 10:26:45 -07:00
cfd . placeholder . runtime = depTemplate . proxyComponentFactory ;
cfd . placeholder . name = `compFactory_ ${ cfd . comp . name } ` ;
2016-01-06 14:13:44 -08:00
}
});
2016-07-13 11:01:32 -07:00
const statements =
2016-06-24 08:46:43 -07:00
stylesCompileResult . componentStylesheet . statements . concat ( compileResult . statements );
2016-07-13 11:01:32 -07:00
let factory : any ;
2016-01-06 14:13:44 -08:00
if ( IS_DART || ! this . _genConfig . useJit ) {
2016-06-28 09:54:42 -07:00
factory = interpretStatements ( statements , compileResult . viewFactoryVar );
2016-01-06 14:13:44 -08:00
} else {
2016-06-08 16:38:52 -07:00
factory = jitStatements (
2016-06-28 09:54:42 -07:00
` ${ template . compType . name } .ngfactory.js` , statements , compileResult . viewFactoryVar );
2016-01-06 14:13:44 -08:00
}
2016-06-24 08:46:43 -07:00
template . compiled ( factory );
2016-01-06 14:13:44 -08:00
}
2016-06-24 08:46:43 -07:00
private _resolveStylesCompileResult (
result : CompiledStylesheet , externalStylesheetsByModuleUrl : Map < string , CompiledStylesheet >) {
result . dependencies . forEach (( dep , i ) => {
var nestedCompileResult = externalStylesheetsByModuleUrl . get ( dep . moduleUrl );
var nestedStylesArr = this . _resolveAndEvalStylesCompileResult (
nestedCompileResult , externalStylesheetsByModuleUrl );
dep . valuePlaceholder . runtime = nestedStylesArr ;
dep . valuePlaceholder . name = `importedStyles ${ i } ` ;
});
2016-01-06 14:13:44 -08:00
}
2016-06-24 08:46:43 -07:00
private _resolveAndEvalStylesCompileResult (
result : CompiledStylesheet ,
externalStylesheetsByModuleUrl : Map < string , CompiledStylesheet >) : string [] {
this . _resolveStylesCompileResult ( result , externalStylesheetsByModuleUrl );
if ( IS_DART || ! this . _genConfig . useJit ) {
2016-06-28 09:54:42 -07:00
return interpretStatements ( result . statements , result . stylesVar );
2016-06-24 08:46:43 -07:00
} else {
return jitStatements ( ` ${ result . meta . moduleUrl } .css.js` , result . statements , result . stylesVar );
2016-01-06 14:13:44 -08:00
}
2016-06-22 14:06:23 -07:00
}
}
2016-01-06 14:13:44 -08:00
class CompiledTemplate {
2016-06-22 14:06:23 -07:00
private _viewFactory : Function = null ;
2016-01-06 14:13:44 -08:00
proxyViewFactory : Function ;
2016-06-24 08:46:43 -07:00
proxyComponentFactory : ComponentFactory < any >;
loading : Promise < any > = null ;
private _normalizedCompMeta : CompileDirectiveMetadata = null ;
isCompiled = false ;
isCompiledWithDeps = false ;
constructor (
public isHost : boolean , selector : string , public compType : CompileIdentifierMetadata ,
public viewDirectives : CompileDirectiveMetadata [], public viewComponentTypes : Type [],
public precompileHostComponentTypes : Type [], public viewPipes : CompilePipeMetadata [],
2016-06-28 09:54:42 -07:00
_normalizeResult : SyncAsyncResult < CompileDirectiveMetadata >) {
2016-06-24 08:46:43 -07:00
this . proxyViewFactory = (... args : any []) => this . _viewFactory . apply ( null , args );
this . proxyComponentFactory = isHost ?
new ComponentFactory < any >( selector , this . proxyViewFactory , compType . runtime ) :
null ;
if ( _normalizeResult . syncResult ) {
this . _normalizedCompMeta = _normalizeResult . syncResult ;
} else {
this . loading = _normalizeResult . asyncResult . then (( normalizedCompMeta ) => {
this . _normalizedCompMeta = normalizedCompMeta ;
this . loading = null ;
});
}
2016-01-06 14:13:44 -08:00
}
2016-06-24 08:46:43 -07:00
get normalizedCompMeta () : CompileDirectiveMetadata {
if ( this . loading ) {
throw new BaseException ( `Template is still loading for ${ this . compType . name } !` );
}
return this . _normalizedCompMeta ;
}
compiled ( viewFactory : Function ) {
this . _viewFactory = viewFactory ;
this . isCompiled = true ;
}
depsCompiled() { this . isCompiledWithDeps = true ; }
2016-01-06 14:13:44 -08:00
}
function assertComponent ( meta : CompileDirectiveMetadata ) {
if ( ! meta . isComponent ) {
throw new BaseException ( `Could not compile ' ${ meta . type . name } ' because it is not a component.` );
2015-10-01 10:07:49 -07:00
}
}
2016-06-30 13:07:17 -07:00
/**
* A wrapper around `Compiler` and `ComponentResolver` that
* provides default patform directives / pipes.
*/
class BoundCompiler implements Compiler , ComponentResolver {
constructor (
2016-07-04 09:37:30 -07:00
private _delegate : RuntimeCompiler , private _directives : any [], private _pipes : any [],
private _parentComponentResolver : ComponentResolver ) {}
get injector () : Injector { return this . _delegate . injector ; }
2016-06-30 13:07:17 -07:00
resolveComponent ( component : Type | string ) : Promise < ComponentFactory < any >> {
if ( isString ( component )) {
2016-07-04 09:37:30 -07:00
if ( this . _parentComponentResolver ) {
return this . _parentComponentResolver . resolveComponent ( component );
} else {
return PromiseWrapper . reject (
new BaseException ( `Cannot resolve component using ' ${ component } '.` ), null );
}
2016-06-30 13:07:17 -07:00
}
return this . compileComponentAsync (< ConcreteType < any >> component );
}
compileComponentAsync < T >( compType : ConcreteType < T >) : Promise < ComponentFactory < T >> {
return this . _delegate . _compileComponent ( compType , false , this . _directives , this . _pipes )
. asyncResult ;
}
compileComponentSync < T >( compType : ConcreteType < T >) : ComponentFactory < T > {
return this . _delegate . _compileComponent ( compType , true , this . _directives , this . _pipes )
. syncResult ;
}
compileAppModuleSync < T >( moduleType : ConcreteType < T >, metadata : AppModuleMetadata = null ) :
AppModuleFactory < T > {
return this . _delegate . compileAppModuleSync ( moduleType , metadata );
}
compileAppModuleAsync < T >( moduleType : ConcreteType < T >, metadata : AppModuleMetadata = null ) :
Promise < AppModuleFactory < T >> {
return this . _delegate . compileAppModuleAsync ( moduleType , metadata );
}
/**
* Clears all caches
*/
2016-07-04 09:37:30 -07:00
clearCache () : void {
this . _delegate . clearCache ();
if ( this . _parentComponentResolver ) {
this . _parentComponentResolver . clearCache ();
}
}
2016-06-30 13:07:17 -07:00
/**
* Clears the cache for the given component/appModule.
*/
clearCacheFor ( type : Type ) { this . _delegate . clearCacheFor ( type ); }
}