diff --git a/modules/@angular/compiler-cli/README.md b/modules/@angular/compiler-cli/README.md index b626c34bbd..20625353a6 100644 --- a/modules/@angular/compiler-cli/README.md +++ b/modules/@angular/compiler-cli/README.md @@ -38,7 +38,7 @@ export class MyComponent {} @NgModule({ imports: [BrowserModule], declarations: [MyComponent], - precompile: [MyComponent] + entryComponents: [MyComponent] }) export class MainModule { constructor(appRef: ApplicationRef) { diff --git a/modules/@angular/compiler-cli/integrationtest/src/entry_components.ts b/modules/@angular/compiler-cli/integrationtest/src/entry_components.ts new file mode 100644 index 0000000000..41e2005c88 --- /dev/null +++ b/modules/@angular/compiler-cli/integrationtest/src/entry_components.ts @@ -0,0 +1,35 @@ +/** + * @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 + */ + +import {ANALYZE_FOR_ENTRY_COMPONENTS, Component, ComponentFactoryResolver, Inject, OpaqueToken} from '@angular/core'; + +import {BasicComp} from './basic'; + +@Component({selector: 'cmp-entryComponents', template: '', entryComponents: [BasicComp]}) +export class CompWithEntryComponents { + constructor(public cfr: ComponentFactoryResolver) {} +} + +export const SOME_TOKEN = new OpaqueToken('someToken'); + +export function provideValueWithEntryComponents(value: any) { + return [ + {provide: SOME_TOKEN, useValue: value}, + {provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: value, multi: true}, + ]; +} + +@Component({ + selector: 'comp-entryComponents-provider', + template: '', + providers: [provideValueWithEntryComponents([{a: 'b', component: BasicComp}])] +}) +export class CompWithAnalyzeEntryComponentsProvider { + constructor(public cfr: ComponentFactoryResolver, @Inject(SOME_TOKEN) public providedValue: any) { + } +} diff --git a/modules/@angular/compiler-cli/integrationtest/src/module.ts b/modules/@angular/compiler-cli/integrationtest/src/module.ts index e6fec9aa31..77c6c62e38 100644 --- a/modules/@angular/compiler-cli/integrationtest/src/module.ts +++ b/modules/@angular/compiler-cli/integrationtest/src/module.ts @@ -12,23 +12,24 @@ import {BrowserModule} from '@angular/platform-browser'; import {AnimateCmp} from './animate'; import {BasicComp} from './basic'; +import {CompWithAnalyzeEntryComponentsProvider, CompWithEntryComponents} from './entry_components'; import {CompWithProviders, CompWithReferences} from './features'; import {CompUsingRootModuleDirectiveAndPipe, SomeDirectiveInRootModule, SomeLibModule, SomePipeInRootModule, SomeService} from './module_fixtures'; -import {CompWithAnalyzePrecompileProvider, CompWithPrecompile} from './precompile'; import {ProjectingComp} from './projection'; import {CompWithChildQuery, CompWithDirectiveChild} from './queries'; @NgModule({ declarations: [ - SomeDirectiveInRootModule, SomePipeInRootModule, AnimateCmp, BasicComp, CompWithPrecompile, - CompWithAnalyzePrecompileProvider, ProjectingComp, CompWithChildQuery, CompWithDirectiveChild, - CompUsingRootModuleDirectiveAndPipe, CompWithProviders, CompWithReferences + SomeDirectiveInRootModule, SomePipeInRootModule, AnimateCmp, BasicComp, CompWithEntryComponents, + CompWithAnalyzeEntryComponentsProvider, ProjectingComp, CompWithChildQuery, + CompWithDirectiveChild, CompUsingRootModuleDirectiveAndPipe, CompWithProviders, + CompWithReferences ], imports: [BrowserModule, FormsModule, SomeLibModule], providers: [SomeService], - precompile: [ - AnimateCmp, BasicComp, CompWithPrecompile, CompWithAnalyzePrecompileProvider, ProjectingComp, - CompWithChildQuery, CompUsingRootModuleDirectiveAndPipe + entryComponents: [ + AnimateCmp, BasicComp, CompWithEntryComponents, CompWithAnalyzeEntryComponentsProvider, + ProjectingComp, CompWithChildQuery, CompUsingRootModuleDirectiveAndPipe ] }) export class MainModule { diff --git a/modules/@angular/compiler-cli/integrationtest/src/module_fixtures.ts b/modules/@angular/compiler-cli/integrationtest/src/module_fixtures.ts index db3a01a91d..0c5af2cdbb 100644 --- a/modules/@angular/compiler-cli/integrationtest/src/module_fixtures.ts +++ b/modules/@angular/compiler-cli/integrationtest/src/module_fixtures.ts @@ -7,7 +7,7 @@ */ import {LowerCasePipe, NgIf} from '@angular/common'; -import {ANALYZE_FOR_PRECOMPILE, Component, ComponentFactoryResolver, Directive, Inject, Injectable, Input, NgModule, OpaqueToken, Pipe} from '@angular/core'; +import {ANALYZE_FOR_ENTRY_COMPONENTS, Component, ComponentFactoryResolver, Directive, Inject, Injectable, Input, NgModule, OpaqueToken, Pipe} from '@angular/core'; import {BrowserModule} from '@angular/platform-browser'; @Injectable() @@ -51,19 +51,19 @@ export class CompUsingLibModuleDirectiveAndPipe { export const SOME_TOKEN = new OpaqueToken('someToken'); -export function provideValueWithPrecompile(value: any) { +export function provideValueWithEntryComponents(value: any) { return [ {provide: SOME_TOKEN, useValue: value}, - {provide: ANALYZE_FOR_PRECOMPILE, useValue: value, multi: true}, + {provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: value, multi: true}, ]; } @NgModule({ declarations: [SomeDirectiveInLibModule, SomePipeInLibModule, CompUsingLibModuleDirectiveAndPipe], - precompile: [CompUsingLibModuleDirectiveAndPipe], + entryComponents: [CompUsingLibModuleDirectiveAndPipe], providers: [ ServiceUsingLibModule, - provideValueWithPrecompile([{a: 'b', component: CompUsingLibModuleDirectiveAndPipe}]) + provideValueWithEntryComponents([{a: 'b', component: CompUsingLibModuleDirectiveAndPipe}]) ], }) export class SomeLibModule { diff --git a/modules/@angular/compiler-cli/integrationtest/src/precompile.ts b/modules/@angular/compiler-cli/integrationtest/src/precompile.ts deleted file mode 100644 index 0407f7ee1b..0000000000 --- a/modules/@angular/compiler-cli/integrationtest/src/precompile.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @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 - */ - -import {ANALYZE_FOR_PRECOMPILE, Component, ComponentFactoryResolver, Inject, OpaqueToken} from '@angular/core'; - -import {BasicComp} from './basic'; - -@Component({selector: 'cmp-precompile', template: '', precompile: [BasicComp]}) -export class CompWithPrecompile { - constructor(public cfr: ComponentFactoryResolver) {} -} - -export const SOME_TOKEN = new OpaqueToken('someToken'); - -export function provideValueWithPrecompile(value: any) { - return [ - {provide: SOME_TOKEN, useValue: value}, - {provide: ANALYZE_FOR_PRECOMPILE, useValue: value, multi: true}, - ]; -} - -@Component({ - selector: 'comp-precompile-provider', - template: '', - providers: [provideValueWithPrecompile([{a: 'b', component: BasicComp}])] -}) -export class CompWithAnalyzePrecompileProvider { - constructor(public cfr: ComponentFactoryResolver, @Inject(SOME_TOKEN) public providedValue: any) { - } -} diff --git a/modules/@angular/compiler-cli/integrationtest/test/precompile_spec.ts b/modules/@angular/compiler-cli/integrationtest/test/entry_components_spec.ts similarity index 62% rename from modules/@angular/compiler-cli/integrationtest/test/precompile_spec.ts rename to modules/@angular/compiler-cli/integrationtest/test/entry_components_spec.ts index d606cd9a3c..13f7b71e32 100644 --- a/modules/@angular/compiler-cli/integrationtest/test/precompile_spec.ts +++ b/modules/@angular/compiler-cli/integrationtest/test/entry_components_spec.ts @@ -9,23 +9,24 @@ import './init'; import {BasicComp} from '../src/basic'; -import {CompWithAnalyzePrecompileProvider, CompWithPrecompile} from '../src/precompile'; +import {CompWithAnalyzeEntryComponentsProvider, CompWithEntryComponents} from '../src/entry_components'; import {createComponent} from './util'; describe('content projection', () => { - it('should support precompile in components', () => { - var compFixture = createComponent(CompWithPrecompile); + it('should support entryComponents in components', () => { + var compFixture = createComponent(CompWithEntryComponents); var cf = compFixture.componentInstance.cfr.resolveComponentFactory(BasicComp); expect(cf.componentType).toBe(BasicComp); }); - it('should support precompile via the ANALYZE_FOR_PRECOMPILE provider and function providers in components', + it('should support entryComponents via the ANALYZE_FOR_ENTRY_COMPONENTS provider and function providers in components', () => { - const compFixture = createComponent(CompWithAnalyzePrecompileProvider); + const compFixture = createComponent(CompWithAnalyzeEntryComponentsProvider); const cf = compFixture.componentInstance.cfr.resolveComponentFactory(BasicComp); expect(cf.componentType).toBe(BasicComp); - // check that the function call that created the provider for ANALYZE_FOR_PRECOMPILE worked. + // check that the function call that created the provider for ANALYZE_FOR_ENTRY_COMPONENTS + // worked. expect(compFixture.componentInstance.providedValue).toEqual([ {a: 'b', component: BasicComp} ]); diff --git a/modules/@angular/compiler-cli/integrationtest/test/ng_module_spec.ts b/modules/@angular/compiler-cli/integrationtest/test/ng_module_spec.ts index 77e8dc14b4..a0a565d7f4 100644 --- a/modules/@angular/compiler-cli/integrationtest/test/ng_module_spec.ts +++ b/modules/@angular/compiler-cli/integrationtest/test/ng_module_spec.ts @@ -20,7 +20,7 @@ describe('NgModule', () => { expect(moduleRef.injector.get(SomeService) instanceof SomeService).toBe(true); }); - it('should support precompile components', () => { + it('should support entryComponents components', () => { const moduleRef = createModule(); const cf = moduleRef.componentFactoryResolver.resolveComponentFactory( CompUsingRootModuleDirectiveAndPipe); @@ -29,13 +29,14 @@ describe('NgModule', () => { expect(compRef.instance instanceof CompUsingRootModuleDirectiveAndPipe).toBe(true); }); - it('should support precompile via the ANALYZE_FOR_PRECOMPILE provider and function providers in components', + it('should support entryComponents via the ANALYZE_FOR_ENTRY_COMPONENTS provider and function providers in components', () => { const moduleRef = createModule(); const cf = moduleRef.componentFactoryResolver.resolveComponentFactory( CompUsingRootModuleDirectiveAndPipe); expect(cf.componentType).toBe(CompUsingRootModuleDirectiveAndPipe); - // check that the function call that created the provider for ANALYZE_FOR_PRECOMPILE worked. + // check that the function call that created the provider for ANALYZE_FOR_ENTRY_COMPONENTS + // worked. expect(moduleRef.injector.get(SOME_TOKEN)).toEqual([ {a: 'b', component: CompUsingLibModuleDirectiveAndPipe} ]); diff --git a/modules/@angular/compiler/src/compile_metadata.ts b/modules/@angular/compiler/src/compile_metadata.ts index 6ca72057cc..05a3639f1d 100644 --- a/modules/@angular/compiler/src/compile_metadata.ts +++ b/modules/@angular/compiler/src/compile_metadata.ts @@ -405,7 +405,7 @@ export class CompileTemplateMetadata { export class CompileDirectiveMetadata implements CompileMetadataWithIdentifier { static create( {type, isComponent, selector, exportAs, changeDetection, inputs, outputs, host, - lifecycleHooks, providers, viewProviders, queries, viewQueries, precompile, template}: { + lifecycleHooks, providers, viewProviders, queries, viewQueries, entryComponents, template}: { type?: CompileTypeMetadata, isComponent?: boolean, selector?: string, @@ -421,7 +421,7 @@ export class CompileDirectiveMetadata implements CompileMetadataWithIdentifier { Array, queries?: CompileQueryMetadata[], viewQueries?: CompileQueryMetadata[], - precompile?: CompileTypeMetadata[], + entryComponents?: CompileTypeMetadata[], template?: CompileTemplateMetadata } = {}): CompileDirectiveMetadata { var hostListeners: {[key: string]: string} = {}; @@ -470,7 +470,7 @@ export class CompileDirectiveMetadata implements CompileMetadataWithIdentifier { viewProviders, queries, viewQueries, - precompile, + entryComponents, template, }); } @@ -490,13 +490,13 @@ export class CompileDirectiveMetadata implements CompileMetadataWithIdentifier { queries: CompileQueryMetadata[]; viewQueries: CompileQueryMetadata[]; // Note: Need to keep types here to prevent cycles! - precompile: CompileTypeMetadata[]; + entryComponents: CompileTypeMetadata[]; template: CompileTemplateMetadata; constructor( {type, isComponent, selector, exportAs, changeDetection, inputs, outputs, hostListeners, hostProperties, hostAttributes, lifecycleHooks, providers, viewProviders, queries, - viewQueries, precompile, template}: { + viewQueries, entryComponents, template}: { type?: CompileTypeMetadata, isComponent?: boolean, selector?: string, @@ -514,7 +514,7 @@ export class CompileDirectiveMetadata implements CompileMetadataWithIdentifier { Array, queries?: CompileQueryMetadata[], viewQueries?: CompileQueryMetadata[], - precompile?: CompileTypeMetadata[], + entryComponents?: CompileTypeMetadata[], template?: CompileTemplateMetadata, } = {}) { this.type = type; @@ -532,7 +532,7 @@ export class CompileDirectiveMetadata implements CompileMetadataWithIdentifier { this.viewProviders = _normalizeArray(viewProviders); this.queries = _normalizeArray(queries); this.viewQueries = _normalizeArray(viewQueries); - this.precompile = _normalizeArray(precompile); + this.entryComponents = _normalizeArray(entryComponents); this.template = template; } @@ -619,8 +619,8 @@ export class CompileNgModuleMetadata implements CompileMetadataWithIdentifier { exportedDirectives: CompileDirectiveMetadata[]; declaredPipes: CompilePipeMetadata[]; exportedPipes: CompilePipeMetadata[]; - // Note: See CompileDirectiveMetadata.precompile why this has to be a type. - precompile: CompileTypeMetadata[]; + // Note: See CompileDirectiveMetadata.entryComponents why this has to be a type. + entryComponents: CompileTypeMetadata[]; providers: CompileProviderMetadata[]; importedModules: CompileNgModuleMetadata[]; @@ -630,7 +630,7 @@ export class CompileNgModuleMetadata implements CompileMetadataWithIdentifier { constructor( {type, providers, declaredDirectives, exportedDirectives, declaredPipes, exportedPipes, - precompile, importedModules, exportedModules, transitiveModule}: { + entryComponents, importedModules, exportedModules, transitiveModule}: { type?: CompileTypeMetadata, providers?: Array, @@ -638,7 +638,7 @@ export class CompileNgModuleMetadata implements CompileMetadataWithIdentifier { exportedDirectives?: CompileDirectiveMetadata[], declaredPipes?: CompilePipeMetadata[], exportedPipes?: CompilePipeMetadata[], - precompile?: CompileTypeMetadata[], + entryComponents?: CompileTypeMetadata[], importedModules?: CompileNgModuleMetadata[], exportedModules?: CompileNgModuleMetadata[], transitiveModule?: TransitiveCompileNgModuleMetadata @@ -649,7 +649,7 @@ export class CompileNgModuleMetadata implements CompileMetadataWithIdentifier { this.declaredPipes = _normalizeArray(declaredPipes); this.exportedPipes = _normalizeArray(exportedPipes); this.providers = _normalizeArray(providers); - this.precompile = _normalizeArray(precompile); + this.entryComponents = _normalizeArray(entryComponents); this.importedModules = _normalizeArray(importedModules); this.exportedModules = _normalizeArray(exportedModules); this.transitiveModule = transitiveModule; @@ -670,7 +670,7 @@ export class TransitiveCompileNgModuleMetadata { pipesSet = new Set(); constructor( public modules: CompileNgModuleMetadata[], public providers: CompileProviderMetadata[], - public precompile: CompileTypeMetadata[], public directives: CompileDirectiveMetadata[], + public entryComponents: CompileTypeMetadata[], public directives: CompileDirectiveMetadata[], public pipes: CompilePipeMetadata[]) { directives.forEach(dir => this.directivesSet.add(dir.type.runtime)); pipes.forEach(pipe => this.pipesSet.add(pipe.type.runtime)); diff --git a/modules/@angular/compiler/src/directive_normalizer.ts b/modules/@angular/compiler/src/directive_normalizer.ts index 564f367da6..d6edaf65d0 100644 --- a/modules/@angular/compiler/src/directive_normalizer.ts +++ b/modules/@angular/compiler/src/directive_normalizer.ts @@ -254,7 +254,7 @@ function _cloneDirectiveWithTemplate( viewProviders: directive.viewProviders, queries: directive.queries, viewQueries: directive.viewQueries, - precompile: directive.precompile, + entryComponents: directive.entryComponents, template: template }); } diff --git a/modules/@angular/compiler/src/directive_resolver.ts b/modules/@angular/compiler/src/directive_resolver.ts index 939541163c..ce775a3805 100644 --- a/modules/@angular/compiler/src/directive_resolver.ts +++ b/modules/@angular/compiler/src/directive_resolver.ts @@ -143,7 +143,7 @@ export class DirectiveResolver { changeDetection: dm.changeDetection, providers: dm.providers, viewProviders: dm.viewProviders, - precompile: dm.precompile + entryComponents: dm.entryComponents }); } else { diff --git a/modules/@angular/compiler/src/identifiers.ts b/modules/@angular/compiler/src/identifiers.ts index 304674fdc4..19bf2c41b6 100644 --- a/modules/@angular/compiler/src/identifiers.ts +++ b/modules/@angular/compiler/src/identifiers.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {ANALYZE_FOR_PRECOMPILE, ChangeDetectionStrategy, ChangeDetectorRef, ComponentFactory, ComponentFactoryResolver, ElementRef, Injector, NgModuleFactory, QueryList, RenderComponentType, Renderer, SecurityContext, SimpleChange, TemplateRef, ViewContainerRef, ViewEncapsulation} from '@angular/core'; +import {ANALYZE_FOR_ENTRY_COMPONENTS, ChangeDetectionStrategy, ChangeDetectorRef, ComponentFactory, ComponentFactoryResolver, ElementRef, Injector, NgModuleFactory, QueryList, RenderComponentType, Renderer, SecurityContext, SimpleChange, TemplateRef, ViewContainerRef, ViewEncapsulation} from '@angular/core'; import {AnimationGroupPlayer as AnimationGroupPlayer_, AnimationKeyframe as AnimationKeyframe_, AnimationSequencePlayer as AnimationSequencePlayer_, AnimationStyles as AnimationStyles_, AppElement, AppView, ChangeDetectorStatus, CodegenComponentFactoryResolver, DebugAppView, DebugContext, EMPTY_ARRAY, EMPTY_MAP, NgModuleInjector, NoOpAnimationPlayer as NoOpAnimationPlayer_, StaticNodeDebugInfo, TemplateRef_, UNINITIALIZED, ValueUnwrapper, ViewType, ViewUtils, balanceAnimationKeyframes as impBalanceAnimationKeyframes, castByValue, checkBinding, clearStyles as impClearStyles, collectAndResolveStyles as impCollectAndResolveStyles, devModeEqual, flattenNestedViewRenderNodes, interpolate, prepareFinalAnimationStyles as impBalanceAnimationStyles, pureProxy1, pureProxy10, pureProxy2, pureProxy3, pureProxy4, pureProxy5, pureProxy6, pureProxy7, pureProxy8, pureProxy9, renderStyles as impRenderStyles} from '../core_private'; @@ -58,10 +58,10 @@ var impNoOpAnimationPlayer = NoOpAnimationPlayer_; var ANIMATION_STYLE_UTIL_ASSET_URL = assetUrl('core', 'animation/animation_style_util'); export class Identifiers { - static ANALYZE_FOR_PRECOMPILE = new CompileIdentifierMetadata({ - name: 'ANALYZE_FOR_PRECOMPILE', + static ANALYZE_FOR_ENTRY_COMPONENTS = new CompileIdentifierMetadata({ + name: 'ANALYZE_FOR_ENTRY_COMPONENTS', moduleUrl: assetUrl('core', 'metadata/di'), - runtime: ANALYZE_FOR_PRECOMPILE + runtime: ANALYZE_FOR_ENTRY_COMPONENTS }); static ViewUtils = new CompileIdentifierMetadata( {name: 'ViewUtils', moduleUrl: assetUrl('core', 'linker/view_utils'), runtime: impViewUtils}); diff --git a/modules/@angular/compiler/src/metadata_resolver.ts b/modules/@angular/compiler/src/metadata_resolver.ts index e8615891c5..74c6706a39 100644 --- a/modules/@angular/compiler/src/metadata_resolver.ts +++ b/modules/@angular/compiler/src/metadata_resolver.ts @@ -123,7 +123,7 @@ export class CompileMetadataResolver { var changeDetectionStrategy: ChangeDetectionStrategy = null; var viewProviders: Array = []; var moduleUrl = staticTypeModuleUrl(directiveType); - var precompileTypes: cpl.CompileTypeMetadata[] = []; + var entryComponentTypes: cpl.CompileTypeMetadata[] = []; if (dirMeta instanceof ComponentMetadata) { var cmpMeta = dirMeta; var viewMeta = this._viewResolver.resolve(directiveType); @@ -150,9 +150,10 @@ export class CompileMetadataResolver { verifyNonBlankProviders(directiveType, dirMeta.viewProviders, 'viewProviders'), []); } moduleUrl = componentModuleUrl(this._reflector, directiveType, cmpMeta); - if (cmpMeta.precompile) { - precompileTypes = flattenArray(cmpMeta.precompile) - .map((cmp) => this.getTypeMetadata(cmp, staticTypeModuleUrl(cmp))); + if (cmpMeta.entryComponents) { + entryComponentTypes = + flattenArray(cmpMeta.entryComponents) + .map((cmp) => this.getTypeMetadata(cmp, staticTypeModuleUrl(cmp))); } } @@ -160,7 +161,7 @@ export class CompileMetadataResolver { if (isPresent(dirMeta.providers)) { providers = this.getProvidersMetadata( verifyNonBlankProviders(directiveType, dirMeta.providers, 'providers'), - precompileTypes); + entryComponentTypes); } var queries: cpl.CompileQueryMetadata[] = []; var viewQueries: cpl.CompileQueryMetadata[] = []; @@ -184,7 +185,7 @@ export class CompileMetadataResolver { viewProviders: viewProviders, queries: queries, viewQueries: viewQueries, - precompile: precompileTypes + entryComponents: entryComponentTypes }); this._directiveCache.set(directiveType, meta); } @@ -259,7 +260,8 @@ export class CompileMetadataResolver { if (declaredDirMeta = this.getDirectiveMetadata(declaredType, false)) { this._addDirectiveToModule( declaredDirMeta, moduleType, transitiveModule, declaredDirectives, true); - // Collect @Component.directives/pipes/precompile into our declared directives/pipes. + // Collect @Component.directives/pipes/entryComponents into our declared + // directives/pipes. this._getTransitiveViewDirectivesAndPipes( declaredDirMeta, moduleType, transitiveModule, declaredDirectives, declaredPipes); } else if (declaredPipeMeta = this.getPipeMetadata(declaredType, false)) { @@ -273,22 +275,23 @@ export class CompileMetadataResolver { } const providers: any[] = []; - const precompile: cpl.CompileTypeMetadata[] = []; + const entryComponents: cpl.CompileTypeMetadata[] = []; if (meta.providers) { - providers.push(...this.getProvidersMetadata(meta.providers, precompile)); + providers.push(...this.getProvidersMetadata(meta.providers, entryComponents)); } - if (meta.precompile) { - precompile.push(...flattenArray(meta.precompile) - .map(type => this.getTypeMetadata(type, staticTypeModuleUrl(type)))); + if (meta.entryComponents) { + entryComponents.push( + ...flattenArray(meta.entryComponents) + .map(type => this.getTypeMetadata(type, staticTypeModuleUrl(type)))); } - transitiveModule.precompile.push(...precompile); + transitiveModule.entryComponents.push(...entryComponents); transitiveModule.providers.push(...providers); compileMeta = new cpl.CompileNgModuleMetadata({ type: this.getTypeMetadata(moduleType, staticTypeModuleUrl(moduleType)), providers: providers, - precompile: precompile, + entryComponents: entryComponents, declaredDirectives: declaredDirectives, exportedDirectives: exportedDirectives, declaredPipes: declaredPipes, @@ -306,7 +309,7 @@ export class CompileMetadataResolver { addComponentToModule(moduleType: Type, compType: Type) { const moduleMeta = this.getNgModuleMetadata(moduleType); - // Collect @Component.directives/pipes/precompile into our declared directives/pipes. + // Collect @Component.directives/pipes/entryComponents into our declared directives/pipes. const compMeta = this.getDirectiveMetadata(compType, false); this._addDirectiveToModule( compMeta, moduleMeta.type.runtime, moduleMeta.transitiveModule, @@ -315,8 +318,8 @@ export class CompileMetadataResolver { compMeta, moduleMeta.type.runtime, moduleMeta.transitiveModule, moduleMeta.declaredDirectives, moduleMeta.declaredPipes); - moduleMeta.transitiveModule.precompile.push(compMeta.type); - moduleMeta.precompile.push(compMeta.type); + moduleMeta.transitiveModule.entryComponents.push(compMeta.type); + moduleMeta.entryComponents.push(compMeta.type); this._verifyModule(moduleMeta); } @@ -335,17 +338,17 @@ export class CompileMetadataResolver { } }); moduleMeta.declaredDirectives.forEach((dirMeta) => { - dirMeta.precompile.forEach((precompileComp) => { - if (!moduleMeta.transitiveModule.directivesSet.has(precompileComp.runtime)) { + dirMeta.entryComponents.forEach((entryComponent) => { + if (!moduleMeta.transitiveModule.directivesSet.has(entryComponent.runtime)) { throw new BaseException( - `Component ${stringify(dirMeta.type.runtime)} in NgModule ${stringify(moduleMeta.type.runtime)} uses ${stringify(precompileComp.runtime)} via "precompile" but it was neither declared nor imported into the module!`); + `Component ${stringify(dirMeta.type.runtime)} in NgModule ${stringify(moduleMeta.type.runtime)} uses ${stringify(entryComponent.runtime)} via "entryComponents" but it was neither declared nor imported into the module!`); } }); }); - moduleMeta.precompile.forEach((precompileType) => { - if (!moduleMeta.transitiveModule.directivesSet.has(precompileType.runtime)) { + moduleMeta.entryComponents.forEach((entryComponentType) => { + if (!moduleMeta.transitiveModule.directivesSet.has(entryComponentType.runtime)) { throw new BaseException( - `NgModule ${stringify(moduleMeta.type.runtime)} uses ${stringify(precompileType.runtime)} via "precompile" but it was neither declared nor imported!`); + `NgModule ${stringify(moduleMeta.type.runtime)} uses ${stringify(entryComponentType.runtime)} via "entryComponents" but it was neither declared nor imported!`); } }); } @@ -400,17 +403,18 @@ export class CompileMetadataResolver { private _getTransitiveNgModuleMetadata( importedModules: cpl.CompileNgModuleMetadata[], exportedModules: cpl.CompileNgModuleMetadata[]): cpl.TransitiveCompileNgModuleMetadata { - // collect `providers` / `precompile` from all imported and all exported modules + // collect `providers` / `entryComponents` from all imported and all exported modules const transitiveModules = getTransitiveModules(importedModules.concat(exportedModules), true); const providers = flattenArray(transitiveModules.map((ngModule) => ngModule.providers)); - const precompile = flattenArray(transitiveModules.map((ngModule) => ngModule.precompile)); + const entryComponents = + flattenArray(transitiveModules.map((ngModule) => ngModule.entryComponents)); const transitiveExportedModules = getTransitiveModules(importedModules, false); const directives = flattenArray(transitiveExportedModules.map((ngModule) => ngModule.exportedDirectives)); const pipes = flattenArray(transitiveExportedModules.map((ngModule) => ngModule.exportedPipes)); return new cpl.TransitiveCompileNgModuleMetadata( - transitiveModules, providers, precompile, directives, pipes); + transitiveModules, providers, entryComponents, directives, pipes); } private _addDirectiveToModule( @@ -571,7 +575,7 @@ export class CompileMetadataResolver { return compileToken; } - getProvidersMetadata(providers: any[], targetPrecompileComponents: cpl.CompileTypeMetadata[]): + getProvidersMetadata(providers: any[], targetEntryComponents: cpl.CompileTypeMetadata[]): Array { const compileProviders: Array = []; providers.forEach((provider) => { @@ -581,11 +585,11 @@ export class CompileMetadataResolver { } let compileProvider: cpl.CompileProviderMetadata|cpl.CompileTypeMetadata|any[]; if (isArray(provider)) { - compileProvider = this.getProvidersMetadata(provider, targetPrecompileComponents); + compileProvider = this.getProvidersMetadata(provider, targetEntryComponents); } else if (provider instanceof Provider) { let tokenMeta = this.getTokenMetadata(provider.token); - if (tokenMeta.equalsTo(identifierToken(Identifiers.ANALYZE_FOR_PRECOMPILE))) { - targetPrecompileComponents.push(...this.getPrecompileComponentsFromProvider(provider)); + if (tokenMeta.equalsTo(identifierToken(Identifiers.ANALYZE_FOR_ENTRY_COMPONENTS))) { + targetEntryComponents.push(...this._getEntryComponentsFromProvider(provider)); } else { compileProvider = this.getProviderMetadata(provider); } @@ -602,14 +606,15 @@ export class CompileMetadataResolver { return compileProviders; } - getPrecompileComponentsFromProvider(provider: Provider): cpl.CompileTypeMetadata[] { + private _getEntryComponentsFromProvider(provider: Provider): cpl.CompileTypeMetadata[] { let components: cpl.CompileTypeMetadata[] = []; let collectedIdentifiers: cpl.CompileIdentifierMetadata[] = []; if (provider.useFactory || provider.useExisting || provider.useClass) { - throw new BaseException(`The ANALYZE_FOR_PRECOMPILE token only supports useValue!`); + throw new BaseException(`The ANALYZE_FOR_ENTRY_COMPONENTS token only supports useValue!`); } if (!provider.multi) { - throw new BaseException(`The ANALYZE_FOR_PRECOMPILE token only supports 'multi = true'!`); + throw new BaseException( + `The ANALYZE_FOR_ENTRY_COMPONENTS token only supports 'multi = true'!`); } convertToCompileValue(provider.useValue, collectedIdentifiers); collectedIdentifiers.forEach((identifier) => { diff --git a/modules/@angular/compiler/src/ng_module_compiler.ts b/modules/@angular/compiler/src/ng_module_compiler.ts index cfc7d56dcf..71663862f0 100644 --- a/modules/@angular/compiler/src/ng_module_compiler.ts +++ b/modules/@angular/compiler/src/ng_module_compiler.ts @@ -41,12 +41,12 @@ export class NgModuleCompiler { new ParseLocation(sourceFile, null, null, null), new ParseLocation(sourceFile, null, null, null)); var deps: ComponentFactoryDependency[] = []; - var precompileComponents = ngModuleMeta.transitiveModule.precompile.map((precompileComp) => { - var id = new CompileIdentifierMetadata({name: precompileComp.name}); - deps.push(new ComponentFactoryDependency(precompileComp, id)); + var entryComponents = ngModuleMeta.transitiveModule.entryComponents.map((entryComponent) => { + var id = new CompileIdentifierMetadata({name: entryComponent.name}); + deps.push(new ComponentFactoryDependency(entryComponent, id)); return id; }); - var builder = new _InjectorBuilder(ngModuleMeta, precompileComponents, sourceSpan); + var builder = new _InjectorBuilder(ngModuleMeta, entryComponents, sourceSpan); var providerParser = new NgModuleProviderAnalyzer(ngModuleMeta, extraProviders, sourceSpan); providerParser.parse().forEach((provider) => builder.addProvider(provider)); @@ -75,8 +75,8 @@ class _InjectorBuilder { constructor( private _ngModuleMeta: CompileNgModuleMetadata, - private _precompileComponents: CompileIdentifierMetadata[], - private _sourceSpan: ParseSourceSpan) {} + private _entryComponents: CompileIdentifierMetadata[], private _sourceSpan: ParseSourceSpan) { + } addProvider(resolvedProvider: ProviderAst) { var providerValueExpressions = @@ -116,8 +116,8 @@ class _InjectorBuilder { [o.SUPER_EXPR .callFn([ o.variable(InjectorProps.parent.name), - o.literalArr(this._precompileComponents.map( - (precompiledComponent) => o.importExpr(precompiledComponent))) + o.literalArr( + this._entryComponents.map((entryComponent) => o.importExpr(entryComponent))) ]) .toStmt()]); diff --git a/modules/@angular/compiler/src/runtime_compiler.ts b/modules/@angular/compiler/src/runtime_compiler.ts index 273b99fe38..c9a1113f0f 100644 --- a/modules/@angular/compiler/src/runtime_compiler.ts +++ b/modules/@angular/compiler/src/runtime_compiler.ts @@ -146,13 +146,13 @@ export class RuntimeCompiler implements Compiler { templates.add(this._createCompiledTemplate( dirMeta, localModuleMeta.transitiveModule.directives, localModuleMeta.transitiveModule.pipes)); - dirMeta.precompile.forEach((precompileType) => { - templates.add(this._createCompiledHostTemplate(precompileType.runtime)); + dirMeta.entryComponents.forEach((entryComponentType) => { + templates.add(this._createCompiledHostTemplate(entryComponentType.runtime)); }); } }); - localModuleMeta.precompile.forEach((precompileType) => { - templates.add(this._createCompiledHostTemplate(precompileType.runtime)); + localModuleMeta.entryComponents.forEach((entryComponentType) => { + templates.add(this._createCompiledHostTemplate(entryComponentType.runtime)); }); }); templates.forEach((template) => { diff --git a/modules/@angular/compiler/src/view_compiler/compile_element.ts b/modules/@angular/compiler/src/view_compiler/compile_element.ts index 202c7ce4c3..db983faae6 100644 --- a/modules/@angular/compiler/src/view_compiler/compile_element.ts +++ b/modules/@angular/compiler/src/view_compiler/compile_element.ts @@ -92,14 +92,13 @@ export class CompileElement extends CompileNode { this._instances.add(identifierToken(Identifiers.AppElement), this.appElement); } - public createComponentFactoryResolver(precompileComponent: CompileIdentifierMetadata[]) { - if (!precompileComponent || precompileComponent.length === 0) { + public createComponentFactoryResolver(entryComponents: CompileIdentifierMetadata[]) { + if (!entryComponents || entryComponents.length === 0) { return; } var createComponentFactoryResolverExpr = o.importExpr(Identifiers.CodegenComponentFactoryResolver).instantiate([ - o.literalArr(precompileComponent.map( - (precompiledComponent) => o.importExpr(precompiledComponent))), + o.literalArr(entryComponents.map((entryComponent) => o.importExpr(entryComponent))), injectFromViewParentInjector(identifierToken(Identifiers.ComponentFactoryResolver), false) ]); var provider = new CompileProviderMetadata({ diff --git a/modules/@angular/compiler/src/view_compiler/view_builder.ts b/modules/@angular/compiler/src/view_compiler/view_builder.ts index 183fdd5f88..b94b6f1ae1 100644 --- a/modules/@angular/compiler/src/view_compiler/view_builder.ts +++ b/modules/@angular/compiler/src/view_compiler/view_builder.ts @@ -211,13 +211,13 @@ class ViewBuilderVisitor implements TemplateAstVisitor { new CompileIdentifierMetadata({name: getViewFactoryName(component, 0)}); this.targetDependencies.push( new ViewFactoryDependency(component.type, nestedComponentIdentifier)); - let precompileComponentIdentifiers = - component.precompile.map((precompileComp: CompileIdentifierMetadata) => { - var id = new CompileIdentifierMetadata({name: precompileComp.name}); - this.targetDependencies.push(new ComponentFactoryDependency(precompileComp, id)); + let entryComponentIdentifiers = + component.entryComponents.map((entryComponent: CompileIdentifierMetadata) => { + var id = new CompileIdentifierMetadata({name: entryComponent.name}); + this.targetDependencies.push(new ComponentFactoryDependency(entryComponent, id)); return id; }); - compileElement.createComponentFactoryResolver(precompileComponentIdentifiers); + compileElement.createComponentFactoryResolver(entryComponentIdentifiers); compViewExpr = o.variable(`compView_${nodeIndex}`); // fix highlighting: ` compileElement.setComponentView(compViewExpr); diff --git a/modules/@angular/compiler/test/ng_module_resolver_spec.ts b/modules/@angular/compiler/test/ng_module_resolver_spec.ts index 442766c508..ea499fbaf8 100644 --- a/modules/@angular/compiler/test/ng_module_resolver_spec.ts +++ b/modules/@angular/compiler/test/ng_module_resolver_spec.ts @@ -21,7 +21,7 @@ class SomeClass5 {} imports: [SomeClass2], exports: [SomeClass3], providers: [SomeClass4], - precompile: [SomeClass5] + entryComponents: [SomeClass5] }) class SomeModule { } @@ -41,7 +41,7 @@ export function main() { imports: [SomeClass2], exports: [SomeClass3], providers: [SomeClass4], - precompile: [SomeClass5] + entryComponents: [SomeClass5] })); }); diff --git a/modules/@angular/compiler/test/runtime_compiler_spec.ts b/modules/@angular/compiler/test/runtime_compiler_spec.ts index 548b9be7ed..f0e7a31ccb 100644 --- a/modules/@angular/compiler/test/runtime_compiler_spec.ts +++ b/modules/@angular/compiler/test/runtime_compiler_spec.ts @@ -116,8 +116,10 @@ export function main() { describe('compileModuleAsync', () => { it('should allow to use templateUrl components', fakeAsync(() => { - @NgModule( - {declarations: [SomeCompWithUrlTemplate], precompile: [SomeCompWithUrlTemplate]}) + @NgModule({ + declarations: [SomeCompWithUrlTemplate], + entryComponents: [SomeCompWithUrlTemplate] + }) class SomeModule { } @@ -131,7 +133,8 @@ export function main() { describe('compileModuleSync', () => { it('should throw when using a templateUrl that has not been compiled before', () => { - @NgModule({declarations: [SomeCompWithUrlTemplate], precompile: [SomeCompWithUrlTemplate]}) + @NgModule( + {declarations: [SomeCompWithUrlTemplate], entryComponents: [SomeCompWithUrlTemplate]}) class SomeModule { } @@ -143,7 +146,7 @@ export function main() { it('should throw when using a templateUrl in a nested component that has not been compiled before', () => { - @NgModule({declarations: [SomeComp], precompile: [SomeComp]}) + @NgModule({declarations: [SomeComp], entryComponents: [SomeComp]}) class SomeModule { } @@ -158,8 +161,10 @@ export function main() { it('should allow to use templateUrl components that have been loaded before', fakeAsync(() => { - @NgModule( - {declarations: [SomeCompWithUrlTemplate], precompile: [SomeCompWithUrlTemplate]}) + @NgModule({ + declarations: [SomeCompWithUrlTemplate], + entryComponents: [SomeCompWithUrlTemplate] + }) class SomeModule { } diff --git a/modules/@angular/compiler/testing/directive_resolver_mock.ts b/modules/@angular/compiler/testing/directive_resolver_mock.ts index 3a29439933..8248f3707e 100644 --- a/modules/@angular/compiler/testing/directive_resolver_mock.ts +++ b/modules/@angular/compiler/testing/directive_resolver_mock.ts @@ -60,7 +60,7 @@ export class MockDirectiveResolver extends DirectiveResolver { changeDetection: dm.changeDetection, providers: providers, viewProviders: viewProviders, - precompile: dm.precompile + entryComponents: dm.entryComponents }); } diff --git a/modules/@angular/core/src/linker/compiler.ts b/modules/@angular/core/src/linker/compiler.ts index cea792a283..17e54c3df1 100644 --- a/modules/@angular/core/src/linker/compiler.ts +++ b/modules/@angular/core/src/linker/compiler.ts @@ -65,7 +65,7 @@ export class Compiler { `Runtime compiler is not loaded. Tried to compile ${stringify(component)}`); } /** - * Compiles the given NgModule. All templates of the components listed in `precompile` + * Compiles the given NgModule. All templates of the components listed in `entryComponents` * have to be either inline or compiled before via `compileComponentAsync` / * `compileModuleAsync`. Otherwise throws a {@link ComponentStillLoadingError}. */ diff --git a/modules/@angular/core/src/linker/component_resolver.ts b/modules/@angular/core/src/linker/component_resolver.ts index e7e07fa380..2adcfc5f7f 100644 --- a/modules/@angular/core/src/linker/component_resolver.ts +++ b/modules/@angular/core/src/linker/component_resolver.ts @@ -14,13 +14,13 @@ import {ComponentFactory} from './component_factory'; * can later be used to create and render a Component instance. * * @deprecated Use {@link ComponentFactoryResolver} together with {@link - * NgModule}.precompile}/{@link Component}.precompile or - * {@link ANALYZE_FOR_PRECOMPILE} provider for dynamic component creation. + * NgModule}.entryComponents}/{@link Component}.entryComponents or + * {@link ANALYZE_FOR_ENTRY_COMPONENTS} provider for dynamic component creation. * Use {@link NgModuleFactoryLoader} for lazy loading. */ export abstract class ComponentResolver { static DynamicCompilationDeprecationMsg = - 'ComponentResolver is deprecated for dynamic compilation. Use ComponentFactoryResolver together with @NgModule/@Component.precompile or ANALYZE_FOR_PRECOMPILE provider instead. For runtime compile only, you can also use Compiler.compileComponentSync/Async.'; + 'ComponentResolver is deprecated for dynamic compilation. Use ComponentFactoryResolver together with @NgModule/@Component.entryComponents or ANALYZE_FOR_ENTRY_COMPONENTS provider instead. For runtime compile only, you can also use Compiler.compileComponentSync/Async.'; static LazyLoadingDeprecationMsg = 'ComponentResolver is deprecated for lazy loading. Use NgModuleFactoryLoader instead.'; diff --git a/modules/@angular/core/src/linker/ng_module_factory.ts b/modules/@angular/core/src/linker/ng_module_factory.ts index 0e2921ee35..5810e90f8c 100644 --- a/modules/@angular/core/src/linker/ng_module_factory.ts +++ b/modules/@angular/core/src/linker/ng_module_factory.ts @@ -29,7 +29,7 @@ export abstract class NgModuleRef { /** * The ComponentFactoryResolver to get hold of the ComponentFactories - * delcared in the `precompile` property of the module. + * delcared in the `entryComponents` property of the module. */ get componentFactoryResolver(): ComponentFactoryResolver { return unimplemented(); } diff --git a/modules/@angular/core/src/metadata.ts b/modules/@angular/core/src/metadata.ts index 7b0f3ebe11..0660a84bfe 100644 --- a/modules/@angular/core/src/metadata.ts +++ b/modules/@angular/core/src/metadata.ts @@ -19,7 +19,7 @@ import {ComponentMetadata, DirectiveMetadata, HostBindingMetadata, HostListenerM import {NgModuleMetadata} from './metadata/ng_module'; import {ViewEncapsulation, ViewMetadata} from './metadata/view'; -export {ANALYZE_FOR_PRECOMPILE, AttributeMetadata, ContentChildMetadata, ContentChildrenMetadata, QueryMetadata, ViewChildMetadata, ViewChildrenMetadata, ViewQueryMetadata} from './metadata/di'; +export {ANALYZE_FOR_ENTRY_COMPONENTS, AttributeMetadata, ContentChildMetadata, ContentChildrenMetadata, QueryMetadata, ViewChildMetadata, ViewChildrenMetadata, ViewQueryMetadata} from './metadata/di'; export {ComponentMetadata, DirectiveMetadata, HostBindingMetadata, HostListenerMetadata, InputMetadata, OutputMetadata, PipeMetadata} from './metadata/directives'; export {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, DoCheck, OnChanges, OnDestroy, OnInit} from './metadata/lifecycle_hooks'; export {NgModuleMetadata} from './metadata/ng_module'; @@ -209,7 +209,7 @@ export interface ComponentMetadataFactory { pipes?: Array, encapsulation?: ViewEncapsulation, interpolation?: [string, string], - precompile?: Array + entryComponents?: Array }): ComponentDecorator; new (obj: { selector?: string, @@ -233,7 +233,7 @@ export interface ComponentMetadataFactory { pipes?: Array, encapsulation?: ViewEncapsulation, interpolation?: [string, string], - precompile?: Array + entryComponents?: Array }): ComponentMetadata; } @@ -500,14 +500,14 @@ export interface NgModuleMetadataFactory { declarations?: Array, imports?: Array, exports?: Array, - precompile?: Array + entryComponents?: Array }): NgModuleDecorator; new (obj?: { providers?: any[], declarations?: Array, imports?: Array, exports?: Array, - precompile?: Array + entryComponents?: Array }): NgModuleMetadata; } diff --git a/modules/@angular/core/src/metadata/di.ts b/modules/@angular/core/src/metadata/di.ts index 3fc60fefe5..bed7eb97cc 100644 --- a/modules/@angular/core/src/metadata/di.ts +++ b/modules/@angular/core/src/metadata/di.ts @@ -13,12 +13,12 @@ import {StringWrapper, Type, isString, stringify} from '../facade/lang'; /** * This token can be used to create a virtual provider that will populate the - * `precompile` fields of components and ng modules based on its `useValue`. + * `entryComponents` fields of components and ng modules based on its `useValue`. * All components that are referenced in the `useValue` value (either directly - * or in a nested array or map) will be added to the `precompile` property. + * or in a nested array or map) will be added to the `entryComponents` property. * * ### Example - * The following example shows how the router can populate the `precompile` + * The following example shows how the router can populate the `entryComponents` * field of an NgModule based on the router configuration which refers * to components. * @@ -27,7 +27,7 @@ import {StringWrapper, Type, isString, stringify} from '../facade/lang'; * function provideRoutes(routes) { * return [ * {provide: ROUTES, useValue: routes}, - * {provide: ANALYZE_FOR_PRECOMPILE, useValue: routes, multi: true} + * {provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: routes, multi: true} * ]; * } * @@ -45,7 +45,7 @@ import {StringWrapper, Type, isString, stringify} from '../facade/lang'; * * @experimental */ -export const ANALYZE_FOR_PRECOMPILE = new OpaqueToken('AnalyzeForPrecompile'); +export const ANALYZE_FOR_ENTRY_COMPONENTS = new OpaqueToken('AnalyzeForEntryComponents'); /** * Specifies that a constant attribute value should be injected. diff --git a/modules/@angular/core/src/metadata/directives.ts b/modules/@angular/core/src/metadata/directives.ts index d6515e7c12..165921f392 100644 --- a/modules/@angular/core/src/metadata/directives.ts +++ b/modules/@angular/core/src/metadata/directives.ts @@ -967,58 +967,43 @@ export class ComponentMetadata extends DirectiveMetadata { interpolation: [string, string]; /** - * Defines the components that should be precompiled as well when + * Defines the components that should be compiled as well when * this component is defined. For each components listed here, * Angular will create a {@link ComponentFactory ComponentFactory} and store it in the * {@link ComponentFactoryResolver ComponentFactoryResolver}. */ - precompile: Array; + entryComponents: Array; - constructor({selector, - inputs, - outputs, - properties, - events, - host, - exportAs, - moduleId, - providers, - viewProviders, - changeDetection = ChangeDetectionStrategy.Default, - queries, - templateUrl, - template, - styleUrls, - styles, - animations, - directives, - pipes, - encapsulation, - interpolation, - precompile}: { - selector?: string, - inputs?: string[], - outputs?: string[], - /** @deprecated */ properties?: string[], - /** @deprecated */ events?: string[], - host?: {[key: string]: string}, - providers?: any[], - exportAs?: string, - moduleId?: string, - viewProviders?: any[], - queries?: {[key: string]: any}, - changeDetection?: ChangeDetectionStrategy, - templateUrl?: string, - template?: string, - styleUrls?: string[], - styles?: string[], - animations?: AnimationEntryMetadata[], - directives?: Array, - pipes?: Array, - encapsulation?: ViewEncapsulation, - interpolation?: [string, string], - precompile?: Array - } = {}) { + constructor( + {selector, inputs, outputs, properties, events, host, exportAs, moduleId, providers, + viewProviders, changeDetection = ChangeDetectionStrategy.Default, queries, templateUrl, + template, styleUrls, styles, animations, directives, pipes, encapsulation, interpolation, + /** @deprecated use entryComponents instead! */ + precompile, entryComponents}: { + selector?: string, + inputs?: string[], + outputs?: string[], + /** @deprecated */ properties?: string[], + /** @deprecated */ events?: string[], + host?: {[key: string]: string}, + providers?: any[], + exportAs?: string, + moduleId?: string, + viewProviders?: any[], + queries?: {[key: string]: any}, + changeDetection?: ChangeDetectionStrategy, + templateUrl?: string, + template?: string, + styleUrls?: string[], + styles?: string[], + animations?: AnimationEntryMetadata[], + directives?: Array, + pipes?: Array, + encapsulation?: ViewEncapsulation, + interpolation?: [string, string], + precompile?: Array, + entryComponents?: Array + } = {}) { super({ selector: selector, inputs: inputs, @@ -1043,7 +1028,7 @@ export class ComponentMetadata extends DirectiveMetadata { this.moduleId = moduleId; this.animations = animations; this.interpolation = interpolation; - this.precompile = precompile; + this.entryComponents = precompile ? precompile : entryComponents; } } diff --git a/modules/@angular/core/src/metadata/ng_module.ts b/modules/@angular/core/src/metadata/ng_module.ts index a08e90104d..d87068e2fc 100644 --- a/modules/@angular/core/src/metadata/ng_module.ts +++ b/modules/@angular/core/src/metadata/ng_module.ts @@ -96,25 +96,25 @@ export class NgModuleMetadata extends InjectableMetadata { exports: Array; /** - * Defines the components that should be precompiled as well when + * Defines the components that should be compiled as well when * this component is defined. For each components listed here, * Angular will create a {@link ComponentFactory ComponentFactory} and store it in the * {@link ComponentFactoryResolver ComponentFactoryResolver}. */ - precompile: Array; + entryComponents: Array; - constructor({providers, declarations, imports, exports, precompile}: { + constructor({providers, declarations, imports, exports, entryComponents}: { providers?: any[], declarations?: Array, imports?: Array, exports?: Array, - precompile?: Array + entryComponents?: Array } = {}) { super(); this._providers = providers; this.declarations = declarations; this.imports = imports; this.exports = exports; - this.precompile = precompile; + this.entryComponents = entryComponents; } } diff --git a/modules/@angular/core/test/linker/precompile_integration_spec.ts b/modules/@angular/core/test/linker/entry_components_integration_spec.ts similarity index 85% rename from modules/@angular/core/test/linker/precompile_integration_spec.ts rename to modules/@angular/core/test/linker/entry_components_integration_spec.ts index 78851ae032..2b425d288e 100644 --- a/modules/@angular/core/test/linker/precompile_integration_spec.ts +++ b/modules/@angular/core/test/linker/entry_components_integration_spec.ts @@ -8,7 +8,7 @@ import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal'; import {TestComponentBuilder, configureModule} from '@angular/core/testing'; -import {Component, ComponentFactoryResolver, NoComponentFactoryError, forwardRef, ANALYZE_FOR_PRECOMPILE, ViewMetadata} from '@angular/core'; +import {Component, ComponentFactoryResolver, NoComponentFactoryError, forwardRef, ANALYZE_FOR_ENTRY_COMPONENTS, ViewMetadata} from '@angular/core'; import {stringify} from '../../src/facade/lang'; export function main() { @@ -17,7 +17,7 @@ export function main() { } function declareTests({useJit}: {useJit: boolean}) { - describe('@Component.precompile', function() { + describe('@Component.entryComponents', function() { beforeEach(() => { configureModule({declarations: [MainComp, ChildComp, NestedChildComp]}); }); it('should error if the component was not declared nor imported by the module', @@ -27,13 +27,13 @@ function declareTests({useJit}: {useJit: boolean}) { class ChildComp { } - @Component({template: 'comp', precompile: [ChildComp]}) + @Component({template: 'comp', entryComponents: [ChildComp]}) class SomeComp { } expect(() => tcb.createSync(SomeComp)) .toThrowError( - `Component ${stringify(SomeComp)} in NgModule DynamicTestModule uses ${stringify(ChildComp)} via "precompile" but it was neither declared nor imported into the module!`); + `Component ${stringify(SomeComp)} in NgModule DynamicTestModule uses ${stringify(ChildComp)} via "entryComponents" but it was neither declared nor imported into the module!`); })); @@ -47,10 +47,10 @@ function declareTests({useJit}: {useJit: boolean}) { })); - it('should resolve ComponentFactories via ANALYZE_FOR_PRECOMPILE', + it('should resolve ComponentFactories via ANALYZE_FOR_ENTRY_COMPONENTS', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { - let compFixture = tcb.createSync(CompWithAnalyzePrecompileProvider); - let mainComp: CompWithAnalyzePrecompileProvider = compFixture.componentInstance; + let compFixture = tcb.createSync(CompWithAnalyzeEntryComponentsProvider); + let mainComp: CompWithAnalyzeEntryComponentsProvider = compFixture.componentInstance; let cfr: ComponentFactoryResolver = compFixture.componentRef.injector.get(ComponentFactoryResolver); expect(cfr.resolveComponentFactory(ChildComp).componentType).toBe(ChildComp); @@ -97,14 +97,14 @@ class NestedChildComp { constructor(public cfr: ComponentFactoryResolver) {} } -@Component({selector: 'child', precompile: [NestedChildComp], template: ''}) +@Component({selector: 'child', entryComponents: [NestedChildComp], template: ''}) class ChildComp { constructor(public cfr: ComponentFactoryResolver) {} } @Component({ selector: 'main', - precompile: [ChildComp], + entryComponents: [ChildComp], template: '', }) class MainComp { @@ -115,7 +115,7 @@ class MainComp { selector: 'comp-with-analyze', template: '', providers: [{ - provide: ANALYZE_FOR_PRECOMPILE, + provide: ANALYZE_FOR_ENTRY_COMPONENTS, multi: true, useValue: [ {a: 'b', component: ChildComp}, @@ -123,5 +123,5 @@ class MainComp { ] }] }) -class CompWithAnalyzePrecompileProvider { +class CompWithAnalyzeEntryComponentsProvider { } diff --git a/modules/@angular/core/test/linker/ng_module_integration_spec.ts b/modules/@angular/core/test/linker/ng_module_integration_spec.ts index 2e10f50930..064aa68eec 100644 --- a/modules/@angular/core/test/linker/ng_module_integration_spec.ts +++ b/modules/@angular/core/test/linker/ng_module_integration_spec.ts @@ -9,7 +9,7 @@ import {LowerCasePipe, NgIf} from '@angular/common'; import {CompilerConfig, NgModuleResolver, ViewResolver} from '@angular/compiler'; import {MockNgModuleResolver, MockViewResolver} from '@angular/compiler/testing'; -import {ANALYZE_FOR_PRECOMPILE, Compiler, Component, ComponentFactoryResolver, ComponentRef, ComponentResolver, DebugElement, Directive, Host, HostBinding, Inject, Injectable, Injector, Input, NgModule, NgModuleMetadata, NgModuleRef, OpaqueToken, Optional, Pipe, Provider, ReflectiveInjector, SelfMetadata, SkipSelf, SkipSelfMetadata, ViewMetadata, forwardRef, getDebugNode, provide} from '@angular/core'; +import {ANALYZE_FOR_ENTRY_COMPONENTS, Compiler, Component, ComponentFactoryResolver, ComponentRef, ComponentResolver, DebugElement, Directive, Host, HostBinding, Inject, Injectable, Injector, Input, NgModule, NgModuleMetadata, NgModuleRef, OpaqueToken, Optional, Pipe, Provider, ReflectiveInjector, SelfMetadata, SkipSelf, SkipSelfMetadata, ViewMetadata, forwardRef, getDebugNode, provide} from '@angular/core'; import {Console} from '@angular/core/src/console'; import {ComponentFixture, configureCompiler} from '@angular/core/testing'; import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal'; @@ -164,14 +164,14 @@ function declareTests({useJit}: {useJit: boolean}) { `Can't export pipe ${stringify(SomePipe)} from ${stringify(SomeModule)} as it was neither declared nor imported!`); }); - it('should error when precompiling a component that was neither declared nor imported', () => { - @NgModule({precompile: [SomeComp]}) + it('should error when using an entryComponent that was neither declared nor imported', () => { + @NgModule({entryComponents: [SomeComp]}) class SomeModule { } expect(() => createModule(SomeModule)) .toThrowError( - `NgModule ${stringify(SomeModule)} uses ${stringify(SomeComp)} via "precompile" but it was neither declared nor imported!`); + `NgModule ${stringify(SomeModule)} uses ${stringify(SomeComp)} via "entryComponents" but it was neither declared nor imported!`); }); it('should error if a directive is declared in more than 1 module', () => { @@ -238,9 +238,9 @@ function declareTests({useJit}: {useJit: boolean}) { }); - describe('precompile', function() { - it('should precompile ComponentFactories in root modules', () => { - @NgModule({declarations: [SomeComp], precompile: [SomeComp]}) + describe('entryComponents', function() { + it('should entryComponents ComponentFactories in root modules', () => { + @NgModule({declarations: [SomeComp], entryComponents: [SomeComp]}) class SomeModule { } @@ -253,11 +253,11 @@ function declareTests({useJit}: {useJit: boolean}) { .toBe(SomeComp); }); - it('should precompile ComponentFactories via ANALYZE_FOR_PRECOMPILE', () => { + it('should entryComponents ComponentFactories via ANALYZE_FOR_ENTRY_COMPONENTS', () => { @NgModule({ declarations: [SomeComp], providers: [{ - provide: ANALYZE_FOR_PRECOMPILE, + provide: ANALYZE_FOR_ENTRY_COMPONENTS, multi: true, useValue: [{a: 'b', component: SomeComp}] }] @@ -274,8 +274,8 @@ function declareTests({useJit}: {useJit: boolean}) { .toBe(SomeComp); }); - it('should precompile ComponentFactories in imported modules', () => { - @NgModule({declarations: [SomeComp], precompile: [SomeComp]}) + it('should entryComponents ComponentFactories in imported modules', () => { + @NgModule({declarations: [SomeComp], entryComponents: [SomeComp]}) class SomeImportedModule { } @@ -292,12 +292,12 @@ function declareTests({useJit}: {useJit: boolean}) { .toBe(SomeComp); }); - it('should precompile ComponentFactories if the component was imported', () => { + it('should entryComponents ComponentFactories if the component was imported', () => { @NgModule({declarations: [SomeComp], exports: [SomeComp]}) class SomeImportedModule { } - @NgModule({imports: [SomeImportedModule], precompile: [SomeComp]}) + @NgModule({imports: [SomeImportedModule], entryComponents: [SomeComp]}) class SomeModule { } @@ -317,7 +317,7 @@ function declareTests({useJit}: {useJit: boolean}) { it('should be supported in root modules', () => { @NgModule({ declarations: [CompUsingModuleDirectiveAndPipe, SomeDirective, SomePipe], - precompile: [CompUsingModuleDirectiveAndPipe] + entryComponents: [CompUsingModuleDirectiveAndPipe] }) class SomeModule { } @@ -331,7 +331,7 @@ function declareTests({useJit}: {useJit: boolean}) { it('should be supported in imported modules', () => { @NgModule({ declarations: [CompUsingModuleDirectiveAndPipe, SomeDirective, SomePipe], - precompile: [CompUsingModuleDirectiveAndPipe] + entryComponents: [CompUsingModuleDirectiveAndPipe] }) class SomeImportedModule { } @@ -360,7 +360,7 @@ function declareTests({useJit}: {useJit: boolean}) { ParentCompUsingModuleDirectiveAndPipe, CompUsingModuleDirectiveAndPipe, SomeDirective, SomePipe ], - precompile: [ParentCompUsingModuleDirectiveAndPipe] + entryComponents: [ParentCompUsingModuleDirectiveAndPipe] }) class SomeModule { } @@ -383,7 +383,7 @@ function declareTests({useJit}: {useJit: boolean}) { @NgModule({ declarations: [ParentCompUsingModuleDirectiveAndPipe], - precompile: [ParentCompUsingModuleDirectiveAndPipe] + entryComponents: [ParentCompUsingModuleDirectiveAndPipe] }) class SomeModule { } @@ -415,7 +415,7 @@ function declareTests({useJit}: {useJit: boolean}) { @NgModule({ declarations: [ParentCompUsingModuleDirectiveAndPipe], imports: [SomeImportedModule], - precompile: [ParentCompUsingModuleDirectiveAndPipe] + entryComponents: [ParentCompUsingModuleDirectiveAndPipe] }) class SomeModule { } @@ -437,7 +437,7 @@ function declareTests({useJit}: {useJit: boolean}) { @NgModule({ declarations: [CompUsingModuleDirectiveAndPipe], imports: [SomeImportedModule], - precompile: [CompUsingModuleDirectiveAndPipe] + entryComponents: [CompUsingModuleDirectiveAndPipe] }) class SomeModule { } @@ -461,7 +461,7 @@ function declareTests({useJit}: {useJit: boolean}) { @NgModule({ declarations: [CompUsingModuleDirectiveAndPipe], imports: [SomeImportedModule], - precompile: [CompUsingModuleDirectiveAndPipe] + entryComponents: [CompUsingModuleDirectiveAndPipe] }) class SomeModule { } @@ -484,7 +484,7 @@ function declareTests({useJit}: {useJit: boolean}) { @NgModule({ declarations: [CompUsingModuleDirectiveAndPipe], imports: [SomeImportedModule], - precompile: [CompUsingModuleDirectiveAndPipe] + entryComponents: [CompUsingModuleDirectiveAndPipe] }) class SomeModule { } @@ -505,7 +505,7 @@ function declareTests({useJit}: {useJit: boolean}) { @NgModule({ declarations: [CompUsingModuleDirectiveAndPipe], imports: [SomeImportedModule], - precompile: [CompUsingModuleDirectiveAndPipe] + entryComponents: [CompUsingModuleDirectiveAndPipe] }) class SomeModule { } @@ -524,7 +524,7 @@ function declareTests({useJit}: {useJit: boolean}) { @NgModule({ declarations: [CompUsingModuleDirectiveAndPipe, SomePipe], imports: [SomeImportedModule], - precompile: [CompUsingModuleDirectiveAndPipe] + entryComponents: [CompUsingModuleDirectiveAndPipe] }) class SomeModule { } diff --git a/modules/@angular/core/testing/test_bed.ts b/modules/@angular/core/testing/test_bed.ts index 2190dacc34..d3c69553d9 100644 --- a/modules/@angular/core/testing/test_bed.ts +++ b/modules/@angular/core/testing/test_bed.ts @@ -30,7 +30,7 @@ export class TestBed implements Injector { private _providers: Array = []; private _declarations: Array = []; private _imports: Array = []; - private _precompile: Array = []; + private _entryComponents: Array = []; reset() { this._compiler = null; @@ -40,7 +40,7 @@ export class TestBed implements Injector { this._providers = []; this._declarations = []; this._imports = []; - this._precompile = []; + this._entryComponents = []; this._instantiated = false; } @@ -56,7 +56,8 @@ export class TestBed implements Injector { } configureModule( - moduleDef: {providers?: any[], declarations?: any[], imports?: any[], precompile?: any[]}) { + moduleDef: + {providers?: any[], declarations?: any[], imports?: any[], entryComponents?: any[]}) { if (this._instantiated) { throw new BaseException('Cannot add configuration after test injector is instantiated'); } @@ -69,16 +70,16 @@ export class TestBed implements Injector { if (moduleDef.imports) { this._imports = ListWrapper.concat(this._imports, moduleDef.imports); } - if (moduleDef.precompile) { - this._precompile = ListWrapper.concat(this._precompile, moduleDef.precompile); + if (moduleDef.entryComponents) { + this._entryComponents = ListWrapper.concat(this._entryComponents, moduleDef.entryComponents); } } createModuleFactory(): Promise> { if (this._instantiated) { throw new BaseException( - 'Cannot run precompilation when the test NgModule has already been instantiated. ' + - 'Make sure you are not using `inject` before `doAsyncPrecompilation`.'); + 'Cannot compile entryComponents when the test NgModule has already been instantiated. ' + + 'Make sure you are not using `inject` before `doAsyncEntryPointCompilation`.'); } if (this._ngModuleFactory) { @@ -122,13 +123,13 @@ export class TestBed implements Injector { const providers = this._providers.concat([{provide: TestBed, useValue: this}]); const declarations = this._declarations; const imports = [this.ngModule, this._imports]; - const precompile = this._precompile; + const entryComponents = this._entryComponents; @NgModule({ providers: providers, declarations: declarations, imports: imports, - precompile: precompile + entryComponents: entryComponents }) class DynamicTestModule { } @@ -258,13 +259,13 @@ export function resetTestEnvironment() { } /** - * Run asynchronous precompilation for the test's NgModule. It is necessary to call this function - * if your test is using an NgModule which has precompiled components that require an asynchronous - * call, such as an XHR. Should be called once before the test case. + * Compile entryComponents with a `templateUrl` for the test's NgModule. + * It is necessary to call this function + * as fetching urls is asynchronous. * * @experimental */ -export function doAsyncPrecompilation(): Promise { +export function doAsyncEntryPointCompilation(): Promise { let testBed = getTestBed(); return testBed.createModuleFactory(); } @@ -312,8 +313,8 @@ export function inject(tokens: any[], fn: Function): () => any { } catch (e) { if (e instanceof ComponentStillLoadingError) { throw new Error( - `This test module precompiles the component ${stringify(e.compType)} which is using a "templateUrl", but precompilation was never done. ` + - `Please call "doAsyncPrecompilation" before "inject".`); + `This test module uses the entryComponents ${stringify(e.compType)} which is using a "templateUrl", but they were never compiled. ` + + `Please call "doAsyncEntryPointCompilation" before "inject".`); } else { throw e; } @@ -327,9 +328,12 @@ export function inject(tokens: any[], fn: Function): () => any { * @experimental */ export class InjectSetupWrapper { - constructor( - private _moduleDef: - () => {providers?: any[], declarations?: any[], imports?: any[], precompile?: any[]}) {} + constructor(private _moduleDef: () => { + providers?: any[], + declarations?: any[], + imports?: any[], + entryComponents?: any[] + }) {} private _addModule() { var moduleDef = this._moduleDef(); @@ -360,7 +364,7 @@ export function withModule(moduleDef: () => { providers?: any[], declarations?: any[], imports?: any[], - precompile?: any[] + entryComponents?: any[] }) { return new InjectSetupWrapper(moduleDef); } diff --git a/modules/@angular/core/testing/testing.ts b/modules/@angular/core/testing/testing.ts index ebc293820f..ce1194eef5 100644 --- a/modules/@angular/core/testing/testing.ts +++ b/modules/@angular/core/testing/testing.ts @@ -50,7 +50,7 @@ export function addProviders(providers: Array): void { * @stable */ export function configureModule( - moduleDef: {providers?: any[], declarations?: any[], imports?: any[], precompile?: any[]}): + moduleDef: {providers?: any[], declarations?: any[], imports?: any[], entryComponents?: any[]}): void { if (!moduleDef) return; try { diff --git a/modules/@angular/platform-browser-dynamic/index.ts b/modules/@angular/platform-browser-dynamic/index.ts index 07f538f1d7..44b8f68f95 100644 --- a/modules/@angular/platform-browser-dynamic/index.ts +++ b/modules/@angular/platform-browser-dynamic/index.ts @@ -106,7 +106,7 @@ export const browserDynamicPlatform = createPlatformFactory( * ## API (version 2) * - `appComponentType`: The root component which should act as the application. This is * a reference to a `Type` which is annotated with `@Component(...)`. - * - `providers`, `declarations`, `imports`, `precompile`: Defines the properties + * - `providers`, `declarations`, `imports`, `entryComponents`: Defines the properties * of the dynamically created module that is used to bootstrap the module. * - to configure the compiler, use the `compilerOptions` parameter. * @@ -121,11 +121,11 @@ export function bootstrap( customProviders?: Array): Promise>; export function bootstrap( appComponentType: ConcreteType, - {providers, imports, declarations, precompile, compilerOptions}?: { + {providers, imports, declarations, entryComponents, compilerOptions}?: { providers?: Array, declarations?: any[], imports?: any[], - precompile?: any[], + entryComponents?: any[], compilerOptions?: CompilerOptions }): Promise>; export function bootstrap( @@ -134,14 +134,14 @@ export function bootstrap( providers: Array, declarations?: any[], imports: any[], - precompile: any[], + entryComponents: any[], compilerOptions: CompilerOptions }): Promise> { let compilerOptions: CompilerOptions; let providers: any[] = []; let declarations: any[] = []; let imports: any[] = []; - let precompile: any[] = []; + let entryComponents: any[] = []; let deprecationMessages: string[] = []; if (customProvidersOrDynamicModule instanceof Array) { providers = customProvidersOrDynamicModule; @@ -153,7 +153,7 @@ export function bootstrap( providers = normalizeArray(customProvidersOrDynamicModule.providers); declarations = normalizeArray(customProvidersOrDynamicModule.declarations); imports = normalizeArray(customProvidersOrDynamicModule.imports); - precompile = normalizeArray(customProvidersOrDynamicModule.precompile); + entryComponents = normalizeArray(customProvidersOrDynamicModule.entryComponents); compilerOptions = customProvidersOrDynamicModule.compilerOptions; } @@ -161,7 +161,7 @@ export function bootstrap( providers: providers, declarations: declarations.concat([appComponentType]), imports: [BrowserModule, imports], - precompile: precompile.concat([appComponentType]) + entryComponents: entryComponents.concat([appComponentType]) }) class DynamicModule { } @@ -218,7 +218,7 @@ export function bootstrapWorkerApp( providers: customProviders, declarations: declarations, imports: [WorkerAppModule], - precompile: [appComponentType] + entryComponents: [appComponentType] }) class DynamicModule { } diff --git a/modules/@angular/platform-browser/test/testing_public_spec.ts b/modules/@angular/platform-browser/test/testing_public_spec.ts index 1af3ee6bae..67e2037681 100644 --- a/modules/@angular/platform-browser/test/testing_public_spec.ts +++ b/modules/@angular/platform-browser/test/testing_public_spec.ts @@ -9,7 +9,7 @@ import {NgIf} from '@angular/common'; import {CompilerConfig, XHR} from '@angular/compiler'; import {Component, ComponentFactoryResolver, Directive, Injectable, Input, NgModule, Pipe, ViewMetadata, provide} from '@angular/core'; -import {TestComponentBuilder, addProviders, async, configureCompiler, configureModule, doAsyncPrecompilation, fakeAsync, inject, tick, withModule, withProviders} from '@angular/core/testing'; +import {TestComponentBuilder, addProviders, async, configureCompiler, configureModule, doAsyncEntryPointCompilation, fakeAsync, inject, tick, withModule, withProviders} from '@angular/core/testing'; import {expect} from '@angular/platform-browser/testing/matchers'; import {stringify} from '../../http/src/facade/lang'; @@ -235,7 +235,7 @@ export function main() { providers: [FancyService], imports: [SomeLibModule], declarations: [SomeDirective, SomePipe, CompUsingModuleDirectiveAndPipe], - precompile: [CompUsingModuleDirectiveAndPipe] + entryComponents: [CompUsingModuleDirectiveAndPipe] }; }); @@ -260,7 +260,7 @@ export function main() { expect(libModule).toBeAnInstanceOf(SomeLibModule); })); - it('should use set up precompile components', + it('should use set up entryComponents components', inject([ComponentFactoryResolver], (resolver: ComponentFactoryResolver) => { expect(resolver.resolveComponentFactory(CompUsingModuleDirectiveAndPipe).componentType) .toBe(CompUsingModuleDirectiveAndPipe); @@ -288,7 +288,7 @@ export function main() { expect(libModule).toBeAnInstanceOf(SomeLibModule); })); - it('should use set up precompile components', + it('should use set up entryComponents components', withModule(() => moduleConfig) .inject([ComponentFactoryResolver], (resolver: ComponentFactoryResolver) => { expect( @@ -297,13 +297,14 @@ export function main() { })); }); - describe('precompile components with template url', () => { + describe('entryComponents components with template url', () => { beforeEach(async(() => { - configureModule({declarations: [CompWithUrlTemplate], precompile: [CompWithUrlTemplate]}); - doAsyncPrecompilation(); + configureModule( + {declarations: [CompWithUrlTemplate], entryComponents: [CompWithUrlTemplate]}); + doAsyncEntryPointCompilation(); })); - it('should allow to createSync components with templateUrl after async precompilation', + it('should allow to createSync components with templateUrl after explicit async compilation', inject([TestComponentBuilder], (builder: TestComponentBuilder) => { let fixture = builder.createSync(CompWithUrlTemplate); expect(fixture.nativeElement).toHaveText('from external template\n'); @@ -434,14 +435,14 @@ export function main() { }); }); - describe('precompile', () => { + describe('entryComponents', () => { let xhrGet: jasmine.Spy; beforeEach(() => { xhrGet = jasmine.createSpy('xhrGet').and.returnValue(Promise.resolve('Hello world!')); configureCompiler({providers: [{provide: XHR, useValue: {get: xhrGet}}]}); }); - it('should report an error for precompile components with templateUrl which never call doAsyncPrecompile', + it('should report an error for entryComponents components with templateUrl which never call doAsyncEntryComponents', () => { var itPromise = patchJasmineIt(); @@ -451,7 +452,7 @@ export function main() { withModule(() => { return { declarations: [CompWithUrlTemplate], - precompile: [CompWithUrlTemplate] + entryComponents: [CompWithUrlTemplate] }; }) .inject( @@ -462,8 +463,8 @@ export function main() { .toBe(CompWithUrlTemplate); }))) .toThrowError( - `This test module precompiles the component ${stringify(CompWithUrlTemplate)} which is using a "templateUrl", but precompilation was never done. ` + - 'Please call "doAsyncPrecompilation" before "inject".'); + `This test module uses the entryComponents ${stringify(CompWithUrlTemplate)} which is using a "templateUrl", but they were never compiled. ` + + `Please call "doAsyncEntryPointCompilation" before "inject".`); restoreJasmineIt(); }); diff --git a/modules/@angular/platform-server/src/server.ts b/modules/@angular/platform-server/src/server.ts index 82c5449ebb..a92496c4ab 100644 --- a/modules/@angular/platform-server/src/server.ts +++ b/modules/@angular/platform-server/src/server.ts @@ -100,7 +100,7 @@ export function serverBootstrap( providers: customProviders, declarations: declarations, imports: [BrowserModule], - precompile: [appComponentType] + entryComponents: [appComponentType] }) class DynamicModule { } diff --git a/modules/@angular/router/src/common_router_providers.ts b/modules/@angular/router/src/common_router_providers.ts index 290c8b2423..095e63a1e6 100644 --- a/modules/@angular/router/src/common_router_providers.ts +++ b/modules/@angular/router/src/common_router_providers.ts @@ -7,7 +7,7 @@ */ import {Location, LocationStrategy, PathLocationStrategy} from '@angular/common'; -import {ANALYZE_FOR_PRECOMPILE, APP_INITIALIZER, ApplicationRef, ComponentResolver, Injector, NgModuleFactoryLoader, OpaqueToken, SystemJsNgModuleLoader} from '@angular/core'; +import {ANALYZE_FOR_ENTRY_COMPONENTS, APP_INITIALIZER, ApplicationRef, ComponentResolver, Injector, NgModuleFactoryLoader, OpaqueToken, SystemJsNgModuleLoader} from '@angular/core'; import {Routes} from './config'; import {Router} from './router'; @@ -88,7 +88,7 @@ export function setupRouterInitializer(injector: Injector) { */ export function provideRouter(routes: Routes, config: ExtraOptions): any[] { return [ - {provide: ANALYZE_FOR_PRECOMPILE, multi: true, useValue: routes}, + {provide: ANALYZE_FOR_ENTRY_COMPONENTS, multi: true, useValue: routes}, {provide: ROUTES, useExisting: ROUTER_CONFIG}, {provide: ROUTER_CONFIG, useValue: routes}, {provide: ROUTER_CONFIGURATION, useValue: config}, Location, @@ -130,7 +130,7 @@ export function provideRouter(routes: Routes, config: ExtraOptions): any[] { */ export function provideRoutes(routes: Routes): any { return [ - {provide: ANALYZE_FOR_PRECOMPILE, multi: true, useValue: routes}, + {provide: ANALYZE_FOR_ENTRY_COMPONENTS, multi: true, useValue: routes}, {provide: ROUTES, useValue: routes} ]; } diff --git a/modules/@angular/router/src/directives/router_outlet.ts b/modules/@angular/router/src/directives/router_outlet.ts index 48fa44b4ed..2d32b4ea96 100644 --- a/modules/@angular/router/src/directives/router_outlet.ts +++ b/modules/@angular/router/src/directives/router_outlet.ts @@ -94,9 +94,9 @@ export class RouterOutlet { if (!(e instanceof NoComponentFactoryError)) throw e; const componentName = component ? component.name : null; console.warn( - `'${componentName}' not found in precompile array. To ensure all components referred + `'${componentName}' not found in entryComponents array. To ensure all components referred to by the Routes are compiled, you must add '${componentName}' to the - 'precompile' array of your application component. This will be required in a future + 'entryComponents' array of your application component. This will be required in a future release of the router.`); factory = snapshot._resolvedComponentFactory; } diff --git a/modules/@angular/router/test/router.spec.ts b/modules/@angular/router/test/router.spec.ts index 1343f5da97..3aaed823cc 100644 --- a/modules/@angular/router/test/router.spec.ts +++ b/modules/@angular/router/test/router.spec.ts @@ -1326,7 +1326,7 @@ describe('Integration', () => { children: [{path: 'child', component: ChildLazyLoadedComponent}] }])], imports: [RouterModuleWithoutProviders], - precompile: [ParentLazyLoadedComponent, ChildLazyLoadedComponent] + entryComponents: [ParentLazyLoadedComponent, ChildLazyLoadedComponent] }) class LoadedModule { } @@ -1359,7 +1359,7 @@ describe('Integration', () => { } @NgModule({ - precompile: [LazyLoadedComponent], + entryComponents: [LazyLoadedComponent], declarations: [LazyLoadedComponent], imports: [RouterModuleWithoutProviders], providers: [ @@ -1558,7 +1558,7 @@ class RouteCmp { template: ` `, directives: ROUTER_DIRECTIVES, - precompile: [BlankCmp, SimpleCmp] + entryComponents: [BlankCmp, SimpleCmp] }) class RelativeLinkInIfCmp { show: boolean = false; @@ -1613,7 +1613,7 @@ class ComponentRecordingRoutePathAndUrl { selector: 'root-cmp', template: ``, directives: [ROUTER_DIRECTIVES], - precompile: [ + entryComponents: [ BlankCmp, SimpleCmp, TeamCmp, UserCmp, StringLinkCmp, DummyLinkCmp, AbsoluteLinkCmp, RelativeLinkCmp, DummyLinkWithParentCmp, LinkWithQueryParamsAndFragment, CollectParamsCmp, QueryParamsAndFragmentCmp, StringLinkButtonCmp, WrapperCmp, LinkInNgIf, @@ -1628,7 +1628,7 @@ class RootCmp { template: `primary [] right []`, directives: [ROUTER_DIRECTIVES], - precompile: [BlankCmp, SimpleCmp, RouteCmp, UserCmp] + entryComponents: [BlankCmp, SimpleCmp, RouteCmp, UserCmp] }) class RootCmpWithTwoOutlets { } diff --git a/modules/playground/src/web_workers/router/index_common.ts b/modules/playground/src/web_workers/router/index_common.ts index dd21fec18b..c36ec31f26 100644 --- a/modules/playground/src/web_workers/router/index_common.ts +++ b/modules/playground/src/web_workers/router/index_common.ts @@ -31,7 +31,7 @@ export const ROUTES = [ @NgModule({ imports: [WorkerAppModule, RouterModule], providers: [provideRoutes(ROUTES), WORKER_APP_LOCATION_PROVIDERS, {provide: LocationStrategy, useClass: HashLocationStrategy}], - precompile: [App], + entryComponents: [App], declarations: [App, Start, Contact, About] }) export class AppModule {