(
features: Iterable<LuaLibFeature>,
luaTarget: LuaTarget,
emitHost: EmitHost
)
| 227 | } |
| 228 | |
| 229 | export function loadImportedLualibFeatures( |
| 230 | features: Iterable<LuaLibFeature>, |
| 231 | luaTarget: LuaTarget, |
| 232 | emitHost: EmitHost |
| 233 | ): lua.Statement[] { |
| 234 | const luaLibModuleInfo = getLuaLibModulesInfo(luaTarget, emitHost); |
| 235 | |
| 236 | const imports = Array.from(features).flatMap(feature => luaLibModuleInfo[feature].exports); |
| 237 | if (imports.length === 0) { |
| 238 | return []; |
| 239 | } |
| 240 | |
| 241 | const requireCall = lua.createCallExpression(lua.createIdentifier("require"), [ |
| 242 | lua.createStringLiteral("lualib_bundle"), |
| 243 | ]); |
| 244 | |
| 245 | const luaLibId = lua.createIdentifier("____lualib"); |
| 246 | const importStatement = lua.createVariableDeclarationStatement(luaLibId, requireCall); |
| 247 | const statements: lua.Statement[] = [importStatement]; |
| 248 | // local <export> = ____luaLib.<export> |
| 249 | for (const item of imports) { |
| 250 | statements.push( |
| 251 | lua.createVariableDeclarationStatement( |
| 252 | lua.createIdentifier(item), |
| 253 | lua.createTableIndexExpression(luaLibId, lua.createStringLiteral(item)) |
| 254 | ) |
| 255 | ); |
| 256 | } |
| 257 | return statements; |
| 258 | } |
| 259 | |
| 260 | const luaLibBundleContent = new Map<string, string>(); |
| 261 |
no test coverage detected