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:
@ -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 {
|
||||
}
|
@ -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 {
|
||||
}
|
||||
|
Reference in New Issue
Block a user