aleclarson / vite-tsconfig-paths

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

v5 breaks if you have both tsconfig and jsconfig #158

Closed simon-abbott closed 3 weeks ago

simon-abbott commented 2 months ago

We have a weird half-legacy setup that has both a jsconfig.json for our legacy code and a tsconfig.json for our modern code. Both files define "paths" containing different sets of paths. v4 of this package handled this just fine, but in v5 it seems to only check the jsconfig then abort without ever checking the tsconfig.json.

From looking at the diff between v4 and v5 I suspect that v4 had the same bug but in reverse (i.e. it only read the tsconfig and not the jsconfig), and it just happened to not cause any issues because the jsconfig only has native node imports definitions.

Changing this line to be return [path && suffix ? path + suffix : path, !!path] fixed the issue for me. Not sure if there is a cleaner solution though.

aleclarson commented 3 weeks ago

Thanks for reporting! Fixed in v5.1.0