mirror of
https://github.com/angular/angular.git
synced 2026-11-29 09:57:50 -05:00
fix(core): add warning when using zoneless but zone.js is still loaded (#55769)
Users may be using zoneless, but are still loading Zone.js in which case they won't get the full benefits like reduced bundle size. These changes detect such a case and log a warning. PR Close #55769
This commit is contained in:
committed by
Dylan Hunn
parent
834e627d9e
commit
ae0baa2522
@@ -147,6 +147,8 @@ export const enum RuntimeErrorCode {
|
|||||||
// (undocumented)
|
// (undocumented)
|
||||||
UNEXPECTED_ZONE_STATE = 909,
|
UNEXPECTED_ZONE_STATE = 909,
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
|
UNEXPECTED_ZONEJS_PRESENT_IN_ZONELESS_MODE = 914,
|
||||||
|
// (undocumented)
|
||||||
UNKNOWN_BINDING = 303,
|
UNKNOWN_BINDING = 303,
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
UNKNOWN_ELEMENT = 304,
|
UNKNOWN_ELEMENT = 304,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {Injectable} from '../../di/injectable';
|
|||||||
import {inject} from '../../di/injector_compatibility';
|
import {inject} from '../../di/injector_compatibility';
|
||||||
import {EnvironmentProviders} from '../../di/interface/provider';
|
import {EnvironmentProviders} from '../../di/interface/provider';
|
||||||
import {makeEnvironmentProviders} from '../../di/provider_collection';
|
import {makeEnvironmentProviders} from '../../di/provider_collection';
|
||||||
import {RuntimeError, RuntimeErrorCode} from '../../errors';
|
import {RuntimeError, RuntimeErrorCode, formatRuntimeError} from '../../errors';
|
||||||
import {PendingTasks} from '../../pending_tasks';
|
import {PendingTasks} from '../../pending_tasks';
|
||||||
import {
|
import {
|
||||||
scheduleCallbackWithMicrotask,
|
scheduleCallbackWithMicrotask,
|
||||||
@@ -294,6 +294,17 @@ export class ChangeDetectionSchedulerImpl implements ChangeDetectionScheduler {
|
|||||||
*/
|
*/
|
||||||
export function provideExperimentalZonelessChangeDetection(): EnvironmentProviders {
|
export function provideExperimentalZonelessChangeDetection(): EnvironmentProviders {
|
||||||
performanceMarkFeature('NgZoneless');
|
performanceMarkFeature('NgZoneless');
|
||||||
|
|
||||||
|
if ((typeof ngDevMode === 'undefined' || ngDevMode) && typeof Zone !== 'undefined' && Zone) {
|
||||||
|
const message = formatRuntimeError(
|
||||||
|
RuntimeErrorCode.UNEXPECTED_ZONEJS_PRESENT_IN_ZONELESS_MODE,
|
||||||
|
`The application is using zoneless change detection, but is still loading Zone.js.` +
|
||||||
|
`Consider removing Zone.js to get the full benefits of zoneless. ` +
|
||||||
|
`In applcations using the Angular CLI, Zone.js is typically included in the "polyfills" section of the angular.json file.`,
|
||||||
|
);
|
||||||
|
console.warn(message);
|
||||||
|
}
|
||||||
|
|
||||||
return makeEnvironmentProviders([
|
return makeEnvironmentProviders([
|
||||||
{provide: ChangeDetectionScheduler, useExisting: ChangeDetectionSchedulerImpl},
|
{provide: ChangeDetectionScheduler, useExisting: ChangeDetectionSchedulerImpl},
|
||||||
{provide: NgZone, useClass: NoopNgZone},
|
{provide: NgZone, useClass: NoopNgZone},
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ export const enum RuntimeErrorCode {
|
|||||||
VIEW_ALREADY_DESTROYED = 911,
|
VIEW_ALREADY_DESTROYED = 911,
|
||||||
COMPONENT_ID_COLLISION = -912,
|
COMPONENT_ID_COLLISION = -912,
|
||||||
IMAGE_PERFORMANCE_WARNING = -913,
|
IMAGE_PERFORMANCE_WARNING = -913,
|
||||||
|
UNEXPECTED_ZONEJS_PRESENT_IN_ZONELESS_MODE = 914,
|
||||||
|
|
||||||
// Signal integration errors
|
// Signal integration errors
|
||||||
REQUIRED_INPUT_NO_VALUE = -950,
|
REQUIRED_INPUT_NO_VALUE = -950,
|
||||||
|
|||||||
Reference in New Issue
Block a user