From 50ec41f43bb1bcb8965fb65b425fac48822f1700 Mon Sep 17 00:00:00 2001 From: Perryvw Date: Thu, 28 Jul 2022 22:10:41 +0200 Subject: [PATCH 1/2] module resolution with paths tests --- test/transpile/module-resolution.spec.ts | 22 +++++++++++++++++++ .../packages/mypackage/src/bar.ts | 1 + .../packages/mypackage/src/index.ts | 1 + .../packages/mypackage/tsconfig.json | 7 ++++++ .../packages/myprogram/src/main.ts | 4 ++++ .../packages/myprogram/tsconfig.json | 7 ++++++ .../monorepo-complicated/tsconfig.base.json | 10 +++++++++ .../monorepo-with-paths/mypackage/bar.ts | 1 + .../monorepo-with-paths/mypackage/index.ts | 1 + .../mypackage/tsconfig.json | 1 + .../myprogram/dist/myprogram/main.lua | 9 ++++++++ .../monorepo-with-paths/myprogram/main.ts | 4 ++++ .../myprogram/tsconfig.json | 9 ++++++++ 13 files changed, 77 insertions(+) create mode 100644 test/transpile/module-resolution/monorepo-complicated/packages/mypackage/src/bar.ts create mode 100644 test/transpile/module-resolution/monorepo-complicated/packages/mypackage/src/index.ts create mode 100644 test/transpile/module-resolution/monorepo-complicated/packages/mypackage/tsconfig.json create mode 100644 test/transpile/module-resolution/monorepo-complicated/packages/myprogram/src/main.ts create mode 100644 test/transpile/module-resolution/monorepo-complicated/packages/myprogram/tsconfig.json create mode 100644 test/transpile/module-resolution/monorepo-complicated/tsconfig.base.json create mode 100644 test/transpile/module-resolution/monorepo-with-paths/mypackage/bar.ts create mode 100644 test/transpile/module-resolution/monorepo-with-paths/mypackage/index.ts create mode 100644 test/transpile/module-resolution/monorepo-with-paths/mypackage/tsconfig.json create mode 100644 test/transpile/module-resolution/monorepo-with-paths/myprogram/dist/myprogram/main.lua create mode 100644 test/transpile/module-resolution/monorepo-with-paths/myprogram/main.ts create mode 100644 test/transpile/module-resolution/monorepo-with-paths/myprogram/tsconfig.json diff --git a/test/transpile/module-resolution.spec.ts b/test/transpile/module-resolution.spec.ts index c18990225..d9c2fc26a 100644 --- a/test/transpile/module-resolution.spec.ts +++ b/test/transpile/module-resolution.spec.ts @@ -538,3 +538,25 @@ test("lualib_module with parent directory import (#1307)", () => { FEATURE_CONSTANT: 456, }); }); + +test.only("supports paths configuration", () => { + // Package root + const baseProjectPath = path.resolve(__dirname, "module-resolution", "monorepo-with-paths"); + // myprogram package + const projectPath = path.join(baseProjectPath, "myprogram"); + const projectTsConfig = path.join(projectPath, "tsconfig.json"); + const mainFile = path.join(projectPath, "main.ts"); + + util.testProject(projectTsConfig).setMainFileName(mainFile).expectToHaveNoDiagnostics().expectToEqual({ foo: 314, bar: 271 }); +}); + +test.only("supports complicated paths configuration", () => { + // Package root + const baseProjectPath = path.resolve(__dirname, "module-resolution", "monorepo-complicated"); + // myprogram package + const projectPath = path.join(baseProjectPath, "packages", "myprogram"); + const projectTsConfig = path.join(projectPath, "tsconfig.json"); + const mainFile = path.join(projectPath, "src", "main.ts"); + + util.testProject(projectTsConfig).setMainFileName(mainFile).expectToHaveNoDiagnostics().expectToEqual({ foo: 314, bar: 271 }); +}); diff --git a/test/transpile/module-resolution/monorepo-complicated/packages/mypackage/src/bar.ts b/test/transpile/module-resolution/monorepo-complicated/packages/mypackage/src/bar.ts new file mode 100644 index 000000000..122c0621e --- /dev/null +++ b/test/transpile/module-resolution/monorepo-complicated/packages/mypackage/src/bar.ts @@ -0,0 +1 @@ +export const bar = 217; \ No newline at end of file diff --git a/test/transpile/module-resolution/monorepo-complicated/packages/mypackage/src/index.ts b/test/transpile/module-resolution/monorepo-complicated/packages/mypackage/src/index.ts new file mode 100644 index 000000000..c932fa9f5 --- /dev/null +++ b/test/transpile/module-resolution/monorepo-complicated/packages/mypackage/src/index.ts @@ -0,0 +1 @@ +export const foo = 314; diff --git a/test/transpile/module-resolution/monorepo-complicated/packages/mypackage/tsconfig.json b/test/transpile/module-resolution/monorepo-complicated/packages/mypackage/tsconfig.json new file mode 100644 index 000000000..f659af26c --- /dev/null +++ b/test/transpile/module-resolution/monorepo-complicated/packages/mypackage/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "../../dist/packages/tstl-module", + }, + "include": ["./src/**/*.ts"], +} diff --git a/test/transpile/module-resolution/monorepo-complicated/packages/myprogram/src/main.ts b/test/transpile/module-resolution/monorepo-complicated/packages/myprogram/src/main.ts new file mode 100644 index 000000000..cc93d7bf6 --- /dev/null +++ b/test/transpile/module-resolution/monorepo-complicated/packages/myprogram/src/main.ts @@ -0,0 +1,4 @@ +import { foo } from "mypackage"; +import { bar } from "mypackage/bar"; + +export { foo, bar } diff --git a/test/transpile/module-resolution/monorepo-complicated/packages/myprogram/tsconfig.json b/test/transpile/module-resolution/monorepo-complicated/packages/myprogram/tsconfig.json new file mode 100644 index 000000000..09bc26f66 --- /dev/null +++ b/test/transpile/module-resolution/monorepo-complicated/packages/myprogram/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "../../dist/packages/tstl-program" + }, + "include": ["./src/**/*.ts"], +} diff --git a/test/transpile/module-resolution/monorepo-complicated/tsconfig.base.json b/test/transpile/module-resolution/monorepo-complicated/tsconfig.base.json new file mode 100644 index 000000000..98f3fcebc --- /dev/null +++ b/test/transpile/module-resolution/monorepo-complicated/tsconfig.base.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "rootDir": ".", + "baseUrl": ".", + "paths": { + "mypackage": ["packages/mypackage/src/index.ts"], + "mypackage/*": ["packages/mypackage/src/*"] + } + } +} diff --git a/test/transpile/module-resolution/monorepo-with-paths/mypackage/bar.ts b/test/transpile/module-resolution/monorepo-with-paths/mypackage/bar.ts new file mode 100644 index 000000000..0362bb99c --- /dev/null +++ b/test/transpile/module-resolution/monorepo-with-paths/mypackage/bar.ts @@ -0,0 +1 @@ +export const bar = 271; \ No newline at end of file diff --git a/test/transpile/module-resolution/monorepo-with-paths/mypackage/index.ts b/test/transpile/module-resolution/monorepo-with-paths/mypackage/index.ts new file mode 100644 index 000000000..a9d9d0e2e --- /dev/null +++ b/test/transpile/module-resolution/monorepo-with-paths/mypackage/index.ts @@ -0,0 +1 @@ +export const foo = 314; \ No newline at end of file diff --git a/test/transpile/module-resolution/monorepo-with-paths/mypackage/tsconfig.json b/test/transpile/module-resolution/monorepo-with-paths/mypackage/tsconfig.json new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/test/transpile/module-resolution/monorepo-with-paths/mypackage/tsconfig.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/test/transpile/module-resolution/monorepo-with-paths/myprogram/dist/myprogram/main.lua b/test/transpile/module-resolution/monorepo-with-paths/myprogram/dist/myprogram/main.lua new file mode 100644 index 000000000..d585347f2 --- /dev/null +++ b/test/transpile/module-resolution/monorepo-with-paths/myprogram/dist/myprogram/main.lua @@ -0,0 +1,9 @@ +--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]] +local ____exports = {} +local ____mypackage = require("mypackage.index") +local foo = ____mypackage.foo +local ____bar = require("mypackage.bar") +local bar = ____bar.bar +____exports.foo = foo +____exports.bar = bar +return ____exports diff --git a/test/transpile/module-resolution/monorepo-with-paths/myprogram/main.ts b/test/transpile/module-resolution/monorepo-with-paths/myprogram/main.ts new file mode 100644 index 000000000..6000b6696 --- /dev/null +++ b/test/transpile/module-resolution/monorepo-with-paths/myprogram/main.ts @@ -0,0 +1,4 @@ +import { foo } from "mypackage"; +import { bar } from "mypackage/bar"; + +export { foo, bar } \ No newline at end of file diff --git a/test/transpile/module-resolution/monorepo-with-paths/myprogram/tsconfig.json b/test/transpile/module-resolution/monorepo-with-paths/myprogram/tsconfig.json new file mode 100644 index 000000000..606f500ce --- /dev/null +++ b/test/transpile/module-resolution/monorepo-with-paths/myprogram/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "baseUrl": "..", + "outDir": "dist", + "paths": { + "mypackage": ["mypackage"] + } + }, +} \ No newline at end of file From 34b2b9b1a7c7b1a103b71ee8a7ff0d8d04b3c850 Mon Sep 17 00:00:00 2001 From: Perryvw Date: Sat, 30 Jul 2022 15:20:43 +0200 Subject: [PATCH 2/2] paths support --- src/transpilation/resolve.ts | 52 +++++++++++++++++++ .../module-resolution.spec.ts.snap | 17 ++++++ test/transpile/module-resolution.spec.ts | 44 +++++++++++++--- .../packages/mypackage/src/bar.ts | 2 +- .../packages/mypackage/tsconfig.json | 10 ++-- .../packages/myprogram/src/main.ts | 2 +- .../packages/myprogram/tsconfig.json | 10 ++-- .../monorepo-complicated/tsconfig.base.json | 14 ++--- .../monorepo-with-paths/mypackage/bar.ts | 2 +- .../monorepo-with-paths/mypackage/index.ts | 2 +- .../mypackage/tsconfig.json | 2 +- .../myprogram/dist/myprogram/main.lua | 9 ---- .../monorepo-with-paths/myprogram/main.ts | 2 +- .../myprogram/tsconfig.json | 4 +- 14 files changed, 131 insertions(+), 41 deletions(-) create mode 100644 test/transpile/__snapshots__/module-resolution.spec.ts.snap delete mode 100644 test/transpile/module-resolution/monorepo-with-paths/myprogram/dist/myprogram/main.lua diff --git a/src/transpilation/resolve.ts b/src/transpilation/resolve.ts index ccf0bdfa4..ff4ba1e84 100644 --- a/src/transpilation/resolve.ts +++ b/src/transpilation/resolve.ts @@ -147,6 +147,16 @@ class ResolutionContext { const fileFromPath = this.getFileFromPath(resolvedPath); if (fileFromPath) return fileFromPath; + if (this.options.paths && this.options.baseUrl) { + // If no file found yet and paths are present, try to find project file via paths mappings + const fileFromPaths = this.tryGetModuleNameFromPaths( + dependencyPath, + this.options.paths, + this.options.baseUrl + ); + if (fileFromPaths) return fileFromPaths; + } + // Not a TS file in our project sources, use resolver to check if we can find dependency try { const resolveResult = resolver.resolveSync({}, fileDirectory, dependencyPath); @@ -222,6 +232,40 @@ class ResolutionContext { } } } + + // Taken from TS and modified: https://github.com/microsoft/TypeScript/blob/88a1e3a1dd8d2d86e844ff1c16d5f041cebcfdb9/src/compiler/moduleSpecifiers.ts#L562 + private tryGetModuleNameFromPaths(relativeToBaseUrl: string, paths: ts.MapLike, baseUrl: string) { + const relativeImport = removeTrailingDirectorySeparator(normalizeSlashes(relativeToBaseUrl)); + for (const [importPattern, targetPatterns] of Object.entries(paths)) { + const pattern = removeFileExtension(normalizeSlashes(importPattern)); + const indexOfStar = pattern.indexOf("*"); + if (indexOfStar !== -1) { + // Try to match * to relativeImport + const prefix = pattern.substring(0, indexOfStar); + const suffix = pattern.substring(indexOfStar + 1); + if ( + (relativeImport.length >= prefix.length + suffix.length && + relativeImport.startsWith(prefix) && + relativeImport.endsWith(suffix)) || + (!suffix && relativeImport === removeTrailingDirectorySeparator(prefix)) + ) { + // If import matches *, extract the matched * path + const matchedStar = relativeImport.substring(prefix.length, relativeImport.length - suffix.length); + // Try to resolve to the target patterns with filled in * pattern + for (const target of targetPatterns) { + const file = this.getFileFromPath(path.join(baseUrl, target.replace("*", matchedStar))); + if (file) return file; + } + } + } else if (pattern === relativeImport) { + // If there is no * pattern, check for exact matches and try those targets + for (const target of targetPatterns) { + const file = this.getFileFromPath(path.join(baseUrl, target)); + if (file) return file; + } + } + } + } } export function resolveDependencies(program: ts.Program, files: ProcessedFile[], emitHost: EmitHost): ResolutionResult { @@ -340,3 +384,11 @@ function fallbackResolve(required: string, sourceRootDir: string, fileDir: strin function luaRequireToPath(requirePath: string): string { return requirePath.replace(/\./g, path.sep); } + +function removeFileExtension(path: string) { + return path.includes(".") ? trimExtension(path) : path; +} + +function removeTrailingDirectorySeparator(path: string) { + return path.endsWith("/") || path.endsWith("\\") ? path.substring(0, -1) : path; +} diff --git a/test/transpile/__snapshots__/module-resolution.spec.ts.snap b/test/transpile/__snapshots__/module-resolution.spec.ts.snap new file mode 100644 index 000000000..5cb03e86b --- /dev/null +++ b/test/transpile/__snapshots__/module-resolution.spec.ts.snap @@ -0,0 +1,17 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`supports complicated paths configuration 1`] = ` +Array [ + "/monorepo-complicated/dist/packages/tstl-program/packages/mypackage/src/bar.lua", + "/monorepo-complicated/dist/packages/tstl-program/packages/mypackage/src/index.lua", + "/monorepo-complicated/dist/packages/tstl-program/packages/myprogram/src/main.lua", +] +`; + +exports[`supports paths configuration 1`] = ` +Array [ + "/monorepo-with-paths/myprogram/dist/mypackage/bar.lua", + "/monorepo-with-paths/myprogram/dist/mypackage/index.lua", + "/monorepo-with-paths/myprogram/dist/myprogram/main.lua", +] +`; diff --git a/test/transpile/module-resolution.spec.ts b/test/transpile/module-resolution.spec.ts index d9c2fc26a..348b502d2 100644 --- a/test/transpile/module-resolution.spec.ts +++ b/test/transpile/module-resolution.spec.ts @@ -2,7 +2,8 @@ import * as path from "path"; import * as tstl from "../../src"; import * as util from "../util"; import * as ts from "typescript"; -import { BuildMode, transpileProject } from "../../src"; +import { BuildMode } from "../../src"; +import { normalizeSlashes } from "../../src/utils"; describe("basic module resolution", () => { const projectPath = path.resolve(__dirname, "module-resolution", "project-with-node-modules"); @@ -236,8 +237,8 @@ describe("module resolution project with dependencies built by tstl library mode const projectPath = path.resolve(__dirname, "module-resolution", "project-with-tstl-library-modules"); // First compile dependencies into node_modules. NOTE: Actually writing to disk, very slow - transpileProject(path.join(projectPath, "dependency1-ts", "tsconfig.json")); - transpileProject(path.join(projectPath, "dependency2-ts", "tsconfig.json")); + tstl.transpileProject(path.join(projectPath, "dependency1-ts", "tsconfig.json")); + tstl.transpileProject(path.join(projectPath, "dependency2-ts", "tsconfig.json")); const expectedResult = { dependency1IndexResult: "function in dependency 1 index: dependency1OtherFileFunc in dependency1/d1otherfile", @@ -539,7 +540,7 @@ test("lualib_module with parent directory import (#1307)", () => { }); }); -test.only("supports paths configuration", () => { +test("supports paths configuration", () => { // Package root const baseProjectPath = path.resolve(__dirname, "module-resolution", "monorepo-with-paths"); // myprogram package @@ -547,10 +548,22 @@ test.only("supports paths configuration", () => { const projectTsConfig = path.join(projectPath, "tsconfig.json"); const mainFile = path.join(projectPath, "main.ts"); - util.testProject(projectTsConfig).setMainFileName(mainFile).expectToHaveNoDiagnostics().expectToEqual({ foo: 314, bar: 271 }); + const luaResult = util + .testProject(projectTsConfig) + .setMainFileName(mainFile) + .expectToHaveNoDiagnostics() + .getLuaResult(); + + expect(snapshotPaths(luaResult.transpiledFiles)).toMatchSnapshot(); + + // Bundle to have all files required to execute and check result + util.testProject(projectTsConfig) + .setMainFileName(mainFile) + .setOptions({ luaBundle: "bundle.lua", luaBundleEntry: mainFile }) + .expectToEqual({ foo: 314, bar: 271 }); }); -test.only("supports complicated paths configuration", () => { +test("supports complicated paths configuration", () => { // Package root const baseProjectPath = path.resolve(__dirname, "module-resolution", "monorepo-complicated"); // myprogram package @@ -558,5 +571,22 @@ test.only("supports complicated paths configuration", () => { const projectTsConfig = path.join(projectPath, "tsconfig.json"); const mainFile = path.join(projectPath, "src", "main.ts"); - util.testProject(projectTsConfig).setMainFileName(mainFile).expectToHaveNoDiagnostics().expectToEqual({ foo: 314, bar: 271 }); + const luaResult = util + .testProject(projectTsConfig) + .setMainFileName(mainFile) + .expectToHaveNoDiagnostics() + .getLuaResult(); + + expect(snapshotPaths(luaResult.transpiledFiles)).toMatchSnapshot(); + + // Bundle to have all files required to execute + util.testProject(projectTsConfig) + .setMainFileName(mainFile) + .setOptions({ luaBundle: "bundle.lua", luaBundleEntry: mainFile }) + .debug() + .expectToEqual({ foo: 314, bar: 271 }); }); + +function snapshotPaths(files: tstl.TranspiledFile[]) { + return files.map(f => normalizeSlashes(f.outPath).split("module-resolution")[1]).sort(); +} diff --git a/test/transpile/module-resolution/monorepo-complicated/packages/mypackage/src/bar.ts b/test/transpile/module-resolution/monorepo-complicated/packages/mypackage/src/bar.ts index 122c0621e..fef4e9ed6 100644 --- a/test/transpile/module-resolution/monorepo-complicated/packages/mypackage/src/bar.ts +++ b/test/transpile/module-resolution/monorepo-complicated/packages/mypackage/src/bar.ts @@ -1 +1 @@ -export const bar = 217; \ No newline at end of file +export const bar = 271; diff --git a/test/transpile/module-resolution/monorepo-complicated/packages/mypackage/tsconfig.json b/test/transpile/module-resolution/monorepo-complicated/packages/mypackage/tsconfig.json index f659af26c..5ac343336 100644 --- a/test/transpile/module-resolution/monorepo-complicated/packages/mypackage/tsconfig.json +++ b/test/transpile/module-resolution/monorepo-complicated/packages/mypackage/tsconfig.json @@ -1,7 +1,7 @@ { - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "../../dist/packages/tstl-module", - }, - "include": ["./src/**/*.ts"], + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "../../dist/packages/tstl-module" + }, + "include": ["./src/**/*.ts"] } diff --git a/test/transpile/module-resolution/monorepo-complicated/packages/myprogram/src/main.ts b/test/transpile/module-resolution/monorepo-complicated/packages/myprogram/src/main.ts index cc93d7bf6..973b93922 100644 --- a/test/transpile/module-resolution/monorepo-complicated/packages/myprogram/src/main.ts +++ b/test/transpile/module-resolution/monorepo-complicated/packages/myprogram/src/main.ts @@ -1,4 +1,4 @@ import { foo } from "mypackage"; import { bar } from "mypackage/bar"; -export { foo, bar } +export { foo, bar }; diff --git a/test/transpile/module-resolution/monorepo-complicated/packages/myprogram/tsconfig.json b/test/transpile/module-resolution/monorepo-complicated/packages/myprogram/tsconfig.json index 09bc26f66..a0ba7c18e 100644 --- a/test/transpile/module-resolution/monorepo-complicated/packages/myprogram/tsconfig.json +++ b/test/transpile/module-resolution/monorepo-complicated/packages/myprogram/tsconfig.json @@ -1,7 +1,7 @@ { - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "../../dist/packages/tstl-program" - }, - "include": ["./src/**/*.ts"], + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "../../dist/packages/tstl-program" + }, + "include": ["./src/**/*.ts"] } diff --git a/test/transpile/module-resolution/monorepo-complicated/tsconfig.base.json b/test/transpile/module-resolution/monorepo-complicated/tsconfig.base.json index 98f3fcebc..3f961c78a 100644 --- a/test/transpile/module-resolution/monorepo-complicated/tsconfig.base.json +++ b/test/transpile/module-resolution/monorepo-complicated/tsconfig.base.json @@ -1,10 +1,10 @@ { - "compilerOptions": { - "rootDir": ".", - "baseUrl": ".", - "paths": { - "mypackage": ["packages/mypackage/src/index.ts"], - "mypackage/*": ["packages/mypackage/src/*"] + "compilerOptions": { + "rootDir": ".", + "baseUrl": ".", + "paths": { + "mypackage": ["packages/mypackage/src/index.ts"], + "mypackage/*": ["packages/mypackage/src/*"] + } } - } } diff --git a/test/transpile/module-resolution/monorepo-with-paths/mypackage/bar.ts b/test/transpile/module-resolution/monorepo-with-paths/mypackage/bar.ts index 0362bb99c..fef4e9ed6 100644 --- a/test/transpile/module-resolution/monorepo-with-paths/mypackage/bar.ts +++ b/test/transpile/module-resolution/monorepo-with-paths/mypackage/bar.ts @@ -1 +1 @@ -export const bar = 271; \ No newline at end of file +export const bar = 271; diff --git a/test/transpile/module-resolution/monorepo-with-paths/mypackage/index.ts b/test/transpile/module-resolution/monorepo-with-paths/mypackage/index.ts index a9d9d0e2e..c932fa9f5 100644 --- a/test/transpile/module-resolution/monorepo-with-paths/mypackage/index.ts +++ b/test/transpile/module-resolution/monorepo-with-paths/mypackage/index.ts @@ -1 +1 @@ -export const foo = 314; \ No newline at end of file +export const foo = 314; diff --git a/test/transpile/module-resolution/monorepo-with-paths/mypackage/tsconfig.json b/test/transpile/module-resolution/monorepo-with-paths/mypackage/tsconfig.json index 9e26dfeeb..0967ef424 100644 --- a/test/transpile/module-resolution/monorepo-with-paths/mypackage/tsconfig.json +++ b/test/transpile/module-resolution/monorepo-with-paths/mypackage/tsconfig.json @@ -1 +1 @@ -{} \ No newline at end of file +{} diff --git a/test/transpile/module-resolution/monorepo-with-paths/myprogram/dist/myprogram/main.lua b/test/transpile/module-resolution/monorepo-with-paths/myprogram/dist/myprogram/main.lua deleted file mode 100644 index d585347f2..000000000 --- a/test/transpile/module-resolution/monorepo-with-paths/myprogram/dist/myprogram/main.lua +++ /dev/null @@ -1,9 +0,0 @@ ---[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]] -local ____exports = {} -local ____mypackage = require("mypackage.index") -local foo = ____mypackage.foo -local ____bar = require("mypackage.bar") -local bar = ____bar.bar -____exports.foo = foo -____exports.bar = bar -return ____exports diff --git a/test/transpile/module-resolution/monorepo-with-paths/myprogram/main.ts b/test/transpile/module-resolution/monorepo-with-paths/myprogram/main.ts index 6000b6696..973b93922 100644 --- a/test/transpile/module-resolution/monorepo-with-paths/myprogram/main.ts +++ b/test/transpile/module-resolution/monorepo-with-paths/myprogram/main.ts @@ -1,4 +1,4 @@ import { foo } from "mypackage"; import { bar } from "mypackage/bar"; -export { foo, bar } \ No newline at end of file +export { foo, bar }; diff --git a/test/transpile/module-resolution/monorepo-with-paths/myprogram/tsconfig.json b/test/transpile/module-resolution/monorepo-with-paths/myprogram/tsconfig.json index 606f500ce..d5f59e8b5 100644 --- a/test/transpile/module-resolution/monorepo-with-paths/myprogram/tsconfig.json +++ b/test/transpile/module-resolution/monorepo-with-paths/myprogram/tsconfig.json @@ -5,5 +5,5 @@ "paths": { "mypackage": ["mypackage"] } - }, -} \ No newline at end of file + } +}