fix(ivy): copy top-level comments into generated factory shims (#29065)
When ngtsc generates a .ngfactory shim, it does so based on the contents of an original file in the program. Occasionally these original files have comments at the top which are load-bearing (e.g. they contain jsdoc annotations which are significant to downstream bundling tools). The generated factory shims should preserve this comment. This commit adds a step to the ngfactory generator to preserve the top-level comment from the original source file. FW-1006 #resolve FW-1095 #resolve PR Close #29065
This commit is contained in:

committed by
Andrew Kushnir

parent
04cf4ef0c7
commit
866d500324
@ -1694,6 +1694,22 @@ describe('ngtsc behavioral tests', () => {
|
||||
expect(emptyFactory).toContain(`export var ɵNonEmptyModule = true;`);
|
||||
});
|
||||
|
||||
it('should copy a top-level comment into a factory stub', () => {
|
||||
env.tsconfig({'allowEmptyCodegenFiles': true});
|
||||
|
||||
env.write('test.ts', `/** I am a top-level comment. */
|
||||
import {NgModule} from '@angular/core';
|
||||
|
||||
@NgModule({})
|
||||
export class TestModule {}
|
||||
`);
|
||||
|
||||
env.driveMain();
|
||||
|
||||
const factoryContents = env.getContents('test.ngfactory.js');
|
||||
expect(factoryContents).toMatch(/^\/\*\* I am a top-level comment\. \*\//);
|
||||
});
|
||||
|
||||
it('should be able to compile an app using the factory shim', () => {
|
||||
env.tsconfig({'allowEmptyCodegenFiles': true});
|
||||
|
||||
|
Reference in New Issue
Block a user