You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and lua will be searching at ./Foo/Bar/index.lua" for that module.
That will result an error:
lua: ./Qux/index.lua:3: module 'Foo.Bar.index' not found:
no field package.preload['Foo.Bar.index']
no file './Foo/Bar/index.lua'
no file '/usr/local/share/lua/5.1/Foo/Bar/index.lua'
no file '/usr/local/share/lua/5.1/Foo/Bar/index/init.lua'
no file '/usr/local/lib/lua/5.1/Foo/Bar/index.lua'
no file '/usr/local/lib/lua/5.1/Foo/Bar/index/init.lua'
no file '/usr/share/lua/5.1/Foo/Bar/index.lua'
no file '/usr/share/lua/5.1/Foo/Bar/index/init.lua'
no file './Foo/Bar/index.so'
no file '/usr/local/lib/lua/5.1/Foo/Bar/index.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.1/Foo/Bar/index.so'
no file '/usr/lib/lua/5.1/Foo/Bar/index.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file './Foo.so'
no file '/usr/local/lib/lua/5.1/Foo.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.1/Foo.so'
no file '/usr/lib/lua/5.1/Foo.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
[C]: in function 'require'
./Qux/index.lua:3: in main chunk
[C]: in function 'require'
./main.lua:3: in main chunk
[C]: ?
Soulution
When compiled to a file ./dist/Foo.Bar.Baz/index.lua, split it's name by dots (excluding extension) and put the file into directory ./Foo/Bar/Baz.
This will fix module resolution for lua.
So basically the ts directory
Alternative solution would be to rename the directory Foo.Bar.Baz to something like Foo_dot_Bar_dot_Baz, I have seen Python grpc do something like that.
But I think I prefer your proposed solution of just outputing to nested directories better.
Hey I solved a similar problem for myself by adding an import resolution failure hook in the plugins interface, which allowed me to write a plugin to customize how I solve imports that can't be resolved via the ts resolver. I'm sure it needs some changes to be contributed but let me know what you think. #1455
My specific issue was a file with a . in the name (e.g. physics-api.component.ts)
Abstract
tstl
fails to produce validlua
code from a subset of valid (accordingly totstl
docs) code ifts
file names contain dots in paths.This problem may naturally arise, for example, when compiling from Purescript to JS and then from JS to Lua using tstl.
The example is not the natural use case for tstl, however, the bug is the bug.
Example
Let's say we have two files:
./src/Foo.Bar/index.ts
./src/Qux/index.ts
So
import {answer} from "./Foo.Bar";
will be compiled (in a non-bundle mode) toand
lua
will be searching at./Foo/Bar/index.lua"
for that module.That will result an error:
Soulution
When compiled to a file
./dist/Foo.Bar.Baz/index.lua
, split it's name by dots (excluding extension) and put the file into directory./Foo/Bar/Baz
.This will fix module resolution for
lua
.So basically the ts directory
should be compiled into
instead of
The text was updated successfully, but these errors were encountered: