aleclarson / vite-tsconfig-paths

Support for TypeScript's path mapping in Vite
MIT License
1.28k stars 44 forks source link

vite-tsconfig-paths cannot import a basic TSconfig extends in sub-folder #150

Open matthew-dean opened 1 month ago

matthew-dean commented 1 month ago

I've reduced the test case to this: https://stackblitz.com/edit/vitest-dev-vitest-oip9io?initialPath=__vitest__/

You can see that this Vite plugin fails entirely to resolve paths using TSConfig settings.

It's important to note that:

  1. The app itself and TypeScript compiler work fine with this setup. Paths are always relative to their tsconfig.json file, but vite-tsconfig-paths does not account for that, and incorrectly merges path options.
  2. In my actual use case, I do not have control over extending from a sub-folder nor the paths. They are auto-generated by Nuxt.
matthew-dean commented 1 month ago

Note also that without parseNative, the plugin failed wildly, not just on path resolution, as there are multiple tsconfig.json files that extend from others in a Nuxt setup. But even if resolving "natively", it's not actually resolving natively in the way that TypeScript actually understands those paths.

juni0r commented 4 days ago

@matthew-dean Did you find a fix?