Skip to content

Commit

Permalink
support importing from dir/index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
frankleng committed Feb 14, 2022
1 parent af618ac commit dca93c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]:frankleng/esbuild-ts-paths.git",
Expand Down

0 comments on commit dca93c8

Please sign in to comment.