Dependencies are scanned statically and pre-bundled with esbuild, so anything imported through a computed path is missed and discovered mid-navigation.
export default defineConfig({
optimizeDeps: {
include: ['some-pkg/deep/module'], // not statically visible
exclude: ['a-pkg-that-breaks-esbuild'],
},
})
# and the cache, which occasionally needs deleting by hand
$ rm -rf node_modules/.vite
The symptom of a missed dependency is a full page reload in the middle of navigating, as Vite discovers and bundles it — which looks like a bug rather than a cache miss. Deleting node_modules/.vite is the first thing to try whenever Vite behaves inexplicably, and it is the answer often enough to be worth a script.