duffman / tspath

TypeScript path alias resolver
GNU Lesser General Public License v2.1
151 stars 33 forks source link

Path resolution has too many `..` when `paths` does not stem from project dir #49

Open joergplewe opened 1 year ago

joergplewe commented 1 year ago

What I try to do: Use some TS code somewhere in my project tree as a library by referring it by a paths mapping.

It seems that path resolution goes wrong when a paths reference does not stem from the project dir (where tsconfig.json is), e.g. has a .. in it. Like this:

 "compilerOptions": {
    "baseUrl": "./",
    "paths": {
      "@lib/*": ["./../lib/src/*"]
    },
    "outDir": "./dist",

In this case, the resolved path has one .. too much.

This also holds when shifting the baseUrl up:

 "compilerOptions": {
    "baseUrl": "./../",
    "paths": {
      "@lib/*": ["./lib/src/*"]
    },
    "outDir": "./dist",