-
Notifications
You must be signed in to change notification settings - Fork 26.2k
/
Copy pathis_dev_mode.ts
44 lines (41 loc) · 1.33 KB
/
is_dev_mode.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {global} from './global';
/**
* Returns whether Angular is in development mode.
*
* By default, this is true, unless `enableProdMode` is invoked prior to calling this method or the
* application is built using the Angular CLI with the `optimization` option.
* @see {@link /cli/build ng build}
*
* @publicApi
*/
export function isDevMode(): boolean {
return typeof ngDevMode === 'undefined' || !!ngDevMode;
}
/**
* Disable Angular's development mode, which turns off assertions and other
* checks within the framework.
*
* One important assertion this disables verifies that a change detection pass
* does not result in additional changes to any bindings (also known as
* unidirectional data flow).
*
* Using this method is discouraged as the Angular CLI will set production mode when using the
* `optimization` option.
* @see {@link /cli/build ng build}
*
* @publicApi
*/
export function enableProdMode(): void {
// The below check is there so when ngDevMode is set via terser
// `global['ngDevMode'] = false;` is also dropped.
if (typeof ngDevMode === 'undefined' || ngDevMode) {
global['ngDevMode'] = false;
}
}