aleclarson / vite-tsconfig-paths

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

fix: stop caching `viteResolve` in buildStart #36

Closed jamesknelson closed 2 years ago

jamesknelson commented 2 years ago

This fixes issue #31.

It seems that the issue here was that resolveId is being called before buildStart, when a node_modules/.vite cache doesn't exist.

Further investigation revealed that we can't wait for buildStart because it causes the build to lock up. We're also unable to cache the viteResolve function, as the result seems to change as the build progresses.

The fix involves just creating a new viteResolve function on every call to resolveId. This may cause a slight degradation in performance, but it doesn't seem noticeable to me.

aleclarson commented 2 years ago

Released in v3.3.14

Thank you