Skip to content

Commit

Permalink
Fix issue with runtime lib generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
kitsonk authored and ry committed Nov 5, 2018
1 parent bd88e56 commit 5e48a68
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tools/ts_library_builder/ast_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
11 changes: 11 additions & 0 deletions tools/ts_library_builder/build_library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
addInterfaceProperty,
addSourceComment,
addVariableDeclaration,
appendSourceFile,
checkDiagnostics,
flattenNamespace,
getSourceComment,
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 5e48a68

Please sign in to comment.