diff --git a/index.js b/index.js index f72dd1d..0d3274b 100644 --- a/index.js +++ b/index.js @@ -23,7 +23,12 @@ module.exports = (relativeTsconfigPath = './tsconfig.json') => { const [pathDir] = pathKey.split("*"); const file = args.path.replace(pathDir, ""); for (const dir of compilerOptions.paths[pathKey]) { - const [matchedFile] = glob(`${path.resolve(process.cwd(), dir).replace("*", file)}.*`); + const fileDir = path.resolve(process.cwd(), dir).replace("*", file) + let [matchedFile] = glob(`${fileDir}.*`); + if (!matchedFile) { + const [matchIndexFile] = glob(`${fileDir}/index.*`); + matchedFile = matchIndexFile + } if (matchedFile) { return { path: matchedFile }; } diff --git a/package.json b/package.json index a7a78ec..cee0447 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "esbuild-ts-paths", - "version": "1.0.4", + "version": "1.1.0", "description": "Transform TS path alias to absolute paths for esbuild", "main": "index.js", "repository": "git@github.com:frankleng/esbuild-ts-paths.git",