From 21328f2373dddf4a7dfdb194438732d26b102986 Mon Sep 17 00:00:00 2001 From: Vikram Subramanian Date: Tue, 28 May 2019 15:35:47 -0700 Subject: [PATCH] fix(ivy): add back ngDevMode to r3_injector (#30707) Import the definition so that it doesn't cause breakage with closure conformance rules. FW-1307 #resolve PR Close #30707 --- packages/core/src/di/r3_injector.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/core/src/di/r3_injector.ts b/packages/core/src/di/r3_injector.ts index b5863856df..276e868117 100644 --- a/packages/core/src/di/r3_injector.ts +++ b/packages/core/src/di/r3_injector.ts @@ -6,6 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ +import '../util/ng_dev_mode'; + import {OnDestroy} from '../interface/lifecycle_hooks'; import {Type} from '../interface/type'; import {throwCyclicDependencyError, throwInvalidProviderError, throwMixedMultiProviderError} from '../render3/errors'; @@ -255,8 +257,7 @@ export class R3Injector { (ngModule === undefined) ? (defOrWrappedDef as InjectorType) : ngModule; // Check for circular dependencies. - // TODO(FW-1307): Re-add ngDevMode when closure can handle it - if (parents.indexOf(defType) !== -1) { + if (ngDevMode && parents.indexOf(defType) !== -1) { const defName = stringify(defType); throw new Error( `Circular dependency in DI detected for type ${defName}. Dependency path: ${parents.map(defType => stringify(defType)).join(' > ')} > ${defName}.`); @@ -286,8 +287,7 @@ export class R3Injector { if (def.imports != null && !isDuplicate) { // Before processing defType's imports, add it to the set of parents. This way, if it ends // up deeply importing itself, this can be detected. - // TODO(FW-1307): Re-add ngDevMode when closure can handle it - parents.push(defType); + ngDevMode && parents.push(defType); // Add it to the set of dedups. This way we can detect multiple imports of the same module dedupStack.push(defType); @@ -303,8 +303,7 @@ export class R3Injector { }); } finally { // Remove it from the parents set when finished. - // TODO(FW-1307): Re-add ngDevMode when closure can handle it - parents.pop(); + ngDevMode && parents.pop(); } // Imports which are declared with providers (TypeWithProviders) need to be processed