From 3122550a9dce73e3e0b944c409cfc7628753105e Mon Sep 17 00:00:00 2001 From: GlassBricks <24237065+GlassBricks@users.noreply.github.com> Date: Wed, 16 Mar 2022 09:17:22 -0700 Subject: [PATCH] Fix using tstl CLI to build lualib --- src/LuaLib.ts | 7 +++++-- src/lualib-build/plugin.ts | 2 +- src/lualib/tsconfig.json | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/LuaLib.ts b/src/LuaLib.ts index e77498936..e5df8927a 100644 --- a/src/LuaLib.ts +++ b/src/LuaLib.ts @@ -130,8 +130,11 @@ export function readLuaLibFeature(feature: LuaLibFeature, emitHost: EmitHost): s return luaLibFeature; } -export function resolveRecursiveLualibFeatures(features: Iterable, emitHost: EmitHost): LuaLibFeature[] { - const luaLibModulesInfo = getLuaLibModulesInfo(emitHost); +export function resolveRecursiveLualibFeatures( + features: Iterable, + emitHost: EmitHost, + luaLibModulesInfo: LuaLibModulesInfo = getLuaLibModulesInfo(emitHost) +): LuaLibFeature[] { const loadedFeatures = new Set(); const result: LuaLibFeature[] = []; diff --git a/src/lualib-build/plugin.ts b/src/lualib-build/plugin.ts index 14f068f71..a14c8917a 100644 --- a/src/lualib-build/plugin.ts +++ b/src/lualib-build/plugin.ts @@ -48,7 +48,7 @@ class LuaLibPlugin implements tstl.Plugin { // Figure out the order required in the bundle by recursively resolving all dependency features const allFeatures = Object.values(LuaLibFeature) as LuaLibFeature[]; - const orderedFeatures = resolveRecursiveLualibFeatures(allFeatures, emitHost); + const orderedFeatures = resolveRecursiveLualibFeatures(allFeatures, emitHost, luaLibModuleInfo); // Concatenate lualib files into bundle with exports table and add lualib_bundle.lua to results let lualibBundle = orderedFeatures.map(f => exportedLualibFeatures.get(LuaLibFeature[f])).join("\n"); diff --git a/src/lualib/tsconfig.json b/src/lualib/tsconfig.json index beca82ecd..8acde4cca 100644 --- a/src/lualib/tsconfig.json +++ b/src/lualib/tsconfig.json @@ -12,6 +12,6 @@ "tstl": { "luaLibImport": "none", "noHeader": true, - "luaPlugins": [{ "name": "../lualib-build/plugin.ts" }] + "luaPlugins": [{ "name": "../../dist/lualib-build/plugin.js" }] } }