fix(compiler): add PURE annotation to getInheritedFactory calls (#38291)
Currently the `getInheritedFactory` function is implemented to allow closure to remove the call if the base factory is unused. However, this method does not work with terser. By adding the PURE annotation, terser will also be able to remove the call when unused. PR Close #38291
This commit is contained in:

committed by
Alex Rickabaugh

parent
1de4fe5dbf
commit
03d8e317c4
@ -3815,7 +3815,8 @@ runInEachFileSystem(os => {
|
||||
|
||||
expect(jsContents)
|
||||
.toContain('function Base_Factory(t) { return new (t || Base)(i0.ɵɵinject(Dep)); }');
|
||||
expect(jsContents).toContain('var \u0275Child_BaseFactory = i0.ɵɵgetInheritedFactory(Child)');
|
||||
expect(jsContents)
|
||||
.toContain('var \u0275Child_BaseFactory = /*@__PURE__*/ i0.ɵɵgetInheritedFactory(Child)');
|
||||
expect(jsContents)
|
||||
.toContain('function Child_Factory(t) { return \u0275Child_BaseFactory(t || Child); }');
|
||||
expect(jsContents)
|
||||
@ -3842,7 +3843,8 @@ runInEachFileSystem(os => {
|
||||
env.driveMain();
|
||||
const jsContents = env.getContents('test.js');
|
||||
|
||||
expect(jsContents).toContain('var \u0275Dir_BaseFactory = i0.ɵɵgetInheritedFactory(Dir)');
|
||||
expect(jsContents)
|
||||
.toContain('var \u0275Dir_BaseFactory = /*@__PURE__*/ i0.ɵɵgetInheritedFactory(Dir)');
|
||||
});
|
||||
|
||||
it('should wrap "directives" in component metadata in a closure when forward references are present',
|
||||
|
Reference in New Issue
Block a user