diff --git a/index.js b/index.js index 9e3f4b6..71309ec 100644 --- a/index.js +++ b/index.js @@ -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}.*`); diff --git a/package.json b/package.json index a77dbbf..8f41277 100644 --- a/package.json +++ b/package.json @@ -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",