fix(core): add `noSideEffects()` to `ɵɵdefineComponent()` (#35769)
This marks the function are "pure" and eligible to be tree shaken by Closure. Without this, initializing `ngDevMode` is considered a side effect which prevents this function from being tree shaken and also any component which calls it. PR Close #35769
This commit is contained in:
parent
dc6a7918e3
commit
ba3612774f
|
@ -289,6 +289,7 @@ export function ɵɵdefineComponent<T>(componentDefinition: {
|
||||||
*/
|
*/
|
||||||
schemas?: SchemaMetadata[] | null;
|
schemas?: SchemaMetadata[] | null;
|
||||||
}): never {
|
}): never {
|
||||||
|
return noSideEffects(() => {
|
||||||
// Initialize ngDevMode. This must be the first statement in ɵɵdefineComponent.
|
// Initialize ngDevMode. This must be the first statement in ɵɵdefineComponent.
|
||||||
// See the `initNgDevMode` docstring for more information.
|
// See the `initNgDevMode` docstring for more information.
|
||||||
(typeof ngDevMode === 'undefined' || ngDevMode) && initNgDevMode();
|
(typeof ngDevMode === 'undefined' || ngDevMode) && initNgDevMode();
|
||||||
|
@ -328,8 +329,8 @@ export function ɵɵdefineComponent<T>(componentDefinition: {
|
||||||
viewQuery: componentDefinition.viewQuery || null,
|
viewQuery: componentDefinition.viewQuery || null,
|
||||||
features: componentDefinition.features as DirectiveDefFeature[] || null,
|
features: componentDefinition.features as DirectiveDefFeature[] || null,
|
||||||
data: componentDefinition.data || {},
|
data: componentDefinition.data || {},
|
||||||
// TODO(misko): convert ViewEncapsulation into const enum so that it can be used directly in the
|
// TODO(misko): convert ViewEncapsulation into const enum so that it can be used directly in
|
||||||
// next line. Also `None` should be 0 not 2.
|
// the next line. Also `None` should be 0 not 2.
|
||||||
encapsulation: componentDefinition.encapsulation || ViewEncapsulation.Emulated,
|
encapsulation: componentDefinition.encapsulation || ViewEncapsulation.Emulated,
|
||||||
id: 'c',
|
id: 'c',
|
||||||
styles: componentDefinition.styles || EMPTY_ARRAY,
|
styles: componentDefinition.styles || EMPTY_ARRAY,
|
||||||
|
@ -338,7 +339,6 @@ export function ɵɵdefineComponent<T>(componentDefinition: {
|
||||||
schemas: componentDefinition.schemas || null,
|
schemas: componentDefinition.schemas || null,
|
||||||
tView: null,
|
tView: null,
|
||||||
};
|
};
|
||||||
def._ = noSideEffects(() => {
|
|
||||||
const directiveTypes = componentDefinition.directives !;
|
const directiveTypes = componentDefinition.directives !;
|
||||||
const feature = componentDefinition.features;
|
const feature = componentDefinition.features;
|
||||||
const pipeTypes = componentDefinition.pipes !;
|
const pipeTypes = componentDefinition.pipes !;
|
||||||
|
@ -353,9 +353,9 @@ export function ɵɵdefineComponent<T>(componentDefinition: {
|
||||||
def.pipeDefs = pipeTypes ?
|
def.pipeDefs = pipeTypes ?
|
||||||
() => (typeof pipeTypes === 'function' ? pipeTypes() : pipeTypes).map(extractPipeDef) :
|
() => (typeof pipeTypes === 'function' ? pipeTypes() : pipeTypes).map(extractPipeDef) :
|
||||||
null;
|
null;
|
||||||
}) as never;
|
|
||||||
|
|
||||||
return def as never;
|
return def as never;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue