Open fwouts opened 1 year ago
Here's a draft I'm working on: https://github.com/aleclarson/vite-tsconfig-paths/compare/master...fwouts:lazy
This seems to be working (shaving off 20 seconds of unnecessary work in my case) but is completely missing the project references priority handling mentioned above, since I don't understand how that's supposed to work :)
It also assumes one directory = one project but the current implementation seems to support more than one resolver per directory? I'd love some more context here. Thanks!
Feel free to take over the code and implement it your way too, I don't care about attribution.
I would love to know your thoughts on this, thanks!
Hi @aleclarson, thanks again for putting this project together.
I was wondering what would be your opinion about a potential refactor (which I'd happily implement myself) to optimise vite-tsconfig-paths's performance on very large projects with many TypeScript projects referencing each other (e.g. thousands of tsconfig.json files).
At the moment, all tsconfig.json files inside the root are parsed in the
configResolved
hook, which if I understand correctly blocks the Vite dev server from starting up while this is ongoing.If Vite renders a specific page that only uses a small subset of the codebase, we may only use a relatively small number of TypeScript projects. What would you think of lazily loading the required TypeScript configs (via
tsconfck.parse/parseNative
) insideresolveId()
instead?I can think of the following issues getting in the way:
resolveId()
can be invoked concurrently, we may need to set up a mutex to ensure a config isn't parsed twice.I'd love to get your feedback on this idea before I go and make a PR for it. Thanks!