typescript-transform-paths icon indicating copy to clipboard operation
typescript-transform-paths copied to clipboard

Bug: Path Not Transformed If Already Resolvable

Open Char2sGu opened this issue 1 year ago • 2 comments

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 avatar Jun 23 '24 08:06 Char2sGu

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.

Char2sGu avatar Jun 23 '24 08:06 Char2sGu

@Char2sGu, thanks for reporting the issue.

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

Can you please provide a reproduction example? You can use this link or provide your own

danielpza avatar Sep 04 '25 11:09 danielpza