fix(compiler): compile .ngfactory.ts files even if nobody references them. (#16899)

This is especially important for library authors, as they will
not reference the .ngfactory.ts files.

Fixes #16741
This commit is contained in:
Tobias Bosch
2017-05-25 10:00:26 -07:00
committed by Chuck Jazdzewski
parent 966eb2fbd0
commit 573b8611bc
10 changed files with 165 additions and 58 deletions
+3 -2
View File
@@ -36,18 +36,19 @@ export class CodeGenerator {
public host: ts.CompilerHost, private compiler: compiler.AotCompiler,
private ngCompilerHost: CompilerHost) {}
codegen(): Promise<any> {
codegen(): Promise<string[]> {
return this.compiler
.analyzeModulesAsync(this.program.getSourceFiles().map(
sf => this.ngCompilerHost.getCanonicalFileName(sf.fileName)))
.then(analyzedModules => this.compiler.emitAllImpls(analyzedModules))
.then(generatedModules => {
generatedModules.forEach(generatedModule => {
return generatedModules.map(generatedModule => {
const sourceFile = this.program.getSourceFile(generatedModule.srcFileUrl);
const emitPath = this.ngCompilerHost.calculateEmitPath(generatedModule.genFileUrl);
const source =
generatedModule.source || compiler.toTypeScript(generatedModule, PREAMBLE);
this.host.writeFile(emitPath, source, false, () => {}, [sourceFile]);
return emitPath;
});
});
}