Skip to content

Commit

Permalink
fixes #6 - root import
Browse files Browse the repository at this point in the history
  • Loading branch information
frankleng committed Mar 24, 2022
1 parent 796bc05 commit 4e30381
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ module.exports = (relativeTsconfigPath = "./tsconfig.json") => {
build.onResolve({ filter: re }, (args) => {
const pathKey = pathKeys.find((pkey) => new RegExp(`^${pkey}`).test(args.path));
const [pathDir] = pathKey.split("*");
const file = args.path.replace(pathDir, "");
let file = args.path.replace(pathDir, "");
if (file === args.path) { // if importing from root of alias
file = ""
}
for (const dir of compilerOptions.paths[pathKey]) {
const fileDir = normalizePath(path.resolve(process.cwd(), dir).replace("*", file));
let [matchedFile] = glob(`${fileDir}.*`);
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.1.2",
"version": "1.1.3",
"description": "Transform TS path alias to absolute paths for esbuild",
"main": "index.js",
"repository": "git@github.com:frankleng/esbuild-ts-paths.git",
Expand Down

0 comments on commit 4e30381

Please sign in to comment.