refactor(core): rename ngComponentDef to ɵcmp (#33088)
Component defs are not considered public API, so the property that contains them should be prefixed with Angular's marker for "private" ('ɵ') to discourage apps from relying on def APIs directly. This commit adds the prefix and shortens the name from `ngComponentDef` to `cmp`. This is because property names cannot be minified by Uglify without turning on property mangling (which most apps have turned off) and are thus size-sensitive. Note that the other "defs" (ngDirectiveDef, etc) will be prefixed and shortened in follow-up PRs, in an attempt to limit how large and conflict-y this change is. PR Close #33088
This commit is contained in:

committed by
Miško Hevery

parent
d4d07233dc
commit
64fd0d6db9
@ -16,7 +16,7 @@ import {initNgDevMode} from '../util/ng_dev_mode';
|
||||
import {stringify} from '../util/stringify';
|
||||
|
||||
import {EMPTY_ARRAY, EMPTY_OBJ} from './empty';
|
||||
import {NG_BASE_DEF, NG_COMPONENT_DEF, NG_DIRECTIVE_DEF, NG_FACTORY_DEF, NG_LOCALE_ID_DEF, NG_MODULE_DEF, NG_PIPE_DEF} from './fields';
|
||||
import {NG_BASE_DEF, NG_COMP_DEF, NG_DIRECTIVE_DEF, NG_FACTORY_DEF, NG_LOCALE_ID_DEF, NG_MODULE_DEF, NG_PIPE_DEF} from './fields';
|
||||
import {ComponentDef, ComponentDefFeature, ComponentTemplate, ComponentType, ContentQueriesFunction, DirectiveDef, DirectiveDefFeature, DirectiveType, DirectiveTypesOrFactory, FactoryFn, HostBindingsFunction, PipeDef, PipeType, PipeTypesOrFactory, ViewQueriesFunction, ɵɵBaseDef} from './interfaces/definition';
|
||||
import {TAttributes} from './interfaces/node';
|
||||
// while SelectorFlags is unused here, it's required so that types don't get resolved lazily
|
||||
@ -34,7 +34,7 @@ let _renderCompCount = 0;
|
||||
* class MyDirective {
|
||||
* // Generated by Angular Template Compiler
|
||||
* // [Symbol] syntax will not be supported by TypeScript until v2.7
|
||||
* static ngComponentDef = defineComponent({
|
||||
* static ɵcmp = defineComponent({
|
||||
* ...
|
||||
* });
|
||||
* }
|
||||
@ -314,7 +314,7 @@ export function ɵɵdefineComponent<T>(componentDefinition: {
|
||||
*/
|
||||
export function ɵɵsetComponentScope(
|
||||
type: ComponentType<any>, directives: Type<any>[], pipes: Type<any>[]): void {
|
||||
const def = (type.ngComponentDef as ComponentDef<any>);
|
||||
const def = (type.ɵcmp as ComponentDef<any>);
|
||||
def.directiveDefs = () => directives.map(extractDirectiveDef);
|
||||
def.pipeDefs = () => pipes.map(extractPipeDef);
|
||||
}
|
||||
@ -740,7 +740,7 @@ export function ɵɵdefinePipe<T>(pipeDef: {
|
||||
*/
|
||||
|
||||
export function getComponentDef<T>(type: any): ComponentDef<T>|null {
|
||||
return type[NG_COMPONENT_DEF] || null;
|
||||
return type[NG_COMP_DEF] || null;
|
||||
}
|
||||
|
||||
export function getDirectiveDef<T>(type: any): DirectiveDef<T>|null {
|
||||
|
Reference in New Issue
Block a user