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:
Kara Erickson
2019-10-10 14:57:15 -07:00
committed by Miško Hevery
parent d4d07233dc
commit 64fd0d6db9
61 changed files with 306 additions and 312 deletions

View File

@ -189,7 +189,7 @@ runInEachFileSystem(() => {
const addDefinitionsSpy = testFormatter.addDefinitions as jasmine.Spy;
expect(addDefinitionsSpy.calls.first().args[2])
.toEqual(`A.ngFactoryDef = function A_Factory(t) { return new (t || A)(); };
A.ngComponentDef = ɵngcc0.ɵɵdefineComponent({ type: A, selectors: [["a"]], decls: 1, vars: 1, template: function A_Template(rf, ctx) { if (rf & 1) {
A.ɵcmp = ɵngcc0.ɵɵdefineComponent({ type: A, selectors: [["a"]], decls: 1, vars: 1, template: function A_Template(rf, ctx) { if (rf & 1) {
ɵngcc0.ɵɵtext(0);
} if (rf & 2) {
ɵngcc0.ɵɵtextInterpolate(ctx.person.name);

View File

@ -400,7 +400,7 @@ export class ComponentDecoratorHandler implements
// First it needs to be determined if actually importing the directives/pipes used in the
// template would create a cycle. Currently ngtsc refuses to generate cycles, so an option
// known as "remote scoping" is used if a cycle would be created. In remote scoping, the
// module file sets the directives/pipes on the ngComponentDef of the component, without
// module file sets the directives/pipes on the ɵcmp of the component, without
// requiring new imports (but also in a way that breaks tree shaking).
//
// Determining this is challenging, because the TemplateDefinitionBuilder is responsible for
@ -456,7 +456,7 @@ export class ComponentDecoratorHandler implements
this._recordSyntheticImport(pipe, context);
}
// Check whether the directive/pipe arrays in ngComponentDef need to be wrapped in closures.
// Check whether the directive/pipe arrays in ɵcmp need to be wrapped in closures.
// This is required if any directive/pipe reference is to a declaration in the same file but
// declared after this component.
const wrapDirectivesAndPipesInClosure =
@ -493,7 +493,7 @@ export class ComponentDecoratorHandler implements
}
return [
factoryRes, {
name: 'ngComponentDef',
name: 'ɵcmp',
initializer: res.expression,
statements: [],
type: res.type,

View File

@ -69,8 +69,7 @@ export class DtsMetadataReader implements MetadataReader {
getDirectiveMetadata(ref: Reference<ClassDeclaration>): DirectiveMeta|null {
const clazz = ref.node;
const def = this.reflector.getMembersOfClass(clazz).find(
field =>
field.isStatic && (field.name === 'ngComponentDef' || field.name === 'ngDirectiveDef'));
field => field.isStatic && (field.name === 'ɵcmp' || field.name === 'ngDirectiveDef'));
if (def === undefined) {
// No definition could be found.
return null;
@ -88,7 +87,7 @@ export class DtsMetadataReader implements MetadataReader {
return {
ref,
name: clazz.name.text,
isComponent: def.name === 'ngComponentDef', selector,
isComponent: def.name === 'ɵcmp', selector,
exportAs: readStringArrayType(def.type.typeArguments[2]),
inputs: readStringMapType(def.type.typeArguments[3]),
outputs: readStringMapType(def.type.typeArguments[4]),

View File

@ -91,7 +91,7 @@ export class LocalModuleScopeRegistry implements MetadataRegistry, ComponentScop
* Tracks whether a given component requires "remote scoping".
*
* Remote scoping is when the set of directives which apply to a given component is set in the
* NgModule's file instead of directly on the ngComponentDef (which is sometimes needed to get
* NgModule's file instead of directly on the component def (which is sometimes needed to get
* around cyclic import issues). This is not used in calculation of `LocalModuleScope`s, but is
* tracked here for convenience.
*/

View File

@ -20,7 +20,7 @@
// Pattern matching all Render3 property names.
const R3_DEF_NAME_PATTERN = [
'ngBaseDef',
'ngComponentDef',
'ɵcmp',
'ngDirectiveDef',
'ngInjectableDef',
'ngInjectorDef',

View File

@ -477,7 +477,7 @@ describe('compiler compliance', () => {
const factory =
'MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
const template = `
MyComponent.ngComponentDef = i0.ɵɵdefineComponent({type:MyComponent,selectors:[["my-component"]],
MyComponent.ɵcmp = i0.ɵɵdefineComponent({type:MyComponent,selectors:[["my-component"]],
decls: 1,
vars: 2,
template: function MyComponent_Template(rf,ctx){
@ -565,7 +565,7 @@ describe('compiler compliance', () => {
// ChildComponent definition should be:
const ChildComponentDefinition = `
ChildComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
ChildComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: ChildComponent,
selectors: [["child"]],
decls: 1,
@ -595,7 +595,7 @@ describe('compiler compliance', () => {
// MyComponent definition should be:
const MyComponentDefinition = `
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
decls: 2,
@ -618,11 +618,11 @@ describe('compiler compliance', () => {
const result = compile(files, angularFiles);
const source = result.source;
expectEmit(source, ChildComponentDefinition, 'Incorrect ChildComponent.ngComponentDef');
expectEmit(source, ChildComponentDefinition, 'Incorrect ChildComponent.ɵcmp');
expectEmit(source, ChildComponentFactory, 'Incorrect ChildComponent.ngFactoryDef');
expectEmit(source, SomeDirectiveDefinition, 'Incorrect SomeDirective.ngDirectiveDef');
expectEmit(source, SomeDirectiveFactory, 'Incorrect SomeDirective.ngFactoryDef');
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponentDefinition.ngComponentDef');
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponentDefinition.ɵcmp');
expectEmit(source, MyComponentFactory, 'Incorrect MyComponentDefinition.ngFactoryDef');
});
@ -693,7 +693,7 @@ describe('compiler compliance', () => {
// EmptyOutletComponent definition should be:
const EmptyOutletComponentDefinition = `
EmptyOutletComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
EmptyOutletComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: EmptyOutletComponent,
selectors: [["ng-component"]],
decls: 1,
@ -713,8 +713,7 @@ describe('compiler compliance', () => {
const result = compile(files, angularFiles);
const source = result.source;
expectEmit(
source, EmptyOutletComponentDefinition, 'Incorrect EmptyOutletComponent.ngComponentDef');
expectEmit(source, EmptyOutletComponentDefinition, 'Incorrect EmptyOutletComponent.ɵcmp');
expectEmit(
source, EmptyOutletComponentFactory, 'Incorrect EmptyOutletComponent.ngFactoryDef');
});
@ -742,7 +741,7 @@ describe('compiler compliance', () => {
const MyComponentDefinition = `
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
decls: 0,
@ -760,7 +759,7 @@ describe('compiler compliance', () => {
const result = compile(files, angularFiles);
const source = result.source;
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponent.ngComponentDef');
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponent.ɵcmp');
expectEmit(source, MyComponentFactory, 'Incorrect MyComponent.ngFactoryDef');
});
@ -813,7 +812,7 @@ describe('compiler compliance', () => {
}
}
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
decls: 3,
@ -838,7 +837,7 @@ describe('compiler compliance', () => {
expectEmit(source, IfDirectiveDefinition, 'Incorrect IfDirective.ngDirectiveDef');
expectEmit(source, IfDirectiveFactory, 'Incorrect IfDirective.ngFactoryDef');
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponent.ngComponentDef');
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponent.ɵcmp');
expectEmit(source, MyComponentFactory, 'Incorrect MyComponent.ngFactoryDef');
});
@ -880,7 +879,7 @@ describe('compiler compliance', () => {
const MyAppDeclaration = `
const $e0_ff$ = function ($v$) { return ["Nancy", $v$]; };
MyApp.ngComponentDef = $r3$.ɵɵdefineComponent({
MyApp.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyApp,
selectors: [["my-app"]],
decls: 1,
@ -961,7 +960,7 @@ describe('compiler compliance', () => {
return ["start-", $v0$, $v1$, $v2$, $v3$, $v4$, "-middle-", $v5$, $v6$, $v7$, $v8$, "-end"];
}
MyApp.ngComponentDef = $r3$.ɵɵdefineComponent({
MyApp.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyApp,
selectors: [["my-app"]],
decls: 1,
@ -1023,7 +1022,7 @@ describe('compiler compliance', () => {
const MyAppDefinition = `
const $e0_ff$ = function ($v$) { return {"duration": 500, animation: $v$}; };
MyApp.ngComponentDef = $r3$.ɵɵdefineComponent({
MyApp.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyApp,
selectors: [["my-app"]],
decls: 1,
@ -1090,7 +1089,7 @@ describe('compiler compliance', () => {
const $e0_ff_1$ = function ($v$) { return [$c0$, $v$]; };
const $e0_ff_2$ = function ($v1$, $v2$) { return {animation: $v1$, actions: $v2$}; };
MyApp.ngComponentDef = $r3$.ɵɵdefineComponent({
MyApp.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyApp,
selectors: [["my-app"]],
decls: 1,
@ -1151,7 +1150,7 @@ describe('compiler compliance', () => {
};
const SimpleComponentDefinition = `
SimpleComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
SimpleComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: SimpleComponent,
selectors: [["simple"]],
ngContentSelectors: $c0$,
@ -1171,7 +1170,7 @@ describe('compiler compliance', () => {
const ComplexComponentDefinition = `
const $c1$ = [[["span", "title", "tofirst"]], [["span", "title", "tosecond"]]];
ComplexComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
ComplexComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: ComplexComponent,
selectors: [["complex"]],
ngContentSelectors: $c2$,
@ -1227,7 +1226,7 @@ describe('compiler compliance', () => {
const $c0$ = ["*", [["", "spacer", ""]], "*"];
const $c1$ = ["*", "[spacer]", "*"];
Cmp.ngComponentDef = $r3$.ɵɵdefineComponent({
Cmp.ɵcmp = $r3$.ɵɵdefineComponent({
type: Cmp,
selectors: [["ng-component"]],
ngContentSelectors: $c1$,
@ -1411,7 +1410,7 @@ describe('compiler compliance', () => {
const $_c0$ = [[["", "title", ""]]];
const $_c1$ = ["[title]"];
MyApp.ngComponentDef = $r3$.ɵɵdefineComponent({
MyApp.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyApp,
selectors: [["my-app"]],
decls: 2,
@ -1463,7 +1462,7 @@ describe('compiler compliance', () => {
const $_c0$ = [[["", "title", ""]]];
const $_c1$ = ["[title]"];
MyApp.ngComponentDef = $r3$.ɵɵdefineComponent({
MyApp.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyApp,
selectors: [["my-app"]],
decls: 2,
@ -1526,7 +1525,7 @@ describe('compiler compliance', () => {
const ViewQueryComponentDefinition = `
ViewQueryComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
ViewQueryComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: ViewQueryComponent,
selectors: [["view-query-component"]],
viewQuery: function ViewQueryComponent_Query(rf, ctx) {
@ -1586,7 +1585,7 @@ describe('compiler compliance', () => {
const $e0_attrs$ = ["myRef"];
const $e1_attrs$ = ["myRef1", "myRef2", "myRef3"];
ViewQueryComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
ViewQueryComponent.ɵcmp = $r3$.ɵɵdefineComponent({
viewQuery: function ViewQueryComponent_Query(rf, ctx) {
if (rf & 1) {
@ -1636,7 +1635,7 @@ describe('compiler compliance', () => {
const ViewQueryComponentDefinition = `
const $refs$ = ["foo"];
ViewQueryComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
ViewQueryComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: ViewQueryComponent,
selectors: [["view-query-component"]],
viewQuery: function ViewQueryComponent_Query(rf, ctx) {
@ -1701,7 +1700,7 @@ describe('compiler compliance', () => {
const $e0_attrs$ = ["myRef"];
const $e1_attrs$ = ["myRef1", "myRef2", "myRef3"];
ViewQueryComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
ViewQueryComponent.ɵcmp = $r3$.ɵɵdefineComponent({
viewQuery: function ViewQueryComponent_Query(rf, ctx) {
if (rf & 1) {
@ -1763,7 +1762,7 @@ describe('compiler compliance', () => {
};
const ContentQueryComponentDefinition = `
ContentQueryComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
ContentQueryComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: ContentQueryComponent,
selectors: [["content-query-component"]],
contentQueries: function ContentQueryComponent_ContentQueries(rf, ctx, dirIndex) {
@ -1824,7 +1823,7 @@ describe('compiler compliance', () => {
const $e0_attrs$ = ["myRef"];
const $e1_attrs$ = ["myRef1", "myRef2", "myRef3"];
ContentQueryComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
ContentQueryComponent.ɵcmp = $r3$.ɵɵdefineComponent({
contentQueries: function ContentQueryComponent_ContentQueries(rf, ctx, dirIndex) {
if (rf & 1) {
@ -1882,7 +1881,7 @@ describe('compiler compliance', () => {
};
const ContentQueryComponentDefinition = `
ContentQueryComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
ContentQueryComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: ContentQueryComponent,
selectors: [["content-query-component"]],
contentQueries: function ContentQueryComponent_ContentQueries(rf, ctx, dirIndex) {
@ -1948,7 +1947,7 @@ describe('compiler compliance', () => {
const $e0_attrs$ = ["myRef"];
const $e1_attrs$ = ["myRef1", "myRef2", "myRef3"];
ContentQueryComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
ContentQueryComponent.ɵcmp = $r3$.ɵɵdefineComponent({
contentQueries: function ContentQueryComponent_ContentQueries(rf, ctx, dirIndex) {
if (rf & 1) {
@ -2045,7 +2044,7 @@ describe('compiler compliance', () => {
return [$a0$, 1, 2, 3, 4, 5];
};
// ...
MyApp.ngComponentDef = $r3$.ɵɵdefineComponent({
MyApp.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyApp,
selectors: [["my-app"]],
decls: 7,
@ -2112,7 +2111,7 @@ describe('compiler compliance', () => {
const MyAppDefinition = `
// ...
MyApp.ngComponentDef = $r3$.ɵɵdefineComponent({
MyApp.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyApp,
selectors: [["my-app"]],
decls: 6,
@ -2235,7 +2234,7 @@ describe('compiler compliance', () => {
const MyComponentDefinition = `
const $c1$ = ["user", ""];
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
decls: 3,
@ -2258,7 +2257,7 @@ describe('compiler compliance', () => {
const result = compile(files, angularFiles);
const source = result.source;
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponent.ngComponentDef');
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponent.ɵcmp');
});
it('local references in nested views', () => {
@ -2330,7 +2329,7 @@ describe('compiler compliance', () => {
}
}
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
decls: 6,
@ -2355,7 +2354,7 @@ describe('compiler compliance', () => {
const result = compile(files, angularFiles);
const source = result.source;
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponent.ngComponentDef');
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponent.ɵcmp');
});
it('should support local refs mixed with context assignments', () => {
@ -2475,7 +2474,7 @@ describe('compiler compliance', () => {
it('should gen hooks with a few simple components', () => {
const LifecycleCompDefinition = `
LifecycleComp.ngComponentDef = $r3$.ɵɵdefineComponent({
LifecycleComp.ɵcmp = $r3$.ɵɵdefineComponent({
type: LifecycleComp,
selectors: [["lifecycle-comp"]],
inputs: {nameMin: ["name", "nameMin"]},
@ -2487,7 +2486,7 @@ describe('compiler compliance', () => {
});`;
const SimpleLayoutDefinition = `
SimpleLayout.ngComponentDef = $r3$.ɵɵdefineComponent({
SimpleLayout.ɵcmp = $r3$.ɵɵdefineComponent({
type: SimpleLayout,
selectors: [["simple-layout"]],
decls: 2,
@ -2619,7 +2618,7 @@ describe('compiler compliance', () => {
}
}
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
decls: 2,
@ -2705,7 +2704,7 @@ describe('compiler compliance', () => {
}
}
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
decls: 2,
@ -2809,7 +2808,7 @@ describe('compiler compliance', () => {
}
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
decls: 2,

View File

@ -714,7 +714,7 @@ describe('compiler compliance: bindings', () => {
const HostBindingCompDeclaration = `
const $ff$ = function ($v$) { return ["red", $v$]; };
HostBindingComp.ngComponentDef = $r3$.ɵɵdefineComponent({
HostBindingComp.ɵcmp = $r3$.ɵɵdefineComponent({
type: HostBindingComp,
selectors: [["host-binding-comp"]],
hostBindings: function HostBindingComp_HostBindings(rf, ctx, elIndex) {
@ -862,7 +862,7 @@ describe('compiler compliance: bindings', () => {
const $c0$ = ["title", "hello there from component", ${AttributeMarker.Styles}, "opacity", "1"];
const $c1$ = ["title", "hello there from directive", ${AttributeMarker.Classes}, "one", "two", ${AttributeMarker.Styles}, "width", "200px", "height", "500px"];
HostAttributeComp.ngComponentDef = $r3$.ɵɵdefineComponent({
HostAttributeComp.ɵcmp = $r3$.ɵɵdefineComponent({
type: HostAttributeComp,
selectors: [["my-host-attribute-component"]],
hostBindings: function HostAttributeComp_HostBindings(rf, ctx, elIndex) {

View File

@ -38,7 +38,7 @@ describe('compiler compliance: directives', () => {
// MyComponent definition should be:
const MyComponentDefinition = `
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
decls: 1,
@ -59,7 +59,7 @@ describe('compiler compliance: directives', () => {
const result = compile(files, angularFiles);
const source = result.source;
expectEmit(source, MyComponentDefinition, 'Incorrect ChildComponent.ngComponentDef');
expectEmit(source, MyComponentDefinition, 'Incorrect ChildComponent.ɵcmp');
expectEmit(source, MyComponentFactory, 'Incorrect ChildComponent.ngFactoryDef');
});
@ -88,7 +88,7 @@ describe('compiler compliance: directives', () => {
// MyComponent definition should be:
const MyComponentDefinition = `
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
decls: 1,
@ -109,7 +109,7 @@ describe('compiler compliance: directives', () => {
const result = compile(files, angularFiles);
const source = result.source;
expectEmit(source, MyComponentDefinition, 'Incorrect ChildComponent.ngComponentDef');
expectEmit(source, MyComponentDefinition, 'Incorrect ChildComponent.ɵcmp');
expectEmit(source, MyComponentFactory, 'Incorrect ChildComponent.ngFactoryDef');
});
@ -138,7 +138,7 @@ describe('compiler compliance: directives', () => {
// MyComponent definition should be:
const MyComponentDefinition = `
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
consts: [[${AttributeMarker.Bindings}, "someDirective"]],
template: function MyComponent_Template(rf, ctx) {
@ -158,7 +158,7 @@ describe('compiler compliance: directives', () => {
const result = compile(files, angularFiles);
const source = result.source;
expectEmit(source, MyComponentDefinition, 'Incorrect ChildComponent.ngComponentDef');
expectEmit(source, MyComponentDefinition, 'Incorrect ChildComponent.ɵcmp');
});
it('should match directives on ng-templates', () => {
@ -196,7 +196,7 @@ describe('compiler compliance: directives', () => {
}
}
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
consts: [["directiveA", ""]],
template: function MyComponent_Template(rf, ctx) {
@ -211,7 +211,7 @@ describe('compiler compliance: directives', () => {
`;
const result = compile(files, angularFiles);
expectEmit(result.source, MyComponentDefinition, 'Incorrect ChildComponent.ngComponentDef');
expectEmit(result.source, MyComponentDefinition, 'Incorrect ChildComponent.ɵcmp');
});
it('should match directives on ng-container', () => {
@ -251,7 +251,7 @@ describe('compiler compliance: directives', () => {
}
}
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
consts: [["directiveA", "", ${AttributeMarker.Template}, "ngIf"], ["directiveA", ""]],
template: function MyComponent_Template(rf, ctx) {
@ -269,7 +269,7 @@ describe('compiler compliance: directives', () => {
`;
const result = compile(files, angularFiles);
expectEmit(result.source, MyComponentDefinition, 'Incorrect ChildComponent.ngComponentDef');
expectEmit(result.source, MyComponentDefinition, 'Incorrect ChildComponent.ɵcmp');
});
it('should match directives on ng-template bindings', () => {
@ -297,7 +297,7 @@ describe('compiler compliance: directives', () => {
// MyComponent definition should be:
const MyComponentDefinition = `
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
consts: [[${AttributeMarker.Bindings}, "someDirective"]],
template: function MyComponent_Template(rf, ctx) {
@ -317,7 +317,7 @@ describe('compiler compliance: directives', () => {
const result = compile(files, angularFiles);
const source = result.source;
expectEmit(source, MyComponentDefinition, 'Incorrect ChildComponent.ngComponentDef');
expectEmit(source, MyComponentDefinition, 'Incorrect ChildComponent.ɵcmp');
});
it('should match structural directives', () => {
@ -344,7 +344,7 @@ describe('compiler compliance: directives', () => {
// MyComponent definition should be:
const MyComponentDefinition = `
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
consts: [[${AttributeMarker.Template}, "someDirective"]],
template: function MyComponent_Template(rf, ctx) {
@ -361,7 +361,7 @@ describe('compiler compliance: directives', () => {
const result = compile(files, angularFiles);
const source = result.source;
expectEmit(source, MyComponentDefinition, 'Incorrect ChildComponent.ngComponentDef');
expectEmit(source, MyComponentDefinition, 'Incorrect ChildComponent.ɵcmp');
});
@ -392,7 +392,7 @@ describe('compiler compliance: directives', () => {
// MyComponent definition should be:
const MyComponentDefinition = `
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
consts: [[${AttributeMarker.Bindings}, "someDirective"]],
template: function MyComponent_Template(rf, ctx) {
@ -411,7 +411,7 @@ describe('compiler compliance: directives', () => {
const result = compile(files, angularFiles);
const source = result.source;
expectEmit(source, MyComponentDefinition, 'Incorrect ChildComponent.ngComponentDef');
expectEmit(source, MyComponentDefinition, 'Incorrect ChildComponent.ɵcmp');
});
});

View File

@ -52,7 +52,7 @@ describe('compiler compliance: listen()', () => {
};
const componentDef = `
MyComponent.ngComponentDef = IDENT.ɵɵdefineComponent({
MyComponent.ɵcmp = IDENT.ɵɵdefineComponent({
inputs:{
componentInput: "componentInput",

View File

@ -195,7 +195,7 @@ describe('compiler compliance: listen()', () => {
const MyComponentDefinition = `
const $e2_refs$ = ["user", ""];
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
decls: 4,
@ -226,7 +226,7 @@ describe('compiler compliance: listen()', () => {
const result = compile(files, angularFiles);
const source = result.source;
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponent.ngComponentDef');
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponent.ɵcmp');
expectEmit(source, MyComponentFactory, 'Incorrect MyComponent.ngFactoryDef');
});

View File

@ -145,7 +145,7 @@ describe('compiler compliance: providers', () => {
export class MyComponent {
}
MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
MyComponent.ngComponentDef = i0.ɵɵdefineComponent({
MyComponent.ɵcmp = i0.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
decls: 1,

View File

@ -95,7 +95,7 @@ describe('compiler compliance: styling', () => {
};
const template = `
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
styles: ["div.cool { color: blue; }", ":host.nice p { color: gold; }"],
encapsulation: 1
@ -128,7 +128,7 @@ describe('compiler compliance: styling', () => {
};
const template = `
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors:[["my-component"]],
decls: 0,
@ -167,7 +167,7 @@ describe('compiler compliance: styling', () => {
};
const template = `
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors:[["my-component"]],
decls: 0,
@ -209,7 +209,7 @@ describe('compiler compliance: styling', () => {
const template = `
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
decls: 3,
vars: 3,
@ -270,7 +270,7 @@ describe('compiler compliance: styling', () => {
const template = `
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
decls: 1,
vars: 1,
@ -502,7 +502,7 @@ describe('compiler compliance: styling', () => {
const template = `
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors:[["my-component"]],
decls: 1,
@ -550,7 +550,7 @@ describe('compiler compliance: styling', () => {
};
const template = `
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors: [["my-component"]],
decls: 1,
@ -696,7 +696,7 @@ describe('compiler compliance: styling', () => {
const template = `
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors:[["my-component"]],
decls: 1,
@ -745,7 +745,7 @@ describe('compiler compliance: styling', () => {
const template = `
MyComponent.ngComponentDef = $r3$.ɵɵdefineComponent({
MyComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: MyComponent,
selectors:[["my-component"]],
decls: 1,

View File

@ -205,14 +205,14 @@ runInEachFileSystem(os => {
env.driveMain();
const jsContents = env.getContents('test.js');
expect(jsContents).toContain('TestCmp.ngComponentDef = i0.ɵɵdefineComponent');
expect(jsContents).toContain('TestCmp.ɵcmp = i0.ɵɵdefineComponent');
expect(jsContents).toContain('TestCmp.ngFactoryDef = function');
expect(jsContents).not.toContain('__decorate');
const dtsContents = env.getContents('test.d.ts');
expect(dtsContents)
.toContain(
'static ngComponentDef: i0.ɵɵComponentDefWithMeta<TestCmp, "test-cmp", never, {}, {}, never>');
'static ɵcmp: i0.ɵɵComponentDefWithMeta<TestCmp, "test-cmp", never, {}, {}, never>');
expect(dtsContents).toContain('static ngFactoryDef: i0.ɵɵFactoryDef<TestCmp>');
});
@ -230,7 +230,7 @@ runInEachFileSystem(os => {
env.driveMain();
const jsContents = env.getContents('test.js');
expect(jsContents).toContain('TestCmp.ngComponentDef = i0.ɵɵdefineComponent');
expect(jsContents).toContain('TestCmp.ɵcmp = i0.ɵɵdefineComponent');
expect(jsContents).toContain('TestCmp.ngFactoryDef = function');
expect(jsContents).not.toContain('__decorate');
@ -238,7 +238,7 @@ runInEachFileSystem(os => {
expect(dtsContents)
.toContain(
'static ngComponentDef: i0.ɵɵComponentDefWithMeta<TestCmp, "test-cmp", never, {}, {}, never>');
'static ɵcmp: i0.ɵɵComponentDefWithMeta<TestCmp, "test-cmp", never, {}, {}, never>');
expect(dtsContents).toContain('static ngFactoryDef: i0.ɵɵFactoryDef<TestCmp>');
});
@ -259,14 +259,14 @@ runInEachFileSystem(os => {
env.driveMain();
const jsContents = env.getContents('test.js');
expect(jsContents).toContain('TestCmp.ngComponentDef = i0.ɵɵdefineComponent');
expect(jsContents).toContain('TestCmp.ɵcmp = i0.ɵɵdefineComponent');
expect(jsContents).toContain('TestCmp.ngFactoryDef = function');
expect(jsContents).not.toContain('__decorate');
const dtsContents = env.getContents('test.d.ts');
expect(dtsContents)
.toContain(
'static ngComponentDef: i0.ɵɵComponentDefWithMeta<TestCmp, "test-cmp", never, {}, {}, never>');
'static ɵcmp: i0.ɵɵComponentDefWithMeta<TestCmp, "test-cmp", never, {}, {}, never>');
expect(dtsContents).toContain('static ngFactoryDef: i0.ɵɵFactoryDef<TestCmp>');
});
@ -310,7 +310,7 @@ runInEachFileSystem(os => {
env.driveMain();
const jsContents = env.getContents('test.js');
expect(jsContents).toContain('/** @nocollapse */ TestCmp.ngComponentDef');
expect(jsContents).toContain('/** @nocollapse */ TestCmp.ɵcmp');
});
}
@ -372,7 +372,7 @@ runInEachFileSystem(os => {
const jsContents = env.getContents('test.js');
expect(jsContents).toContain('TestBase.ngBaseDef = i0.ɵɵdefineBase');
expect(jsContents).toContain('TestComponent.ngComponentDef = i0.ɵɵdefineComponent');
expect(jsContents).toContain('TestComponent.ɵcmp = i0.ɵɵdefineComponent');
expect(jsContents).toContain('TestDirective.ngDirectiveDef = i0.ɵɵdefineDirective');
expect(jsContents).toContain('TestPipe.ngPipeDef = i0.ɵɵdefinePipe');
expect(jsContents).toContain('TestInjectable.ngInjectableDef = i0.ɵɵdefineInjectable');
@ -509,7 +509,7 @@ runInEachFileSystem(os => {
const dtsContents = env.getContents('test.d.ts');
expect(dtsContents)
.toContain(
'static ngComponentDef: i0.ɵɵComponentDefWithMeta<TestCmp, "test-cmp", never, {}, {}, never>');
'static ɵcmp: i0.ɵɵComponentDefWithMeta<TestCmp, "test-cmp", never, {}, {}, never>');
expect(dtsContents)
.toContain(
'static ngModuleDef: i0.ɵɵNgModuleDefWithMeta<TestModule, [typeof TestCmp], never, never>');
@ -602,7 +602,7 @@ runInEachFileSystem(os => {
import {ɵɵComponentDefWithMeta, ModuleWithProviders, ɵɵNgModuleDefWithMeta} from '@angular/core';
export declare class RouterComp {
static ngComponentDef: ɵɵComponentDefWithMeta<RouterComp, "lib-cmp", never, {}, {}, never>
static ɵcmp: ɵɵComponentDefWithMeta<RouterComp, "lib-cmp", never, {}, {}, never>
}
declare class RouterModule {
@ -1179,7 +1179,7 @@ runInEachFileSystem(os => {
const dtsContents = env.getContents('test.d.ts');
// Validate that each class has the primary definition.
expect(jsContents).toContain('TestCmp.ngComponentDef =');
expect(jsContents).toContain('TestCmp.ɵcmp =');
expect(jsContents).toContain('TestDir.ngDirectiveDef =');
expect(jsContents).toContain('TestPipe.ngPipeDef =');
expect(jsContents).toContain('TestNgModule.ngModuleDef =');