From 765f229357587fb66dfe04d3c48d62c6aae9ce71 Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Sun, 4 Nov 2018 10:45:06 +1100 Subject: Improve robustness of lib builder. --- tools/ts_library_builder/build_library.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tools/ts_library_builder/build_library.ts') diff --git a/tools/ts_library_builder/build_library.ts b/tools/ts_library_builder/build_library.ts index e4111fe21..05cd4013b 100644 --- a/tools/ts_library_builder/build_library.ts +++ b/tools/ts_library_builder/build_library.ts @@ -18,6 +18,7 @@ import { getSourceComment, loadDtsFiles, loadFiles, + logDiagnostics, namespaceSourceFile, normalizeSlashes } from "./ast_util"; @@ -222,6 +223,7 @@ export function mergeGlobal({ // declaration source file into a namespace that exists within the merged // namespace const importDeclarations = sourceFile.getImportDeclarations(); + const namespaces = new Set(); for (const declaration of importDeclarations) { const declarationSourceFile = declaration.getModuleSpecifierSourceFile(); if ( @@ -241,6 +243,7 @@ export function mergeGlobal({ namespaceSourceFile(dtsSourceFile, { debug, namespace: declaration.getNamespaceImportOrThrow().getText(), + namespaces, rootPath: basePath, sourceFileMap }) @@ -308,6 +311,14 @@ export function main({ // emit the project, which will be only the declaration files const inputEmitResult = inputProject.emitToMemory(); + const inputDiagnostics = inputEmitResult + .getDiagnostics() + .map(d => d.compilerObject); + logDiagnostics(inputDiagnostics); + if (inputDiagnostics.length) { + process.exit(1); + } + // the declaration project will be the target for the emitted files from // the input project, these will be used to transfer information over to // the final library file -- cgit v1.2.3