Skip to content

fix dots in file/directory names breaking Lua require resolution (#1445)#1702

Open
RealColdFry wants to merge 2 commits intoTypeScriptToLua:masterfrom
RealColdFry:fix/dots-in-module-paths
Open

fix dots in file/directory names breaking Lua require resolution (#1445)#1702
RealColdFry wants to merge 2 commits intoTypeScriptToLua:masterfrom
RealColdFry:fix/dots-in-module-paths

Conversation

@RealColdFry
Copy link
Copy Markdown
Contributor

Relates to #1445

Lua's require() uses dots as path separators, so a file at Foo.Bar/index.lua is unreachable via require("Foo.Bar.index") since Lua looks for Foo/Bar/index.lua. Expand dotted path segments into nested directories in the emit output, and emit a diagnostic when this expansion causes output path collisions.

…eScriptToLua#1445)

Lua's require() uses dots as path separators, so a file at Foo.Bar/index.lua
is unreachable via require("Foo.Bar.index") since Lua looks for Foo/Bar/index.lua.
Expand dotted path segments into nested directories in the emit output, and emit
a diagnostic when this expansion causes output path collisions.
@Perryvw
Copy link
Copy Markdown
Member

Perryvw commented Apr 1, 2026

While this is a possible solution, wouldn't it be simpler (and the output more reasonable) if we were to just find/replace periods with e.g. underscores in the output file names?

@RealColdFry
Copy link
Copy Markdown
Contributor Author

While this is a possible solution, wouldn't it be simpler (and the output more reasonable) if we were to just find/replace periods with e.g. underscores in the output file names?

Agreed, done

@RealColdFry RealColdFry marked this pull request as ready for review April 3, 2026 01:53
// regardless of output path. We check the output path directly instead.
test("dots in directory names are replaced with underscores in output", () => {
const { transpiledFiles } = util.testModule`
import { answer } from "./Foo.Bar";
Copy link
Copy Markdown
Member

@Perryvw Perryvw Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a test where you're including a file like "Foo.Bar.ts", or maybe "foo.test.ts" since that was mentioned in the issue, rather than only directories with dots

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants