fix(compiler-cli): merge @fileoverview comments. (#20870)

Previously, this code would unconditionally add a @fileoverview
comment to generated files, and only if the contained any code at all.

However often existing fileoverview comments should be copied from the
file the generated file was originally based off of. This allows users
to e.g. include Closure Compiler directives in their original
`component.ts` file, which will then automaticallly also apply to code
generated from it.

This special cases `@license` comments, as Closure disregards directives
in comments containing `@license`.

PR Close #20870
This commit is contained in:
Martin Probst
2017-12-07 17:52:16 +01:00
committed by Jason Aden
parent 1f469497da
commit be9a7371b8
5 changed files with 157 additions and 27 deletions

View File

@ -437,7 +437,8 @@ describe('ng program', () => {
sf => sf.fileName === path.join(testSupport.basePath, checks.originalFileName)))
.toBe(true);
if (checks.shouldBeEmpty) {
expect(writeData !.data).toBe('');
// The file should only contain comments (the preamble comment added by ngc).
expect(writeData !.data).toMatch(/^(\s*\/\*([^*]|\*[^/])*\*\/\s*)?$/);
} else {
expect(writeData !.data).not.toBe('');
}