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
This commit is contained in:
Vikram Subramanian 2019-05-28 15:35:47 -07:00 committed by Misko Hevery
parent dd8cf19352
commit 21328f2373

View File

@ -6,6 +6,8 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import '../util/ng_dev_mode';
import {OnDestroy} from '../interface/lifecycle_hooks'; import {OnDestroy} from '../interface/lifecycle_hooks';
import {Type} from '../interface/type'; import {Type} from '../interface/type';
import {throwCyclicDependencyError, throwInvalidProviderError, throwMixedMultiProviderError} from '../render3/errors'; import {throwCyclicDependencyError, throwInvalidProviderError, throwMixedMultiProviderError} from '../render3/errors';
@ -255,8 +257,7 @@ export class R3Injector {
(ngModule === undefined) ? (defOrWrappedDef as InjectorType<any>) : ngModule; (ngModule === undefined) ? (defOrWrappedDef as InjectorType<any>) : ngModule;
// Check for circular dependencies. // Check for circular dependencies.
// TODO(FW-1307): Re-add ngDevMode when closure can handle it if (ngDevMode && parents.indexOf(defType) !== -1) {
if (parents.indexOf(defType) !== -1) {
const defName = stringify(defType); const defName = stringify(defType);
throw new Error( throw new Error(
`Circular dependency in DI detected for type ${defName}. Dependency path: ${parents.map(defType => stringify(defType)).join(' > ')} > ${defName}.`); `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) { if (def.imports != null && !isDuplicate) {
// Before processing defType's imports, add it to the set of parents. This way, if it ends // 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. // up deeply importing itself, this can be detected.
// TODO(FW-1307): Re-add ngDevMode when closure can handle it ngDevMode && parents.push(defType);
parents.push(defType);
// Add it to the set of dedups. This way we can detect multiple imports of the same module // Add it to the set of dedups. This way we can detect multiple imports of the same module
dedupStack.push(defType); dedupStack.push(defType);
@ -303,8 +303,7 @@ export class R3Injector {
}); });
} finally { } finally {
// Remove it from the parents set when finished. // Remove it from the parents set when finished.
// TODO(FW-1307): Re-add ngDevMode when closure can handle it ngDevMode && parents.pop();
parents.pop();
} }
// Imports which are declared with providers (TypeWithProviders) need to be processed // Imports which are declared with providers (TypeWithProviders) need to be processed