fix(core): initialize global ngDevMode without toplevel side effects (#32079)

Fix #31595

PR Close #32079
This commit is contained in:
Filipe Silva
2019-08-15 14:14:25 +01:00
committed by Matias Niemelä
parent a85eccd6ff
commit 5f095a501e
9 changed files with 92 additions and 36 deletions

View File

@ -6,15 +6,13 @@
* found in the LICENSE file at https://angular.io/license
*/
import '../util/ng_dev_mode';
import {ChangeDetectionStrategy} from '../change_detection/constants';
import {NG_INJECTABLE_DEF, ɵɵdefineInjectable} from '../di/interface/defs';
import {Mutable, Type} from '../interface/type';
import {NgModuleDef} from '../metadata/ng_module';
import {SchemaMetadata} from '../metadata/schema';
import {ViewEncapsulation} from '../metadata/view';
import {noSideEffects} from '../util/closure';
import {initNgDevMode} from '../util/ng_dev_mode';
import {stringify} from '../util/stringify';
import {EMPTY_ARRAY, EMPTY_OBJ} from './empty';
@ -240,6 +238,10 @@ export function ɵɵdefineComponent<T>(componentDefinition: {
*/
schemas?: SchemaMetadata[] | null;
}): never {
// Initialize ngDevMode. This must be the first statement in ɵɵdefineComponent.
// See the `initNgDevMode` docstring for more information.
(typeof ngDevMode === 'undefined' || ngDevMode) && initNgDevMode();
const type = componentDefinition.type;
const typePrototype = type.prototype;
const declaredInputs: {[key: string]: string} = {} as any;