summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2018-11-05 16:07:11 +1100
committerRyan Dahl <ry@tinyclouds.org>2018-11-05 07:17:47 -0800
commit5e48a681c4d6d6cb3debb4024b5108780dbbad90 (patch)
tree0def78c67885a2752d3227836ac489066c211aed
parentbd88e56cbc6e64da471b379f996bac6c564a7e1e (diff)
Fix issue with runtime lib generation.
-rw-r--r--tools/ts_library_builder/ast_util.ts8
-rw-r--r--tools/ts_library_builder/build_library.ts11
2 files changed, 19 insertions, 0 deletions
diff --git a/tools/ts_library_builder/ast_util.ts b/tools/ts_library_builder/ast_util.ts
index 81fc45f0c..528036b99 100644
--- a/tools/ts_library_builder/ast_util.ts
+++ b/tools/ts_library_builder/ast_util.ts
@@ -58,6 +58,14 @@ export function addVariableDeclaration(
});
}
+/** Copy one source file to the end of another source file. */
+export function appendSourceFile(
+ sourceFile: SourceFile,
+ targetSourceFile: SourceFile
+): void {
+ targetSourceFile.addStatements(`\n${sourceFile.print()}`);
+}
+
/** Check diagnostics, and if any exist, exit the process */
export function checkDiagnostics(project: Project, onlyFor?: string[]) {
const program = project.getProgram();
diff --git a/tools/ts_library_builder/build_library.ts b/tools/ts_library_builder/build_library.ts
index 05cd4013b..af3fb599d 100644
--- a/tools/ts_library_builder/build_library.ts
+++ b/tools/ts_library_builder/build_library.ts
@@ -13,6 +13,7 @@ import {
addInterfaceProperty,
addSourceComment,
addVariableDeclaration,
+ appendSourceFile,
checkDiagnostics,
flattenNamespace,
getSourceComment,
@@ -421,6 +422,16 @@ export function main({
console.log(`Merged "globals" into global scope.`);
}
+ // Since we flatten the namespaces, we don't attempt to import `text-encoding`
+ // so we then need to concatenate that onto the `libDts` so it can stand on
+ // its own.
+ const textEncodingSourceFile = outputProject.getSourceFileOrThrow(
+ textEncodingFilePath
+ );
+ appendSourceFile(textEncodingSourceFile, libDTs);
+ // Removing it from the project so we know the libDTs can stand on its own.
+ outputProject.removeSourceFile(textEncodingSourceFile);
+
// Add the preamble
libDTs.insertStatements(0, libPreamble);