Fix lua file resolutoin using the wrong root dirs (#1316) · TypeScriptToLua/TypeScriptToLua@bd3bced · GitHub
Skip to content

Commit bd3bced

Browse files
authored
Fix lua file resolutoin using the wrong root dirs (#1316)
1 parent 1001207 commit bd3bced

9 files changed

Lines changed: 80 additions & 43 deletions

File tree

‎src/transpilation/resolve.ts‎

Lines changed: 39 additions & 43 deletions

‎test/transpile/module-resolution.spec.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,3 +525,16 @@ test("require matches correct pattern", () => {
525525
.addExtraFile("c.lua", "return function(self, a) return a end")
526526
.expectToEqual({ addResult: 3 + 5, callResult: "foo" });
527527
});
528+
529+
// https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1307
530+
test("lualib_module with parent directory import (#1307)", () => {
531+
const projectDir = path.join(__dirname, "module-resolution", "project-with-dependency-with-same-file-names");
532+
const inputProject = path.join(projectDir, "tsconfig.json");
533+
534+
util.testProject(inputProject).setMainFileName(path.join(projectDir, "index.ts")).expectToEqual({
535+
// eslint-disable-next-line @typescript-eslint/naming-convention
536+
BASE_CONSTANT: 123,
537+
// eslint-disable-next-line @typescript-eslint/naming-convention
538+
FEATURE_CONSTANT: 456,
539+
});
540+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "mymodule";

‎test/transpile/module-resolution/project-with-dependency-with-same-file-names/node_modules/mymodule/constants.lua‎

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎test/transpile/module-resolution/project-with-dependency-with-same-file-names/node_modules/mymodule/feature/constants.lua‎

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎test/transpile/module-resolution/project-with-dependency-with-same-file-names/node_modules/mymodule/feature/feature.lua‎

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎test/transpile/module-resolution/project-with-dependency-with-same-file-names/node_modules/mymodule/index.d.ts‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎test/transpile/module-resolution/project-with-dependency-with-same-file-names/node_modules/mymodule/index.lua‎

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)