-
-
Notifications
You must be signed in to change notification settings - Fork 184
Closed
Labels
bugscope: bundlingRelated to bundling of generated lua files.Related to bundling of generated lua files.
Description
Either code generator or custom require in lua works incorrectly:
When importing import * from './pkg if pkg is a directory with index.ts tstl generates module for lua named pkg.index and generates import referencing just pkg without .index.
Sample:
main.ts:
import { hello } from './pkg';
print(hello);pkg/index.ts:
export const hello = 'hello';results in:
local ____modules = {}
local ____moduleCache = {}
local ____originalRequire = require
local function require(file)
if ____moduleCache[file] then
return ____moduleCache[file]
end
if ____modules[file] then
____moduleCache[file] = ____modules[file]()
return ____moduleCache[file]
else
if ____originalRequire then
return ____originalRequire(file)
else
error("module '" .. file .. "' not found")
end
end
end
____modules = {
["pkg.index"] = function() local ____exports = {}
____exports.hello = "hello"
return ____exports
end,
["main"] = function() local ____exports = {}
local ____pkg = require("pkg")
local hello = ____pkg.hello
print(hello)
return ____exports
end,
}
return require("main")tstl version: 0.37.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugscope: bundlingRelated to bundling of generated lua files.Related to bundling of generated lua files.