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
Either code generator or custom
requirein lua works incorrectly:When importing
import * from './pkgifpkgis a directory withindex.tststl generates module for lua namedpkg.indexand generates import referencing justpkgwithout.index.Sample:
main.ts:pkg/index.ts:results in:
tstl version:
0.37.1