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
This commit is contained in:
Pete Bacon Darwin 2018-11-16 12:09:34 +00:00 committed by Jason Aden
parent 69c7488927
commit a4462c24fa
1 changed files with 2 additions and 2 deletions

View File

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