refactor(core): rename ngFactoryDef to ɵfac (#33116)
Factory 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 ngFactoryDef to fac. 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" (ngPipeDef, 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 #33116
This commit is contained in:

committed by
Miško Hevery

parent
c3aaa5211e
commit
0de2a5e408
@ -44,7 +44,7 @@ describe('compiler compliance', () => {
|
||||
|
||||
// The factory should look like this:
|
||||
const factory =
|
||||
'MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
|
||||
'MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
|
||||
|
||||
// The template should look like this (where IDENT is a wild card for an identifier):
|
||||
const template = `
|
||||
@ -93,7 +93,7 @@ describe('compiler compliance', () => {
|
||||
|
||||
// The factory should look like this:
|
||||
const factory =
|
||||
'MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
|
||||
'MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
|
||||
|
||||
// The template should look like this (where IDENT is a wild card for an identifier):
|
||||
const template = `
|
||||
@ -141,7 +141,7 @@ describe('compiler compliance', () => {
|
||||
|
||||
// The factory should look like this:
|
||||
const factory =
|
||||
'MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
|
||||
'MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
|
||||
|
||||
// The template should look like this (where IDENT is a wild card for an identifier):
|
||||
const template = `
|
||||
@ -189,7 +189,7 @@ describe('compiler compliance', () => {
|
||||
|
||||
// The factory should look like this:
|
||||
const factory =
|
||||
'MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
|
||||
'MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
|
||||
|
||||
// The template should look like this (where IDENT is a wild card for an identifier):
|
||||
const template = `
|
||||
@ -305,7 +305,7 @@ describe('compiler compliance', () => {
|
||||
};
|
||||
|
||||
const factory =
|
||||
'MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
|
||||
'MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
|
||||
const template = `
|
||||
…
|
||||
consts: [[${AttributeMarker.Bindings}, "id"]],
|
||||
@ -360,7 +360,7 @@ describe('compiler compliance', () => {
|
||||
///////////////
|
||||
|
||||
const factory =
|
||||
'MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
|
||||
'MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
|
||||
const template = `
|
||||
template: function MyComponent_Template(rf, ctx) {
|
||||
if (rf & 1) {
|
||||
@ -475,7 +475,7 @@ describe('compiler compliance', () => {
|
||||
};
|
||||
|
||||
const factory =
|
||||
'MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
|
||||
'MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); }';
|
||||
const template = `
|
||||
MyComponent.ɵcmp = i0.ɵɵdefineComponent({type:MyComponent,selectors:[["my-component"]],
|
||||
decls: 1,
|
||||
@ -579,7 +579,7 @@ describe('compiler compliance', () => {
|
||||
});`;
|
||||
|
||||
const ChildComponentFactory =
|
||||
`ChildComponent.ngFactoryDef = function ChildComponent_Factory(t) { return new (t || ChildComponent)(); };`;
|
||||
`ChildComponent.ɵfac = function ChildComponent_Factory(t) { return new (t || ChildComponent)(); };`;
|
||||
|
||||
// SomeDirective definition should be:
|
||||
const SomeDirectiveDefinition = `
|
||||
@ -590,7 +590,7 @@ describe('compiler compliance', () => {
|
||||
`;
|
||||
|
||||
const SomeDirectiveFactory =
|
||||
`SomeDirective.ngFactoryDef = function SomeDirective_Factory(t) {return new (t || SomeDirective)(); };`;
|
||||
`SomeDirective.ɵfac = function SomeDirective_Factory(t) {return new (t || SomeDirective)(); };`;
|
||||
|
||||
// MyComponent definition should be:
|
||||
const MyComponentDefinition = `
|
||||
@ -613,17 +613,17 @@ describe('compiler compliance', () => {
|
||||
`;
|
||||
|
||||
const MyComponentFactory =
|
||||
`MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); };`;
|
||||
`MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); };`;
|
||||
|
||||
const result = compile(files, angularFiles);
|
||||
const source = result.source;
|
||||
|
||||
expectEmit(source, ChildComponentDefinition, 'Incorrect ChildComponent.ɵcmp');
|
||||
expectEmit(source, ChildComponentFactory, 'Incorrect ChildComponent.ngFactoryDef');
|
||||
expectEmit(source, ChildComponentFactory, 'Incorrect ChildComponent.ɵfac');
|
||||
expectEmit(source, SomeDirectiveDefinition, 'Incorrect SomeDirective.ɵdir');
|
||||
expectEmit(source, SomeDirectiveFactory, 'Incorrect SomeDirective.ngFactoryDef');
|
||||
expectEmit(source, SomeDirectiveFactory, 'Incorrect SomeDirective.ɵfac');
|
||||
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponentDefinition.ɵcmp');
|
||||
expectEmit(source, MyComponentFactory, 'Incorrect MyComponentDefinition.ngFactoryDef');
|
||||
expectEmit(source, MyComponentFactory, 'Incorrect MyComponentDefinition.ɵfac');
|
||||
});
|
||||
|
||||
it('should support complex selectors', () => {
|
||||
@ -653,7 +653,7 @@ describe('compiler compliance', () => {
|
||||
`;
|
||||
|
||||
const SomeDirectiveFactory =
|
||||
`SomeDirective.ngFactoryDef = function SomeDirective_Factory(t) {return new (t || SomeDirective)(); };`;
|
||||
`SomeDirective.ɵfac = function SomeDirective_Factory(t) {return new (t || SomeDirective)(); };`;
|
||||
|
||||
// OtherDirective definition should be:
|
||||
const OtherDirectiveDefinition = `
|
||||
@ -664,15 +664,15 @@ describe('compiler compliance', () => {
|
||||
`;
|
||||
|
||||
const OtherDirectiveFactory =
|
||||
`OtherDirective.ngFactoryDef = function OtherDirective_Factory(t) {return new (t || OtherDirective)(); };`;
|
||||
`OtherDirective.ɵfac = function OtherDirective_Factory(t) {return new (t || OtherDirective)(); };`;
|
||||
|
||||
const result = compile(files, angularFiles);
|
||||
const source = result.source;
|
||||
|
||||
expectEmit(source, SomeDirectiveDefinition, 'Incorrect SomeDirective.ɵdir');
|
||||
expectEmit(source, SomeDirectiveFactory, 'Incorrect SomeDirective.ngFactoryDef');
|
||||
expectEmit(source, SomeDirectiveFactory, 'Incorrect SomeDirective.ɵfac');
|
||||
expectEmit(source, OtherDirectiveDefinition, 'Incorrect OtherDirective.ɵdir');
|
||||
expectEmit(source, OtherDirectiveFactory, 'Incorrect OtherDirective.ngFactoryDef');
|
||||
expectEmit(source, OtherDirectiveFactory, 'Incorrect OtherDirective.ɵfac');
|
||||
});
|
||||
|
||||
it('should support components without selector', () => {
|
||||
@ -708,14 +708,13 @@ describe('compiler compliance', () => {
|
||||
`;
|
||||
|
||||
const EmptyOutletComponentFactory =
|
||||
`EmptyOutletComponent.ngFactoryDef = function EmptyOutletComponent_Factory(t) { return new (t || EmptyOutletComponent)(); };`;
|
||||
`EmptyOutletComponent.ɵfac = function EmptyOutletComponent_Factory(t) { return new (t || EmptyOutletComponent)(); };`;
|
||||
|
||||
const result = compile(files, angularFiles);
|
||||
const source = result.source;
|
||||
|
||||
expectEmit(source, EmptyOutletComponentDefinition, 'Incorrect EmptyOutletComponent.ɵcmp');
|
||||
expectEmit(
|
||||
source, EmptyOutletComponentFactory, 'Incorrect EmptyOutletComponent.ngFactoryDef');
|
||||
expectEmit(source, EmptyOutletComponentFactory, 'Incorrect EmptyOutletComponent.ɵfac');
|
||||
});
|
||||
|
||||
it('should not treat ElementRef, ViewContainerRef, or ChangeDetectorRef specially when injecting',
|
||||
@ -750,7 +749,7 @@ describe('compiler compliance', () => {
|
||||
encapsulation: 2
|
||||
});`;
|
||||
|
||||
const MyComponentFactory = `MyComponent.ngFactoryDef = function MyComponent_Factory(t) {
|
||||
const MyComponentFactory = `MyComponent.ɵfac = function MyComponent_Factory(t) {
|
||||
return new (t || MyComponent)(
|
||||
$r3$.ɵɵdirectiveInject($i$.ElementRef), $r3$.ɵɵdirectiveInject($i$.ViewContainerRef),
|
||||
$r3$.ɵɵdirectiveInject($i$.ChangeDetectorRef));
|
||||
@ -760,7 +759,7 @@ describe('compiler compliance', () => {
|
||||
const source = result.source;
|
||||
|
||||
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponent.ɵcmp');
|
||||
expectEmit(source, MyComponentFactory, 'Incorrect MyComponent.ngFactoryDef');
|
||||
expectEmit(source, MyComponentFactory, 'Incorrect MyComponent.ɵfac');
|
||||
});
|
||||
|
||||
it('should support structural directives', () => {
|
||||
@ -794,7 +793,7 @@ describe('compiler compliance', () => {
|
||||
selectors: [["", "if", ""]]
|
||||
});`;
|
||||
const IfDirectiveFactory =
|
||||
`IfDirective.ngFactoryDef = function IfDirective_Factory(t) { return new (t || IfDirective)($r3$.ɵɵdirectiveInject($i$.TemplateRef)); };`;
|
||||
`IfDirective.ɵfac = function IfDirective_Factory(t) { return new (t || IfDirective)($r3$.ɵɵdirectiveInject($i$.TemplateRef)); };`;
|
||||
|
||||
const MyComponentDefinition = `
|
||||
const $c1$ = ["foo", ""];
|
||||
@ -830,15 +829,15 @@ describe('compiler compliance', () => {
|
||||
});`;
|
||||
|
||||
const MyComponentFactory =
|
||||
`MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); };`;
|
||||
`MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); };`;
|
||||
|
||||
const result = compile(files, angularFiles);
|
||||
const source = result.source;
|
||||
|
||||
expectEmit(source, IfDirectiveDefinition, 'Incorrect IfDirective.ɵdir');
|
||||
expectEmit(source, IfDirectiveFactory, 'Incorrect IfDirective.ngFactoryDef');
|
||||
expectEmit(source, IfDirectiveFactory, 'Incorrect IfDirective.ɵfac');
|
||||
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponent.ɵcmp');
|
||||
expectEmit(source, MyComponentFactory, 'Incorrect MyComponent.ngFactoryDef');
|
||||
expectEmit(source, MyComponentFactory, 'Incorrect MyComponent.ɵfac');
|
||||
});
|
||||
|
||||
describe('value composition', () => {
|
||||
@ -2024,8 +2023,8 @@ describe('compiler compliance', () => {
|
||||
});
|
||||
`;
|
||||
|
||||
const MyPipengFactoryDef = `
|
||||
MyPipe.ngFactoryDef = function MyPipe_Factory(t) { return new (t || MyPipe)(); };
|
||||
const MyPipeFactoryDef = `
|
||||
MyPipe.ɵfac = function MyPipe_Factory(t) { return new (t || MyPipe)(); };
|
||||
`;
|
||||
|
||||
const MyPurePipeDefinition = `
|
||||
@ -2035,8 +2034,8 @@ describe('compiler compliance', () => {
|
||||
pure: true
|
||||
});`;
|
||||
|
||||
const MyPurePipengFactoryDef = `
|
||||
MyPurePipe.ngFactoryDef = function MyPurePipe_Factory(t) { return new (t || MyPurePipe)(); };
|
||||
const MyPurePipeFactoryDef = `
|
||||
MyPurePipe.ɵfac = function MyPurePipe_Factory(t) { return new (t || MyPurePipe)(); };
|
||||
`;
|
||||
|
||||
const MyAppDefinition = `
|
||||
@ -2074,9 +2073,9 @@ describe('compiler compliance', () => {
|
||||
const source = result.source;
|
||||
|
||||
expectEmit(source, MyPipeDefinition, 'Invalid pipe definition');
|
||||
expectEmit(source, MyPipengFactoryDef, 'Invalid pipe factory function');
|
||||
expectEmit(source, MyPipeFactoryDef, 'Invalid pipe factory function');
|
||||
expectEmit(source, MyPurePipeDefinition, 'Invalid pure pipe definition');
|
||||
expectEmit(source, MyPurePipengFactoryDef, 'Invalid pure pipe factory function');
|
||||
expectEmit(source, MyPurePipeFactoryDef, 'Invalid pure pipe factory function');
|
||||
expectEmit(source, MyAppDefinition, 'Invalid MyApp definition');
|
||||
});
|
||||
|
||||
@ -2191,7 +2190,7 @@ describe('compiler compliance', () => {
|
||||
`;
|
||||
|
||||
const MyPipeFactory = `
|
||||
MyPipe.ngFactoryDef = function MyPipe_Factory(t) { return new (t || MyPipe)($r3$.ɵɵinjectPipeChangeDetectorRef()); };
|
||||
MyPipe.ɵfac = function MyPipe_Factory(t) { return new (t || MyPipe)($r3$.ɵɵinjectPipeChangeDetectorRef()); };
|
||||
`;
|
||||
|
||||
const MyOtherPipeDefinition = `
|
||||
@ -2202,7 +2201,7 @@ describe('compiler compliance', () => {
|
||||
});`;
|
||||
|
||||
const MyOtherPipeFactory = `
|
||||
MyOtherPipe.ngFactoryDef = function MyOtherPipe_Factory(t) { return new (t || MyOtherPipe)($r3$.ɵɵinjectPipeChangeDetectorRef(8)); };
|
||||
MyOtherPipe.ɵfac = function MyOtherPipe_Factory(t) { return new (t || MyOtherPipe)($r3$.ɵɵinjectPipeChangeDetectorRef(8)); };
|
||||
`;
|
||||
|
||||
const result = compile(files, angularFiles);
|
||||
@ -2603,8 +2602,7 @@ describe('compiler compliance', () => {
|
||||
});
|
||||
`;
|
||||
|
||||
const ForDirectiveFactory =
|
||||
`ForOfDirective.ngFactoryDef = function ForOfDirective_Factory(t) {
|
||||
const ForDirectiveFactory = `ForOfDirective.ɵfac = function ForOfDirective_Factory(t) {
|
||||
return new (t || ForOfDirective)($r3$.ɵɵdirectiveInject(ViewContainerRef), $r3$.ɵɵdirectiveInject(TemplateRef));
|
||||
};`;
|
||||
|
||||
@ -2685,7 +2683,7 @@ describe('compiler compliance', () => {
|
||||
`;
|
||||
|
||||
const ForDirectiveFactory = `
|
||||
ForOfDirective.ngFactoryDef = function ForOfDirective_Factory(t) {
|
||||
ForOfDirective.ɵfac = function ForOfDirective_Factory(t) {
|
||||
return new (t || ForOfDirective)($r3$.ɵɵdirectiveInject(ViewContainerRef), $r3$.ɵɵdirectiveInject(TemplateRef));
|
||||
};
|
||||
`;
|
||||
|
@ -48,7 +48,7 @@ describe('compiler compliance: dependency injection', () => {
|
||||
};
|
||||
|
||||
const factory = `
|
||||
MyComponent.ngFactoryDef = function MyComponent_Factory(t) {
|
||||
MyComponent.ɵfac = function MyComponent_Factory(t) {
|
||||
return new (t || MyComponent)(
|
||||
$r3$.ɵɵinjectAttribute('name'),
|
||||
$r3$.ɵɵdirectiveInject(MyService),
|
||||
@ -83,7 +83,7 @@ describe('compiler compliance: dependency injection', () => {
|
||||
};
|
||||
|
||||
const factory = `
|
||||
MyService.ngFactoryDef = function MyService_Factory(t) {
|
||||
MyService.ɵfac = function MyService_Factory(t) {
|
||||
return new (t || MyService)($r3$.ɵɵinject(MyDependency));
|
||||
}`;
|
||||
|
||||
@ -91,7 +91,7 @@ describe('compiler compliance: dependency injection', () => {
|
||||
MyService.ngInjectableDef = $r3$.ɵɵdefineInjectable({
|
||||
token: MyService,
|
||||
factory: function(t) {
|
||||
return MyService.ngFactoryDef(t);
|
||||
return MyService.ɵfac(t);
|
||||
},
|
||||
providedIn: null
|
||||
});
|
||||
@ -102,7 +102,7 @@ describe('compiler compliance: dependency injection', () => {
|
||||
expectEmit(result.source, def, 'Incorrect injectable definition');
|
||||
});
|
||||
|
||||
it('should create a single ngFactoryDef if the class has more than one decorator', () => {
|
||||
it('should create a single factory def if the class has more than one decorator', () => {
|
||||
const files = {
|
||||
app: {
|
||||
'spec.ts': `
|
||||
@ -117,7 +117,7 @@ describe('compiler compliance: dependency injection', () => {
|
||||
};
|
||||
|
||||
const result = compile(files, angularFiles).source;
|
||||
const matches = result.match(/MyPipe\.ngFactoryDef = function MyPipe_Factory/g);
|
||||
const matches = result.match(/MyPipe\.ɵfac = function MyPipe_Factory/g);
|
||||
expect(matches ? matches.length : 0).toBe(1);
|
||||
});
|
||||
|
||||
@ -220,7 +220,7 @@ describe('compiler compliance: dependency injection', () => {
|
||||
MyService.ngInjectableDef = $r3$.ɵɵdefineInjectable({
|
||||
token: MyService,
|
||||
factory: function(t) {
|
||||
return MyAlternateService.ngFactoryDef(t);
|
||||
return MyAlternateService.ɵfac(t);
|
||||
},
|
||||
providedIn: null
|
||||
});
|
||||
@ -293,7 +293,7 @@ describe('compiler compliance: dependency injection', () => {
|
||||
SomeProvider.ngInjectableDef = $r3$.ɵɵdefineInjectable({
|
||||
token: SomeProvider,
|
||||
factory: function(t) {
|
||||
return SomeProviderImpl.ngFactoryDef(t);
|
||||
return SomeProviderImpl.ɵfac(t);
|
||||
},
|
||||
providedIn: 'root'
|
||||
});
|
||||
@ -343,17 +343,17 @@ describe('compiler compliance: dependency injection', () => {
|
||||
const source = result.source;
|
||||
|
||||
const MyPipeFactory = `
|
||||
MyPipe.ngFactoryDef = function MyPipe_Factory(t) { return new (t || MyPipe)($r3$.ɵɵdirectiveInject(Service)); };
|
||||
MyPipe.ɵfac = function MyPipe_Factory(t) { return new (t || MyPipe)($r3$.ɵɵdirectiveInject(Service)); };
|
||||
`;
|
||||
|
||||
const MyOtherPipeFactory = `
|
||||
MyOtherPipe.ngFactoryDef = function MyOtherPipe_Factory(t) { return new (t || MyOtherPipe)($r3$.ɵɵdirectiveInject(Service)); };
|
||||
MyOtherPipe.ɵfac = function MyOtherPipe_Factory(t) { return new (t || MyOtherPipe)($r3$.ɵɵdirectiveInject(Service)); };
|
||||
`;
|
||||
|
||||
expectEmit(source, MyPipeFactory, 'Invalid pipe factory function');
|
||||
expectEmit(source, MyOtherPipeFactory, 'Invalid pipe factory function');
|
||||
expect(source.match(/MyPipe\.ngFactoryDef =/g) !.length).toBe(1);
|
||||
expect(source.match(/MyOtherPipe\.ngFactoryDef =/g) !.length).toBe(1);
|
||||
expect(source.match(/MyPipe\.ɵfac =/g) !.length).toBe(1);
|
||||
expect(source.match(/MyOtherPipe\.ɵfac =/g) !.length).toBe(1);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -53,14 +53,14 @@ describe('compiler compliance: directives', () => {
|
||||
`;
|
||||
|
||||
const MyComponentFactory = `
|
||||
MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
|
||||
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
|
||||
`;
|
||||
|
||||
const result = compile(files, angularFiles);
|
||||
const source = result.source;
|
||||
|
||||
expectEmit(source, MyComponentDefinition, 'Incorrect ChildComponent.ɵcmp');
|
||||
expectEmit(source, MyComponentFactory, 'Incorrect ChildComponent.ngFactoryDef');
|
||||
expectEmit(source, MyComponentFactory, 'Incorrect ChildComponent.ɵfac');
|
||||
});
|
||||
|
||||
it('should not match directives on i18n-prefixed attributes', () => {
|
||||
@ -103,14 +103,14 @@ describe('compiler compliance: directives', () => {
|
||||
`;
|
||||
|
||||
const MyComponentFactory = `
|
||||
MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
|
||||
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
|
||||
`;
|
||||
|
||||
const result = compile(files, angularFiles);
|
||||
const source = result.source;
|
||||
|
||||
expectEmit(source, MyComponentDefinition, 'Incorrect ChildComponent.ɵcmp');
|
||||
expectEmit(source, MyComponentFactory, 'Incorrect ChildComponent.ngFactoryDef');
|
||||
expectEmit(source, MyComponentFactory, 'Incorrect ChildComponent.ɵfac');
|
||||
});
|
||||
|
||||
it('should match directives on element bindings', () => {
|
||||
|
@ -220,14 +220,14 @@ describe('compiler compliance: listen()', () => {
|
||||
`;
|
||||
|
||||
const MyComponentFactory = `
|
||||
MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
|
||||
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
|
||||
`;
|
||||
|
||||
const result = compile(files, angularFiles);
|
||||
const source = result.source;
|
||||
|
||||
expectEmit(source, MyComponentDefinition, 'Incorrect MyComponent.ɵcmp');
|
||||
expectEmit(source, MyComponentFactory, 'Incorrect MyComponent.ngFactoryDef');
|
||||
expectEmit(source, MyComponentFactory, 'Incorrect MyComponent.ɵfac');
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -144,7 +144,7 @@ describe('compiler compliance: providers', () => {
|
||||
result.source, `
|
||||
export class MyComponent {
|
||||
}
|
||||
MyComponent.ngFactoryDef = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
|
||||
MyComponent.ɵfac = function MyComponent_Factory(t) { return new (t || MyComponent)(); };
|
||||
MyComponent.ɵcmp = i0.ɵɵdefineComponent({
|
||||
type: MyComponent,
|
||||
selectors: [["my-component"]],
|
||||
|
@ -67,8 +67,8 @@ runInEachFileSystem(os => {
|
||||
const dtsContents = env.getContents('test.d.ts');
|
||||
expect(dtsContents).toContain('static ngInjectableDef: i0.ɵɵInjectableDef<Dep>;');
|
||||
expect(dtsContents).toContain('static ngInjectableDef: i0.ɵɵInjectableDef<Service>;');
|
||||
expect(dtsContents).toContain('static ngFactoryDef: i0.ɵɵFactoryDef<Dep>;');
|
||||
expect(dtsContents).toContain('static ngFactoryDef: i0.ɵɵFactoryDef<Service>;');
|
||||
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDef<Dep>;');
|
||||
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDef<Service>;');
|
||||
});
|
||||
|
||||
it('should compile Injectables with a generic service', () => {
|
||||
@ -85,7 +85,7 @@ runInEachFileSystem(os => {
|
||||
const jsContents = env.getContents('test.js');
|
||||
expect(jsContents).toContain('Store.ngInjectableDef =');
|
||||
const dtsContents = env.getContents('test.d.ts');
|
||||
expect(dtsContents).toContain('static ngFactoryDef: i0.ɵɵFactoryDef<Store<any>>;');
|
||||
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDef<Store<any>>;');
|
||||
expect(dtsContents).toContain('static ngInjectableDef: i0.ɵɵInjectableDef<Store<any>>;');
|
||||
});
|
||||
|
||||
@ -110,14 +110,14 @@ runInEachFileSystem(os => {
|
||||
expect(jsContents).toContain('Service.ngInjectableDef =');
|
||||
expect(jsContents)
|
||||
.toContain(
|
||||
'Service.ngFactoryDef = function Service_Factory(t) { return new (t || Service)(i0.ɵɵinject(Dep)); };');
|
||||
'Service.ɵfac = function Service_Factory(t) { return new (t || Service)(i0.ɵɵinject(Dep)); };');
|
||||
expect(jsContents).toContain('providedIn: \'root\' })');
|
||||
expect(jsContents).not.toContain('__decorate');
|
||||
const dtsContents = env.getContents('test.d.ts');
|
||||
expect(dtsContents).toContain('static ngInjectableDef: i0.ɵɵInjectableDef<Dep>;');
|
||||
expect(dtsContents).toContain('static ngInjectableDef: i0.ɵɵInjectableDef<Service>;');
|
||||
expect(dtsContents).toContain('static ngFactoryDef: i0.ɵɵFactoryDef<Dep>;');
|
||||
expect(dtsContents).toContain('static ngFactoryDef: i0.ɵɵFactoryDef<Service>;');
|
||||
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDef<Dep>;');
|
||||
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDef<Service>;');
|
||||
});
|
||||
|
||||
it('should compile Injectables with providedIn and factory without errors', () => {
|
||||
@ -142,7 +142,7 @@ runInEachFileSystem(os => {
|
||||
expect(jsContents).not.toContain('__decorate');
|
||||
const dtsContents = env.getContents('test.d.ts');
|
||||
expect(dtsContents).toContain('static ngInjectableDef: i0.ɵɵInjectableDef<Service>;');
|
||||
expect(dtsContents).toContain('static ngFactoryDef: i0.ɵɵFactoryDef<Service>;');
|
||||
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDef<Service>;');
|
||||
});
|
||||
|
||||
it('should compile Injectables with providedIn and factory with deps without errors', () => {
|
||||
@ -171,7 +171,7 @@ runInEachFileSystem(os => {
|
||||
expect(jsContents).not.toContain('__decorate');
|
||||
const dtsContents = env.getContents('test.d.ts');
|
||||
expect(dtsContents).toContain('static ngInjectableDef: i0.ɵɵInjectableDef<Service>;');
|
||||
expect(dtsContents).toContain('static ngFactoryDef: i0.ɵɵFactoryDef<Service>;');
|
||||
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDef<Service>;');
|
||||
});
|
||||
|
||||
it('should compile @Injectable with an @Optional dependency', () => {
|
||||
@ -206,14 +206,14 @@ runInEachFileSystem(os => {
|
||||
|
||||
const jsContents = env.getContents('test.js');
|
||||
expect(jsContents).toContain('TestCmp.ɵcmp = i0.ɵɵdefineComponent');
|
||||
expect(jsContents).toContain('TestCmp.ngFactoryDef = function');
|
||||
expect(jsContents).toContain('TestCmp.ɵfac = function');
|
||||
expect(jsContents).not.toContain('__decorate');
|
||||
|
||||
const dtsContents = env.getContents('test.d.ts');
|
||||
expect(dtsContents)
|
||||
.toContain(
|
||||
'static ɵcmp: i0.ɵɵComponentDefWithMeta<TestCmp, "test-cmp", never, {}, {}, never>');
|
||||
expect(dtsContents).toContain('static ngFactoryDef: i0.ɵɵFactoryDef<TestCmp>');
|
||||
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDef<TestCmp>');
|
||||
});
|
||||
|
||||
it('should compile Components (dynamic inline template) without errors', () => {
|
||||
@ -231,7 +231,7 @@ runInEachFileSystem(os => {
|
||||
|
||||
const jsContents = env.getContents('test.js');
|
||||
expect(jsContents).toContain('TestCmp.ɵcmp = i0.ɵɵdefineComponent');
|
||||
expect(jsContents).toContain('TestCmp.ngFactoryDef = function');
|
||||
expect(jsContents).toContain('TestCmp.ɵfac = function');
|
||||
expect(jsContents).not.toContain('__decorate');
|
||||
|
||||
const dtsContents = env.getContents('test.d.ts');
|
||||
@ -239,7 +239,7 @@ runInEachFileSystem(os => {
|
||||
expect(dtsContents)
|
||||
.toContain(
|
||||
'static ɵcmp: i0.ɵɵComponentDefWithMeta<TestCmp, "test-cmp", never, {}, {}, never>');
|
||||
expect(dtsContents).toContain('static ngFactoryDef: i0.ɵɵFactoryDef<TestCmp>');
|
||||
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDef<TestCmp>');
|
||||
});
|
||||
|
||||
it('should compile Components (function call inline template) without errors', () => {
|
||||
@ -260,14 +260,14 @@ runInEachFileSystem(os => {
|
||||
|
||||
const jsContents = env.getContents('test.js');
|
||||
expect(jsContents).toContain('TestCmp.ɵcmp = i0.ɵɵdefineComponent');
|
||||
expect(jsContents).toContain('TestCmp.ngFactoryDef = function');
|
||||
expect(jsContents).toContain('TestCmp.ɵfac = function');
|
||||
expect(jsContents).not.toContain('__decorate');
|
||||
|
||||
const dtsContents = env.getContents('test.d.ts');
|
||||
expect(dtsContents)
|
||||
.toContain(
|
||||
'static ɵcmp: i0.ɵɵComponentDefWithMeta<TestCmp, "test-cmp", never, {}, {}, never>');
|
||||
expect(dtsContents).toContain('static ngFactoryDef: i0.ɵɵFactoryDef<TestCmp>');
|
||||
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDef<TestCmp>');
|
||||
});
|
||||
|
||||
it('should compile Components (external template) without errors', () => {
|
||||
@ -899,10 +899,10 @@ runInEachFileSystem(os => {
|
||||
'TestPipe.ngPipeDef = i0.ɵɵdefinePipe({ name: "test-pipe", type: TestPipe, pure: false })');
|
||||
expect(jsContents)
|
||||
.toContain(
|
||||
'TestPipe.ngFactoryDef = function TestPipe_Factory(t) { return new (t || TestPipe)(); }');
|
||||
'TestPipe.ɵfac = function TestPipe_Factory(t) { return new (t || TestPipe)(); }');
|
||||
expect(dtsContents)
|
||||
.toContain('static ngPipeDef: i0.ɵɵPipeDefWithMeta<TestPipe, "test-pipe">;');
|
||||
expect(dtsContents).toContain('static ngFactoryDef: i0.ɵɵFactoryDef<TestPipe>;');
|
||||
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDef<TestPipe>;');
|
||||
});
|
||||
|
||||
it('should compile pure Pipes without errors', () => {
|
||||
@ -925,10 +925,10 @@ runInEachFileSystem(os => {
|
||||
'TestPipe.ngPipeDef = i0.ɵɵdefinePipe({ name: "test-pipe", type: TestPipe, pure: true })');
|
||||
expect(jsContents)
|
||||
.toContain(
|
||||
'TestPipe.ngFactoryDef = function TestPipe_Factory(t) { return new (t || TestPipe)(); }');
|
||||
'TestPipe.ɵfac = function TestPipe_Factory(t) { return new (t || TestPipe)(); }');
|
||||
expect(dtsContents)
|
||||
.toContain('static ngPipeDef: i0.ɵɵPipeDefWithMeta<TestPipe, "test-pipe">;');
|
||||
expect(dtsContents).toContain('static ngFactoryDef: i0.ɵɵFactoryDef<TestPipe>;');
|
||||
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDef<TestPipe>;');
|
||||
});
|
||||
|
||||
it('should compile Pipes with dependencies', () => {
|
||||
@ -969,7 +969,7 @@ runInEachFileSystem(os => {
|
||||
const dtsContents = env.getContents('test.d.ts');
|
||||
expect(dtsContents)
|
||||
.toContain('static ngPipeDef: i0.ɵɵPipeDefWithMeta<TestPipe<any>, "test-pipe">;');
|
||||
expect(dtsContents).toContain('static ngFactoryDef: i0.ɵɵFactoryDef<TestPipe<any>>;');
|
||||
expect(dtsContents).toContain('static ɵfac: i0.ɵɵFactoryDef<TestPipe<any>>;');
|
||||
});
|
||||
|
||||
it('should include @Pipes in @NgModule scopes', () => {
|
||||
@ -1309,8 +1309,7 @@ runInEachFileSystem(os => {
|
||||
|
||||
env.driveMain();
|
||||
const jsContents = env.getContents('test.js');
|
||||
expect(jsContents)
|
||||
.toContain('Test.ngFactoryDef = function Test_Factory(t) { throw new Error(');
|
||||
expect(jsContents).toContain('Test.ɵfac = function Test_Factory(t) { throw new Error(');
|
||||
});
|
||||
|
||||
it('should compile an @Injectable provided in the root on a class with a non-injectable constructor',
|
||||
@ -1327,7 +1326,7 @@ runInEachFileSystem(os => {
|
||||
env.driveMain();
|
||||
const jsContents = env.getContents('test.js');
|
||||
expect(jsContents)
|
||||
.toContain('Test.ngFactoryDef = function Test_Factory(t) { throw new Error(');
|
||||
.toContain('Test.ɵfac = function Test_Factory(t) { throw new Error(');
|
||||
});
|
||||
|
||||
});
|
||||
@ -1640,7 +1639,7 @@ runInEachFileSystem(os => {
|
||||
const jsContents = env.getContents('test.js');
|
||||
expect(jsContents)
|
||||
.toContain(
|
||||
`FooCmp.ngFactoryDef = function FooCmp_Factory(t) { return new (t || FooCmp)(i0.ɵɵinjectAttribute("test"), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef), i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.Injector), i0.ɵɵdirectiveInject(i0.Renderer2), i0.ɵɵdirectiveInject(i0.TemplateRef), i0.ɵɵdirectiveInject(i0.ViewContainerRef)); }`);
|
||||
`FooCmp.ɵfac = function FooCmp_Factory(t) { return new (t || FooCmp)(i0.ɵɵinjectAttribute("test"), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef), i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.Injector), i0.ɵɵdirectiveInject(i0.Renderer2), i0.ɵɵdirectiveInject(i0.TemplateRef), i0.ɵɵdirectiveInject(i0.ViewContainerRef)); }`);
|
||||
});
|
||||
|
||||
it('should generate queries for components', () => {
|
||||
|
Reference in New Issue
Block a user