From a4462c24facaff03b12de780a15a1e92cc12812d Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Fri, 16 Nov 2018 12:09:34 +0000 Subject: [PATCH] fix(upgrade): don't rely upon the runtime to resolve forward refs (#27132) The way that `UpgradeAdapter` needs to be setup, you often find that you must pass a `forwardRef` for an `NgModule.import`. Pre-ivy, this gets resolved at runtime, but until this is implemented in ivy, we can workaround it by resolving it in the `UpgradeAdapter` upfront. This should be backward-compatible since by the time we actually create the dynamic `NgModule` that has the import, the imported class should be defined. PR Close #27132 --- packages/upgrade/src/dynamic/upgrade_adapter.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/upgrade/src/dynamic/upgrade_adapter.ts b/packages/upgrade/src/dynamic/upgrade_adapter.ts index 9c7488f395..f7ab728c4d 100644 --- a/packages/upgrade/src/dynamic/upgrade_adapter.ts +++ b/packages/upgrade/src/dynamic/upgrade_adapter.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Compiler, CompilerOptions, Directive, Injector, NgModule, NgModuleRef, NgZone, StaticProvider, Testability, Type} from '@angular/core'; +import {Compiler, CompilerOptions, Injector, NgModule, NgModuleRef, NgZone, StaticProvider, Testability, Type, resolveForwardRef} from '@angular/core'; import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; import * as angular from '../common/angular1'; @@ -574,7 +574,7 @@ export class UpgradeAdapter { {provide: $COMPILE, useFactory: () => ng1Injector.get($COMPILE)}, this.upgradedProviders ], - imports: [this.ng2AppModule], + imports: [resolveForwardRef(this.ng2AppModule)], entryComponents: this.downgradedComponents }; // At this point we have ng1 injector and we have prepared