Skip to content

Commit d1275a4

Browse files
committed
Use plugin afterPrint results array to create bundle
1 parent 0fea440 commit d1275a4

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/lualib-build/plugin.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as ts from "typescript";
33
import * as tstl from "..";
44
import * as path from "path";
55
import { getUsedLuaLibFeatures } from "../transformation/utils/lualib";
6-
import { loadInlineLualibFeatures, LuaLibFeature, LuaLibModulesInfo, luaLibModulesInfoFileName } from "../LuaLib";
6+
import { LuaLibFeature, LuaLibModulesInfo, luaLibModulesInfoFileName } from "../LuaLib";
77
import { EmitHost, ProcessedFile } from "../transpilation/utils";
88
import {
99
isExportAlias,
@@ -44,8 +44,9 @@ class LuaLibPlugin implements tstl.Plugin {
4444
);
4545

4646
// Create lualib bundle by inlining all lualib features into one file
47+
const exportedLualibFeatures = result.filter(f => path.basename(f.fileName).split(".")[0] in LuaLibFeature);
4748
const allFeatures = Object.values(LuaLibFeature) as LuaLibFeature[];
48-
let lualibBundle = loadInlineLualibFeatures(allFeatures, emitHost);
49+
let lualibBundle = exportedLualibFeatures.map(f => f.code).join("\n");
4950
const exports = allFeatures.flatMap(feature => luaLibModuleInfo[feature].exports);
5051
lualibBundle += `\nreturn {\n${exports.map(exportName => ` ${exportName} = ${exportName}`).join(",\n")}\n}\n`;
5152
result.push({ fileName: "lualib_bundle.lua", code: lualibBundle });

0 commit comments

Comments
 (0)