From 1799f621b7773d41d5d3f74746cd01b44a492a1b Mon Sep 17 00:00:00 2001 From: crisbeto Date: Fri, 18 Oct 2019 20:48:37 +0200 Subject: [PATCH] refactor(core): deprecate entryComponents (#33205) With Ivy the `entryComponents` array isn't necessary anymore. These changes mark it as deprecated so that it can be removed in a future version. PR Close #33205 --- aio/content/guide/deprecations.md | 6 ++++++ packages/core/src/metadata/di.ts | 1 + packages/core/src/metadata/directives.ts | 1 + packages/core/src/metadata/ng_module.ts | 1 + tools/public_api_guard/core/core.d.ts | 5 +++-- 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/aio/content/guide/deprecations.md b/aio/content/guide/deprecations.md index d7e5d0f3a4..2e9cb96e66 100644 --- a/aio/content/guide/deprecations.md +++ b/aio/content/guide/deprecations.md @@ -82,6 +82,8 @@ Tip: In the [API reference section](api) of this doc site, deprecated APIs are i | [`wtfStartTimeRange`](api/core/wtfStartTimeRange) | none | v8 | See [Web Tracing Framework](#wtf) | | [`wtfEndTimeRange`](api/core/wtfEndTimeRange) | none | v8 | See [Web Tracing Framework](#wtf) | | [`wtfLeave`](api/core/wtfLeave) | none | v8 | See [Web Tracing Framework](#wtf) | +| [`entryComponents`](api/core/NgModule#entryComponents) | none | v9 | See [`entryComponents`](#entryComponents) | +| [`ANALYZE_FOR_ENTRY_COMPONENTS`](api/core/ANALYZE_FOR_ENTRY_COMPONENTS) | none | v9 | See [`ANALYZE_FOR_ENTRY_COMPONENTS`](#entryComponents) | {@a forms} @@ -318,6 +320,10 @@ As of Angular version 8, all `platform-webworker` APIs are deprecated. This includes both packages: `@angular/platform-webworker` and `@angular/platform-webworker-dynamic`. +{@a entryComponents} +### `entryComponents` and `ANALYZE_FOR_ENTRY_COMPONENTS` no longer required +Previously, the `entryComponents` array in the `NgModule` definition was used to tell the compiler which components would be created and inserted dynamically. With Ivy, this isn't a requirement anymore and the `entryComponents` array can be removed from existing module declarations. The same applies to the `ANALYZE_FOR_ENTRY_COMPONENTS` injection token. + ## Angular version 9 schematics diff --git a/packages/core/src/metadata/di.ts b/packages/core/src/metadata/di.ts index e5a2c2286d..3702f4e60b 100644 --- a/packages/core/src/metadata/di.ts +++ b/packages/core/src/metadata/di.ts @@ -45,6 +45,7 @@ import {makePropDecorator} from '../util/decorators'; * ``` * * @publicApi + * @deprecated Since 9.0.0. With Ivy, this property is no longer necessary. */ export const ANALYZE_FOR_ENTRY_COMPONENTS = new InjectionToken('AnalyzeForEntryComponents'); diff --git a/packages/core/src/metadata/directives.ts b/packages/core/src/metadata/directives.ts index e95cbbddcf..e29149856a 100644 --- a/packages/core/src/metadata/directives.ts +++ b/packages/core/src/metadata/directives.ts @@ -542,6 +542,7 @@ export interface Component extends Directive { * this component. For each component listed here, * Angular creates a {@link ComponentFactory} and stores it in the * {@link ComponentFactoryResolver}. + * @deprecated Since 9.0.0. With Ivy, this property is no longer necessary. */ entryComponents?: Array|any[]>; diff --git a/packages/core/src/metadata/ng_module.ts b/packages/core/src/metadata/ng_module.ts index a44826cd78..5c9f85991f 100644 --- a/packages/core/src/metadata/ng_module.ts +++ b/packages/core/src/metadata/ng_module.ts @@ -265,6 +265,7 @@ export interface NgModule { * using one of the imperative techniques, such as `ViewContainerRef.createComponent()`. * * @see [Entry Components](guide/entry-components) + * @deprecated Since 9.0.0. With Ivy, this property is no longer necessary. */ entryComponents?: Array|any[]>; diff --git a/tools/public_api_guard/core/core.d.ts b/tools/public_api_guard/core/core.d.ts index ca3c6c09f4..4a0795c2fa 100644 --- a/tools/public_api_guard/core/core.d.ts +++ b/tools/public_api_guard/core/core.d.ts @@ -18,6 +18,7 @@ export interface AfterViewInit { ngAfterViewInit(): void; } +/** @deprecated */ export declare const ANALYZE_FOR_ENTRY_COMPONENTS: InjectionToken; export declare const APP_BOOTSTRAP_LISTENER: InjectionToken<((compRef: ComponentRef) => void)[]>; @@ -116,7 +117,7 @@ export interface Component extends Directive { animations?: any[]; changeDetection?: ChangeDetectionStrategy; encapsulation?: ViewEncapsulation; - entryComponents?: Array | any[]>; + /** @deprecated */ entryComponents?: Array | any[]>; interpolation?: [string, string]; moduleId?: string; preserveWhitespaces?: boolean; @@ -581,7 +582,7 @@ export declare type NgIterable = Array | Iterable; export interface NgModule { bootstrap?: Array | any[]>; declarations?: Array | any[]>; - entryComponents?: Array | any[]>; + /** @deprecated */ entryComponents?: Array | any[]>; exports?: Array | any[]>; id?: string; imports?: Array | ModuleWithProviders<{}> | any[]>;