LeDDGroup / typescript-transform-paths

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

Does not work with relative path to a node module folder. #160

Closed AndrewSouthpaw closed 1 year ago

AndrewSouthpaw commented 2 years ago

For various reasons, I had a TS path that reached deeply into an npm package:

paths: {
  "@foobar/*": ["./node_modules/eslint/lib/rules/*"]
}

I'd have an import like this:

import { thing } from '@foobar/curly'

Which I would expect to be translated to something like:

const { thing } = require('../../node_modules/eslint/lib/rules/curly')

But instead the transformed output would stop at the index of the node module:

const { thing } = require('../../node_modules/eslint')

Any ideas what's going on here? Is that a bug or expected behavior? Or am I just using the package wrong? 🤔

nonara commented 1 year ago

Hi @AndrewSouthpaw. Sorry for the delayed response. This looks connected to a known issue which gets extremely into the weeds. Long story short, we had to reengineer the resolutions portion of the library to support some of these edge cases with indexes and to better support ESM.

At the moment, that's nearly finished, but I've not had time to finish it, unfortunately. In the mean time, you can use the @transform-path tag as a workaround!

nonara commented 1 year ago

Closing this issue as a duplicate.

Please follow this for updates: