perf(core): use `ngDevMode` to tree-shake warning (#40876)
This commit adds `ngDevMode` guard to show the warning only in dev mode (similar to how things work in other parts of Ivy runtime code). The `ngDevMode` flag helps to tree-shake the warning from production builds (in dev mode everything will work as it works right now) to decrease production bundle size. PR Close #40876
This commit is contained in:
parent
8658cd59b2
commit
b7a2d0da20
|
@ -12,7 +12,7 @@
|
||||||
"master": {
|
"master": {
|
||||||
"uncompressed": {
|
"uncompressed": {
|
||||||
"runtime-es2015": 3033,
|
"runtime-es2015": 3033,
|
||||||
"main-es2015": 448036,
|
"main-es2015": 447894,
|
||||||
"polyfills-es2015": 52493
|
"polyfills-es2015": 52493
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import {APP_INITIALIZER, ApplicationInitStatus} from './application_init';
|
||||||
import {ApplicationRef} from './application_ref';
|
import {ApplicationRef} from './application_ref';
|
||||||
import {APP_ID_RANDOM_PROVIDER} from './application_tokens';
|
import {APP_ID_RANDOM_PROVIDER} from './application_tokens';
|
||||||
import {defaultIterableDiffers, defaultKeyValueDiffers, IterableDiffers, KeyValueDiffers} from './change_detection/change_detection';
|
import {defaultIterableDiffers, defaultKeyValueDiffers, IterableDiffers, KeyValueDiffers} from './change_detection/change_detection';
|
||||||
import {Console} from './console';
|
|
||||||
import {Injector, StaticProvider} from './di';
|
import {Injector, StaticProvider} from './di';
|
||||||
import {Inject, Optional, SkipSelf} from './di/metadata';
|
import {Inject, Optional, SkipSelf} from './di/metadata';
|
||||||
import {ErrorHandler} from './error_handler';
|
import {ErrorHandler} from './error_handler';
|
||||||
|
@ -78,7 +77,7 @@ export const APPLICATION_MODULE_PROVIDERS: StaticProvider[] = [
|
||||||
{
|
{
|
||||||
provide: ApplicationRef,
|
provide: ApplicationRef,
|
||||||
useClass: ApplicationRef,
|
useClass: ApplicationRef,
|
||||||
deps: [NgZone, Console, Injector, ErrorHandler, ComponentFactoryResolver, ApplicationInitStatus]
|
deps: [NgZone, Injector, ErrorHandler, ComponentFactoryResolver, ApplicationInitStatus]
|
||||||
},
|
},
|
||||||
{provide: SCHEDULER, deps: [NgZone], useFactory: zoneSchedulerFactory},
|
{provide: SCHEDULER, deps: [NgZone], useFactory: zoneSchedulerFactory},
|
||||||
{
|
{
|
||||||
|
|
|
@ -621,8 +621,7 @@ export class ApplicationRef {
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
constructor(
|
constructor(
|
||||||
private _zone: NgZone, private _console: Console, private _injector: Injector,
|
private _zone: NgZone, private _injector: Injector, private _exceptionHandler: ErrorHandler,
|
||||||
private _exceptionHandler: ErrorHandler,
|
|
||||||
private _componentFactoryResolver: ComponentFactoryResolver,
|
private _componentFactoryResolver: ComponentFactoryResolver,
|
||||||
private _initStatus: ApplicationInitStatus) {
|
private _initStatus: ApplicationInitStatus) {
|
||||||
this._onMicrotaskEmptySubscription = this._zone.onMicrotaskEmpty.subscribe({
|
this._onMicrotaskEmptySubscription = this._zone.onMicrotaskEmpty.subscribe({
|
||||||
|
@ -734,8 +733,11 @@ export class ApplicationRef {
|
||||||
});
|
});
|
||||||
|
|
||||||
this._loadComponent(compRef);
|
this._loadComponent(compRef);
|
||||||
if (isDevMode()) {
|
// Note that we have still left the `isDevMode()` condition in order to avoid
|
||||||
this._console.log(
|
// creating a breaking change for projects that still use the View Engine.
|
||||||
|
if ((typeof ngDevMode === 'undefined' || ngDevMode) && isDevMode()) {
|
||||||
|
const _console = this._injector.get(Console);
|
||||||
|
_console.log(
|
||||||
`Angular is running in development mode. Call enableProdMode() to enable production mode.`);
|
`Angular is running in development mode. Call enableProdMode() to enable production mode.`);
|
||||||
}
|
}
|
||||||
return compRef;
|
return compRef;
|
||||||
|
|
Loading…
Reference in New Issue