Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
gatherDiagnosticsForInputsOnly(compilerOpts, bazelOpts, program);
}
const {diagnostics, emitResult, program} = ng.performCompilation({
rootNames: files,
options: compilerOpts,
host: ngHost, emitCallback,
mergeEmitResultsCallback: tsickle.mergeEmitResults, gatherDiagnostics
});
const tsickleEmitResult = emitResult as tsickle.EmitResult;
let externs = '/** @externs */\n';
if (!diagnostics.length) {
if (bazelOpts.tsickleGenerateExterns) {
externs += tsickle.getGeneratedExterns(tsickleEmitResult.externs);
}
if (bazelOpts.manifest) {
const manifest = constructManifest(tsickleEmitResult.modulesManifest, bazelHost);
fs.writeFileSync(bazelOpts.manifest, manifest);
}
}
// If compilation fails unexpectedly, performCompilation returns no program.
// Make sure not to crash but report the diagnostics.
if (!program) return {program, diagnostics};
if (!bazelOpts.nodeModulesPrefix) {
// If there is no node modules, then metadata.json should be emitted since
// there is no other way to obtain the information
generateMetadataJson(program.getTsProgram(), files, compilerOpts.rootDirs, bazelBin, tsHost);
}
if (bazelOpts.tsickleExternsPath) {
// Note: when tsickleExternsPath is provided, we always write a file as a
const emitResult = tsickle.emit(
this.program,
this.bazelHost,
this.bazelHost.writeFile,
);
const allDiagnostics = this.gatherDiagnosticsForInputsOnly();
allDiagnostics.push(...emitResult.diagnostics);
let externs = '/** @externs */\n';
if (!emitResult.diagnostics.length) {
if (this.bazelOpts.tsickleGenerateExterns) {
externs += tsickle.getGeneratedExterns(emitResult.externs);
}
if (this.bazelOpts.manifest) {
const manifest = constructManifest(
emitResult.modulesManifest,
this.bazelHost,
);
fs.writeFileSync(this.bazelOpts.manifest, manifest, 'utf8');
}
}
if (this.bazelOpts.tsickleExternsPath) {
fs.writeFileSync(this.bazelOpts.tsickleExternsPath, externs, 'utf8');
}
this.options.expectedOuts.forEach(outputFile => {
this.originalWriteFile(outputFile, '', false);
});
if (allDiagnostics.length) {