fix(ivy): default to `ngDevMode = true` (#25208)
Before the `ngDevMode` had to be set explicitly or it would throw an exception at runtime. This changes it so that if `ngDevModu` is `undefined` than we default to `ngDevMode = true`. In other words unless the developer has explicitly asked to make a prodution build by setting `ngDevMode = false` as compilation constant, the default is `ngDevMode = true`. This also fixes a minor bug where the setup code would read `global['ngDevMode']` but all other code would read `global.ngDevMode`. This would cause issues with closure compiler since the reading of the `ngDevMode` must be consistent. PR Close #25208
This commit is contained in:
parent
4cb1074850
commit
aafd502bcb
|
@ -35,32 +35,43 @@ declare global {
|
||||||
|
|
||||||
|
|
||||||
declare let global: any;
|
declare let global: any;
|
||||||
export const ngDevModeResetPerfCounters: () => void =
|
|
||||||
(typeof ngDevMode == 'undefined' && (function(global: {ngDevMode: NgDevModePerfCounters}) {
|
const __global: {ngDevMode: NgDevModePerfCounters | boolean} =
|
||||||
function ngDevModeResetPerfCounters() {
|
typeof window != 'undefined' && window || typeof self != 'undefined' && self ||
|
||||||
global['ngDevMode'] = {
|
typeof global != 'undefined' && global;
|
||||||
firstTemplatePass: 0,
|
|
||||||
tNode: 0,
|
export function ngDevModeResetPerfCounters() {
|
||||||
tView: 0,
|
__global.ngDevMode = {
|
||||||
rendererCreateTextNode: 0,
|
firstTemplatePass: 0,
|
||||||
rendererSetText: 0,
|
tNode: 0,
|
||||||
rendererCreateElement: 0,
|
tView: 0,
|
||||||
rendererAddEventListener: 0,
|
rendererCreateTextNode: 0,
|
||||||
rendererSetAttribute: 0,
|
rendererSetText: 0,
|
||||||
rendererRemoveAttribute: 0,
|
rendererCreateElement: 0,
|
||||||
rendererSetProperty: 0,
|
rendererAddEventListener: 0,
|
||||||
rendererSetClassName: 0,
|
rendererSetAttribute: 0,
|
||||||
rendererAddClass: 0,
|
rendererRemoveAttribute: 0,
|
||||||
rendererRemoveClass: 0,
|
rendererSetProperty: 0,
|
||||||
rendererSetStyle: 0,
|
rendererSetClassName: 0,
|
||||||
rendererRemoveStyle: 0,
|
rendererAddClass: 0,
|
||||||
rendererDestroy: 0,
|
rendererRemoveClass: 0,
|
||||||
rendererDestroyNode: 0,
|
rendererSetStyle: 0,
|
||||||
rendererMoveNode: 0,
|
rendererRemoveStyle: 0,
|
||||||
rendererRemoveNode: 0,
|
rendererDestroy: 0,
|
||||||
};
|
rendererDestroyNode: 0,
|
||||||
}
|
rendererMoveNode: 0,
|
||||||
ngDevModeResetPerfCounters();
|
rendererRemoveNode: 0,
|
||||||
return ngDevModeResetPerfCounters;
|
};
|
||||||
})(typeof window != 'undefined' && window || typeof self != 'undefined' && self ||
|
}
|
||||||
typeof global != 'undefined' && global)) as() => void;
|
|
||||||
|
/**
|
||||||
|
* This checks to see if the `ngDevMode` has been set. If yes,
|
||||||
|
* than we honor it, otherwise we default to dev mode with additional checks.
|
||||||
|
*
|
||||||
|
* The idea is that unless we are doing production build where we explicitly
|
||||||
|
* set `ngDevMode == false` we should be helping the developer by providing
|
||||||
|
* as much early warning and errors as possible.
|
||||||
|
*/
|
||||||
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
||||||
|
ngDevModeResetPerfCounters();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue