diff --git a/modules/@angular/compiler/src/metadata_resolver.ts b/modules/@angular/compiler/src/metadata_resolver.ts index 6651227537..1e36b659c7 100644 --- a/modules/@angular/compiler/src/metadata_resolver.ts +++ b/modules/@angular/compiler/src/metadata_resolver.ts @@ -388,11 +388,8 @@ export class CompileMetadataResolver { }); moduleMeta.entryComponents.forEach((entryComponentType) => { if (!moduleMeta.transitiveModule.directivesSet.has(entryComponentType.runtime)) { - this._addDirectiveToModule( - this.getDirectiveMetadata(entryComponentType.runtime), moduleMeta.type.runtime, - moduleMeta.transitiveModule, moduleMeta.declaredDirectives); - this._console.warn( - `NgModule ${stringify(moduleMeta.type.runtime)} uses ${stringify(entryComponentType.runtime)} via "entryComponents" but it was neither declared nor imported! This warning will become an error after final.`); + throw new BaseException( + `NgModule ${stringify(moduleMeta.type.runtime)} uses ${stringify(entryComponentType.runtime)} via "entryComponents" but it was neither declared nor imported! If ${stringify(entryComponentType.runtime)} is declared in an imported module, make sure it is exported.`); } }); // Collect @Component.directives/pipes/entryComponents into our declared 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 27544f023f..c778e56aa4 100644 --- a/modules/@angular/core/test/linker/ng_module_integration_spec.ts +++ b/modules/@angular/core/test/linker/ng_module_integration_spec.ts @@ -263,27 +263,19 @@ function declareTests({useJit}: {useJit: boolean}) { .toBe(SomeComp); }); - it('should warn and auto declare when using an entryComponent that was neither declared nor imported', - () => { - @Component({template: '', entryComponents: [SomeComp]}) - class SomeCompWithEntryComponents { - } + it('should throw when using an entryComponent that was neither declared nor imported', () => { + @Component({template: '', entryComponents: [SomeComp]}) + class SomeCompWithEntryComponents { + } - @NgModule({entryComponents: [SomeCompWithEntryComponents]}) - class SomeModule { - } + @NgModule({entryComponents: [SomeCompWithEntryComponents]}) + class SomeModule { + } - const ngModule = createModule(SomeModule); - expect(ngModule.componentFactoryResolver - .resolveComponentFactory(SomeCompWithEntryComponents) - .componentType) - .toBe(SomeCompWithEntryComponents); - - expect(console.warnings).toEqual([ - `NgModule ${stringify(SomeModule)} uses ${stringify(SomeCompWithEntryComponents)} via "entryComponents" but it was neither declared nor imported! This warning will become an error after final.`, - `Component ${stringify(SomeCompWithEntryComponents)} in NgModule ${stringify(SomeModule)} uses ${stringify(SomeComp)} via "entryComponents" but it was neither declared nor imported into the module! This warning will become an error after final.` - ]); - }); + expect(() => createModule(SomeModule)) + .toThrowError( + `NgModule ${stringify(SomeModule)} uses ${stringify(SomeCompWithEntryComponents)} via "entryComponents" but it was neither declared nor imported! If ${stringify(SomeCompWithEntryComponents)} is declared in an imported module, make sure it is exported.`); + }); it('should create ComponentFactories via ANALYZE_FOR_ENTRY_COMPONENTS', () => { @NgModule({ diff --git a/modules/@angular/platform-server/test/integration_spec.ts b/modules/@angular/platform-server/test/integration_spec.ts index 1cb4c3e866..b9bc950859 100644 --- a/modules/@angular/platform-server/test/integration_spec.ts +++ b/modules/@angular/platform-server/test/integration_spec.ts @@ -24,7 +24,7 @@ function writeBody(html: string): any { class MyServerApp { } -@NgModule({imports: [ServerModule], bootstrap: [MyServerApp]}) +@NgModule({imports: [ServerModule], declarations: [MyServerApp], bootstrap: [MyServerApp]}) class ExampleModule { } diff --git a/modules/playground/src/animate/index.ts b/modules/playground/src/animate/index.ts index 6eb5a4b403..2922c3a8ec 100644 --- a/modules/playground/src/animate/index.ts +++ b/modules/playground/src/animate/index.ts @@ -11,7 +11,7 @@ import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; import {AnimateApp} from './app/animate-app'; -@NgModule({bootstrap: [AnimateApp], imports: [BrowserModule]}) +@NgModule({declarations: [AnimateApp], bootstrap: [AnimateApp], imports: [BrowserModule]}) class ExampleModule { } diff --git a/modules/playground/src/async/index.ts b/modules/playground/src/async/index.ts index 5ff909c5aa..704d64e0b3 100644 --- a/modules/playground/src/async/index.ts +++ b/modules/playground/src/async/index.ts @@ -98,7 +98,8 @@ class AsyncApplication { }; } -@NgModule({bootstrap: [AsyncApplication], imports: [BrowserModule]}) +@NgModule( + {declarations: [AsyncApplication], bootstrap: [AsyncApplication], imports: [BrowserModule]}) class ExampleModule { } diff --git a/modules/playground/src/gestures/index.ts b/modules/playground/src/gestures/index.ts index 75d99c486a..ef46377849 100644 --- a/modules/playground/src/gestures/index.ts +++ b/modules/playground/src/gestures/index.ts @@ -25,7 +25,7 @@ class GesturesCmp { onRotate(event: any /** TODO #9100 */): void { this.rotateAngle = event.rotation; } } -@NgModule({bootstrap: [GesturesCmp], imports: [BrowserModule]}) +@NgModule({declarations: [GesturesCmp], bootstrap: [GesturesCmp], imports: [BrowserModule]}) class ExampleModule { } diff --git a/modules/playground/src/hello_world/index.ts b/modules/playground/src/hello_world/index.ts index eeac72923a..80eeadae4d 100644 --- a/modules/playground/src/hello_world/index.ts +++ b/modules/playground/src/hello_world/index.ts @@ -57,6 +57,6 @@ export class HelloCmp { changeGreeting(): void { this.greeting = 'howdy'; } } -@NgModule({bootstrap: [HelloCmp], declarations: [RedDec], imports: [BrowserModule]}) +@NgModule({bootstrap: [HelloCmp], declarations: [HelloCmp, RedDec], imports: [BrowserModule]}) class ExampleModule { } diff --git a/modules/playground/src/http/index.ts b/modules/playground/src/http/index.ts index 7b46efcd8b..9fbc084118 100644 --- a/modules/playground/src/http/index.ts +++ b/modules/playground/src/http/index.ts @@ -13,7 +13,7 @@ import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; import {HttpCmp} from './app/http_comp'; -@NgModule({bootstrap: [HttpCmp], imports: [BrowserModule, HttpModule]}) +@NgModule({declarations: [HttpCmp], bootstrap: [HttpCmp], imports: [BrowserModule, HttpModule]}) class ExampleModule { } diff --git a/modules/playground/src/key_events/index.ts b/modules/playground/src/key_events/index.ts index 99756e24f6..bc93619431 100644 --- a/modules/playground/src/key_events/index.ts +++ b/modules/playground/src/key_events/index.ts @@ -41,7 +41,7 @@ class KeyEventsApp { resetShiftEnter(): void { this.shiftEnter = false; } } -@NgModule({bootstrap: [KeyEventsApp], imports: [BrowserModule]}) +@NgModule({declarations: [KeyEventsApp], bootstrap: [KeyEventsApp], imports: [BrowserModule]}) class ExampleModule { } diff --git a/modules/playground/src/model_driven_forms/index.ts b/modules/playground/src/model_driven_forms/index.ts index 6f4c8987af..28b0d6ea88 100644 --- a/modules/playground/src/model_driven_forms/index.ts +++ b/modules/playground/src/model_driven_forms/index.ts @@ -158,7 +158,7 @@ class ReactiveForms { @NgModule({ bootstrap: [ReactiveForms], - declarations: [ShowError], + declarations: [ReactiveForms, ShowError], imports: [BrowserModule, ReactiveFormsModule] }) class ExampleModule { diff --git a/modules/playground/src/order_management/index.ts b/modules/playground/src/order_management/index.ts index 67910411e0..47d472d83c 100644 --- a/modules/playground/src/order_management/index.ts +++ b/modules/playground/src/order_management/index.ts @@ -197,7 +197,8 @@ class OrderManagementApplication { @NgModule({ bootstrap: [OrderManagementApplication], - declarations: [OrderListComponent, OrderDetailsComponent, OrderItemComponent], + declarations: + [OrderManagementApplication, OrderListComponent, OrderDetailsComponent, OrderItemComponent], imports: [BrowserModule, FormsModule] }) class ExampleModule { diff --git a/modules/playground/src/person_management/index.ts b/modules/playground/src/person_management/index.ts index 371f9071e4..4e156bc140 100644 --- a/modules/playground/src/person_management/index.ts +++ b/modules/playground/src/person_management/index.ts @@ -198,7 +198,8 @@ class PersonManagementApplication { @NgModule({ bootstrap: [PersonManagementApplication], - declarations: [FullNameComponent, PersonsComponent, PersonsDetailComponent], + declarations: + [PersonManagementApplication, FullNameComponent, PersonsComponent, PersonsDetailComponent], imports: [BrowserModule, FormsModule] }) class ExampleModule { diff --git a/modules/playground/src/relative_assets/index.ts b/modules/playground/src/relative_assets/index.ts index 55e3335eb3..25caced54f 100644 --- a/modules/playground/src/relative_assets/index.ts +++ b/modules/playground/src/relative_assets/index.ts @@ -24,6 +24,6 @@ export function main() { export class RelativeApp { } -@NgModule({bootstrap: [RelativeApp], imports: [BrowserModule]}) +@NgModule({declarations: [RelativeApp], bootstrap: [RelativeApp], imports: [BrowserModule]}) class ExampleModule { } diff --git a/modules/playground/src/sourcemap/index.ts b/modules/playground/src/sourcemap/index.ts index a640b30335..994cf84f02 100644 --- a/modules/playground/src/sourcemap/index.ts +++ b/modules/playground/src/sourcemap/index.ts @@ -20,7 +20,7 @@ export class ErrorComponent { createError(): void { throw new BaseException('Sourcemap test'); } } -@NgModule({bootstrap: [ErrorComponent], imports: [BrowserModule]}) +@NgModule({declarations: [ErrorComponent], bootstrap: [ErrorComponent], imports: [BrowserModule]}) class ExampleModule { } diff --git a/modules/playground/src/svg/index.ts b/modules/playground/src/svg/index.ts index a576ba2496..82fa5bcc48 100644 --- a/modules/playground/src/svg/index.ts +++ b/modules/playground/src/svg/index.ts @@ -23,7 +23,7 @@ class SvgGroup { class SvgApp { } -@NgModule({bootstrap: [SvgApp], declarations: [SvgGroup], imports: [BrowserModule]}) +@NgModule({bootstrap: [SvgApp], declarations: [SvgApp, SvgGroup], imports: [BrowserModule]}) class ExampleModule { } diff --git a/modules/playground/src/template_driven_forms/index.ts b/modules/playground/src/template_driven_forms/index.ts index 5111902989..6d8eb2932e 100644 --- a/modules/playground/src/template_driven_forms/index.ts +++ b/modules/playground/src/template_driven_forms/index.ts @@ -169,7 +169,11 @@ class TemplateDrivenForms { print(this.model); } } -@NgModule({bootstrap: [TemplateDrivenForms], imports: [BrowserModule]}) +@NgModule({ + declarations: [TemplateDrivenForms], + bootstrap: [TemplateDrivenForms], + imports: [BrowserModule] +}) class ExampleModule { } diff --git a/modules/playground/src/todo/index.ts b/modules/playground/src/todo/index.ts index 246a6f9470..dced700078 100644 --- a/modules/playground/src/todo/index.ts +++ b/modules/playground/src/todo/index.ts @@ -51,7 +51,7 @@ class TodoApp { clearCompleted(): void { this.todoStore.removeBy((todo: Todo) => todo.completed); } } -@NgModule({bootstrap: [TodoApp], imports: [BrowserModule]}) +@NgModule({declarations: [TodoApp], bootstrap: [TodoApp], imports: [BrowserModule]}) class ExampleModule { } diff --git a/modules/playground/src/web_workers/images/background_index.ts b/modules/playground/src/web_workers/images/background_index.ts index aba2285db2..51dcd5e9af 100644 --- a/modules/playground/src/web_workers/images/background_index.ts +++ b/modules/playground/src/web_workers/images/background_index.ts @@ -12,7 +12,7 @@ import {platformWorkerAppDynamic} from '@angular/platform-browser-dynamic'; import {ImageDemo} from './index_common'; -@NgModule({imports: [WorkerAppModule], bootstrap: [ImageDemo]}) +@NgModule({imports: [WorkerAppModule], bootstrap: [ImageDemo], declarations: [ImageDemo]}) class ExampleModule { } diff --git a/modules/playground/src/web_workers/input/background_index.ts b/modules/playground/src/web_workers/input/background_index.ts index b368d53e79..55f4af4200 100644 --- a/modules/playground/src/web_workers/input/background_index.ts +++ b/modules/playground/src/web_workers/input/background_index.ts @@ -12,7 +12,7 @@ import {platformWorkerAppDynamic} from '@angular/platform-browser-dynamic'; import {InputCmp} from './index_common'; -@NgModule({imports: [WorkerAppModule], bootstrap: [InputCmp]}) +@NgModule({imports: [WorkerAppModule], bootstrap: [InputCmp], declarations: [InputCmp]}) class ExampleModule { } diff --git a/modules/playground/src/web_workers/kitchen_sink/background_index.ts b/modules/playground/src/web_workers/kitchen_sink/background_index.ts index 4ff96794e5..88fa3117ab 100644 --- a/modules/playground/src/web_workers/kitchen_sink/background_index.ts +++ b/modules/playground/src/web_workers/kitchen_sink/background_index.ts @@ -12,7 +12,7 @@ import {platformWorkerAppDynamic} from '@angular/platform-browser-dynamic'; import {HelloCmp} from './index_common'; -@NgModule({imports: [WorkerAppModule], bootstrap: [HelloCmp]}) +@NgModule({imports: [WorkerAppModule], bootstrap: [HelloCmp], declarations: [HelloCmp]}) class ExampleModule { } diff --git a/modules/playground/src/web_workers/message_broker/background_index.ts b/modules/playground/src/web_workers/message_broker/background_index.ts index 87b08aca9f..41368a231d 100644 --- a/modules/playground/src/web_workers/message_broker/background_index.ts +++ b/modules/playground/src/web_workers/message_broker/background_index.ts @@ -12,7 +12,7 @@ import {platformWorkerAppDynamic} from '@angular/platform-browser-dynamic'; import {App} from './index_common'; -@NgModule({imports: [WorkerAppModule], bootstrap: [App]}) +@NgModule({imports: [WorkerAppModule], bootstrap: [App], declarations: [App]}) class ExampleModule { } diff --git a/modules/playground/src/web_workers/todo/background_index.ts b/modules/playground/src/web_workers/todo/background_index.ts index 2a3bc98852..167c6e0e3d 100644 --- a/modules/playground/src/web_workers/todo/background_index.ts +++ b/modules/playground/src/web_workers/todo/background_index.ts @@ -12,7 +12,7 @@ import {platformWorkerAppDynamic} from '@angular/platform-browser-dynamic'; import {TodoApp} from './index_common'; -@NgModule({imports: [WorkerAppModule], bootstrap: [TodoApp]}) +@NgModule({imports: [WorkerAppModule], bootstrap: [TodoApp], declarations: [TodoApp]}) class ExampleModule { } diff --git a/modules/playground/src/zippy_component/index.ts b/modules/playground/src/zippy_component/index.ts index da6b225811..44f1cccd53 100644 --- a/modules/playground/src/zippy_component/index.ts +++ b/modules/playground/src/zippy_component/index.ts @@ -30,7 +30,7 @@ class ZippyApp { pushLog(log: string) { this.logs.push(log); } } -@NgModule({bootstrap: [ZippyApp], imports: [BrowserModule]}) +@NgModule({declarations: [ZippyApp], bootstrap: [ZippyApp], imports: [BrowserModule]}) class ExampleModule { } diff --git a/modules/rollup-test/hello_world.ts b/modules/rollup-test/hello_world.ts index d36a67e823..832361d203 100644 --- a/modules/rollup-test/hello_world.ts +++ b/modules/rollup-test/hello_world.ts @@ -15,6 +15,7 @@ class HelloWorldComponent { } @NgModule({ + declarations: [HelloWorldComponent], bootstrap: [HelloWorldComponent], imports: [BrowserModule] })