aleclarson / vite-tsconfig-paths

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

Full Working Example? #133

Open shellscape opened 8 months ago

shellscape commented 8 months ago

Any chance we can get a Stackblitz full working example posted in the docs for this?

I'm unable to get a very basic project working with this plugin, so there must be nuance to how this has to be setup. Specifically, the import-analysis keeps nuking my build, and I've tried every combination of settings. Would love to have a baseline reference of a working project to go off of for both Vite 4 and Vite 5

shellscape commented 8 months ago

(FWIW my issue was related to an expectation that vite-tsconfig-paths was using the findUp functionality of tsconfk. However, it is not, and won't search parent directories for tsconig.json. I had to wire up that functionality myself to tell the plugin where to look. It would still be good of the project to put together a baseline Stackblitz, which could then be used as a reproduction template for forking)

aleclarson commented 8 months ago

There is the ./demo folder within this repository that you could play with. PR welcome to anyone who wants to set up a StackBlitz for the README.

FWIW my issue was related to an expectation that vite-tsconfig-paths was using the findUp functionality of tsconfk. However, it is not, and won't search parent directories for tsconig.json.

This plugin uses tsconfck.findAll as long as the projects option isn't used.

https://github.com/aleclarson/vite-tsconfig-paths/blob/ca4e2aa7f3be36facbce0305cc145f9d5f9693d1/src/index.ts#L63-L68

shellscape commented 8 months ago

Good to know. Will run with this and try to setup a repro stackblitz for you

m-shum commented 1 month ago

Seconded. Without a demo it's impossible to tell whether this module is set up correctly or not. How do you set an alias, for example? Can you set an alias? What's the default? Would be great to get some expansion of the docs with clearer examples of usage, especially for less experienced users.