Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
join(this.project.workingPath.toString(), relativeOutput),
workingPath
].map(pathFromString);
if (this.project.workingPath != null) {
ts.outDir = join(this.project.workingPath.toString(), relativeOutput);
ng.outDir = ts.outDir;
}
const build = new Build(this.project.basePath, outputs, roots);
const {host, compiler} = createNgCompiler(compilerHost, program, ng, roots);
const generatedModules = await this.generateTemplateCode(compilerHost, host, compiler, program, build);
const metadataWriter = new MetadataWriterHost(compilerHost, ng, true);
const canonicalSources = program.getSourceFiles().map(sf => sf.fileName).concat(generatedModules);
const templatedProgram = createProgram(canonicalSources, ts, metadataWriter, program);
const originalWriteFile = compilerHost.writeFile.bind(compilerHost);
const writeFile = (filename: string, data: string, writeByteOrderMark: boolean, onError: (message: string) => void, sourceFiles: Array) => {
build.emit(filename, sourceFiles);
return originalWriteFile(filename, data, writeByteOrderMark, onError, sourceFiles);
};
const emitResult = templatedProgram.emit(undefined, writeFile);
if (emitResult) {
assertDiagnostics(emitResult.diagnostics);
private async generateTemplates(): Promise<[CompilerHost, Array]> {
const hostContext = new NodeCompilerHostContext();
const compiler = this.compilerFactory(hostContext);
const cli = new NgcCliOptions({
i18nFormat: null,
i18nFile: null,
locale: null,
basePath: this.ng.basePath
});
const generatedModules = await this.generateTemplateCode(compiler, cli);
const metadataWriter = new MetadataWriterHost(this.compilerHost, this.ng, true);
return [metadataWriter, generatedModules];
}
const hostContext = new NodeCompilerHostContext();
const ngCompiler = new TranslatingCompilerHost(program, options.angular, hostContext);
const cli = new NgcCliOptions({
i18nFormat: null,
i18nFile: null,
locale: null,
basePath: options.angular.basePath
});
const generator = CodeGenerator.create(options.angular, cli, program, compilerHost, hostContext, ngCompiler);
await generator.codegen();
const metadataWriter = new MetadataWriterHost(compilerHost, options.angular);
metadataWriter.writeFile = compilerHost.writeFile;
return metadataWriter;
};
export const compileTemplates = async (options: CompileOptions, program: Program, compilerHost: TsCompilerHost): Promise<[TsCompilerHost, Array]> => {
const hostContext = new NodeCompilerHostContext();
const ngCompiler = compilerFactory(program, options.angular, hostContext);
const cli = new NgcCliOptions({
i18nFormat: null,
i18nFile: null,
locale: null,
basePath: options.angular.basePath
});
const generatedModules = await generateAngularCode(program, ngCompiler, compilerHost, cli);
const metadataWriter = new MetadataWriterHost(compilerHost, options.angular);
metadataWriter.writeFile = compilerHost.writeFile;
return [metadataWriter, generatedModules];
};