diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2019-02-06 00:12:58 +1100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-02-05 08:12:58 -0500 |
commit | 48fedee34e567570e43905dc9f32d0d78118b9b0 (patch) | |
tree | 4576c5152db483762e5ae53571926903239a0262 /tools/ts_library_builder/ast_util.ts | |
parent | 748b0f9c9d267dddf6f59c9d2ca8728bc76e630f (diff) |
Add WebAssembly to runtime library (#1677)
This also modifies the `ts_library_builder` to support inlining assets.
Includes integration tests from @sh7dm
Diffstat (limited to 'tools/ts_library_builder/ast_util.ts')
-rw-r--r-- | tools/ts_library_builder/ast_util.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/ts_library_builder/ast_util.ts b/tools/ts_library_builder/ast_util.ts index 9bb7e8edc..58aa7fb9c 100644 --- a/tools/ts_library_builder/ast_util.ts +++ b/tools/ts_library_builder/ast_util.ts @@ -243,6 +243,32 @@ export function getSourceComment( return `\n// @url ${relative(rootPath, sourceFile.getFilePath())}\n\n`; } +interface InlineFilesOptions { + basePath: string; + debug?: boolean; + inline: string[]; + targetSourceFile: SourceFile; +} + +/** Inline files into the target source file. */ +export function inlineFiles({ + basePath, + debug, + inline, + targetSourceFile +}: InlineFilesOptions) { + for (const filename of inline) { + const text = readFileSync(filename, { + encoding: "utf8" + }); + targetSourceFile.addStatements( + debug + ? `\n// @url ${relative(basePath, filename)}\n\n${text}` + : `\n${text}` + ); + } +} + /** * Load and write to a virtual file system all the default libs needed to * resolve types on project. |