@@ -106,18 +106,19 @@ export interface LuaLibFeatureInfo {
106106}
107107export type LuaLibModulesInfo = Record < LuaLibFeature , LuaLibFeatureInfo > ;
108108
109- let luaLibModuleInfo : LuaLibModulesInfo | undefined ;
110- export function getLuaLibModuleInfo ( emitHost : EmitHost ) : LuaLibModulesInfo {
111- if ( luaLibModuleInfo === undefined ) {
112- const lualibPath = path . resolve ( __dirname , "../dist/lualib/lualib_dependencies.json" ) ;
109+ export const luaLibModulesInfoFileName = "lualib_module_info.json" ;
110+ let luaLibModulesInfo : LuaLibModulesInfo | undefined ;
111+ export function getLuaLibModulesInfo ( emitHost : EmitHost ) : LuaLibModulesInfo {
112+ if ( luaLibModulesInfo === undefined ) {
113+ const lualibPath = path . resolve ( __dirname , `../dist/lualib/${ luaLibModulesInfoFileName } ` ) ;
113114 const result = emitHost . readFile ( lualibPath ) ;
114115 if ( result !== undefined ) {
115- luaLibModuleInfo = JSON . parse ( result ) as LuaLibModulesInfo ;
116+ luaLibModulesInfo = JSON . parse ( result ) as LuaLibModulesInfo ;
116117 } else {
117118 throw new Error ( `Could not load lualib dependencies from '${ lualibPath } '` ) ;
118119 }
119120 }
120- return luaLibModuleInfo ;
121+ return luaLibModulesInfo ;
121122}
122123
123124export function readLuaLibFeature ( feature : LuaLibFeature , emitHost : EmitHost ) : string {
@@ -132,7 +133,7 @@ export function readLuaLibFeature(feature: LuaLibFeature, emitHost: EmitHost): s
132133export function loadInlineLualibFeatures (
133134 features : Iterable < LuaLibFeature > ,
134135 emitHost : EmitHost ,
135- luaLibModulesInfo : LuaLibModulesInfo = getLuaLibModuleInfo ( emitHost ) ,
136+ luaLibModulesInfo : LuaLibModulesInfo = getLuaLibModulesInfo ( emitHost ) ,
136137 readFeature : ( feature : LuaLibFeature ) => string = feature => readLuaLibFeature ( feature , emitHost )
137138) : string {
138139 let result = "" ;
@@ -163,7 +164,7 @@ export function loadImportedLualibFeatures(
163164 emitHost : EmitHost ,
164165 alwaysRequire = false
165166) : lua . Statement [ ] {
166- const luaLibModuleInfo = getLuaLibModuleInfo ( emitHost ) ;
167+ const luaLibModuleInfo = getLuaLibModulesInfo ( emitHost ) ;
167168
168169 const imports = Array . from ( features ) . flatMap ( feature => luaLibModuleInfo [ feature ] . exports ) ;
169170
0 commit comments