LeDDGroup / typescript-transform-paths

Transforms module resolution paths using TypeScript path mapping and/or custom paths
MIT License
478 stars 25 forks source link

Bug: Path Not Transformed If Already Resolvable #190

Open Char2sGu opened 3 months ago

Char2sGu commented 3 months ago

Let's say @workspace/lib is a package in a loal NPM Workspace.
By default, imports will be resolved to node_modules/@workspace/lib, but we can change its resolution by defining the following path mapping:

"paths": {
  "@workspace/lib": "./dist/lib"
}

By doing so, TypeScript will always resolve the path @workspace/lib to {workspaceRoot}/dist/lib instead of {workspaceRoot}/node_modules/@workspace/lib, but this behavior doesn't seem respected in this library: In such case, the path mapping does not take effect, and the path @workspace/lib is not transformed at all.

I will be happy to provide a reproduction repository if you find the above information not descriptive enough.

Char2sGu commented 3 months ago

Update: the path mapping is respected if @workspace/lib is not present in package.json. This package was listed as a peer dependency to enable auto-imports.