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:
committed by
Chuck Jazdzewski
parent
966eb2fbd0
commit
573b8611bc
@@ -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;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user