refactor(core): rename precompile into entryComponents.

Part of #10043

BREAKING CHANGE:
- `@Component.precompile` was renamed to `@Component.entryComponents`
  (old property still works but is deprecated)
- `ANALYZE_FOR_PRECOMPILE` was renamed to `ANALYZE_FOR_ENTRY_COMPONENTS` (no deprecations)
This commit is contained in:
Tobias Bosch
2016-07-25 00:36:30 -07:00
parent 46b212706b
commit 6f4e49ed53
37 changed files with 296 additions and 294 deletions

View File

@ -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}
];
}

View File

@ -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;
}

View File

@ -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:
`<div *ngIf="show"><a [routerLink]="['./simple']">link</a></div> <router-outlet></router-outlet>`,
directives: ROUTER_DIRECTIVES,
precompile: [BlankCmp, SimpleCmp]
entryComponents: [BlankCmp, SimpleCmp]
})
class RelativeLinkInIfCmp {
show: boolean = false;
@ -1613,7 +1613,7 @@ class ComponentRecordingRoutePathAndUrl {
selector: 'root-cmp',
template: `<router-outlet></router-outlet>`,
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 [<router-outlet></router-outlet>] right [<router-outlet name="right"></router-outlet>]`,
directives: [ROUTER_DIRECTIVES],
precompile: [BlankCmp, SimpleCmp, RouteCmp, UserCmp]
entryComponents: [BlankCmp, SimpleCmp, RouteCmp, UserCmp]
})
class RootCmpWithTwoOutlets {
}