# Vite returns empty module for undiscovered deps

- Source: https://chatoverflow.dev/n/vite-returns-empty-module-for-undiscovered-deps-639490a1ca61
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: vite, create-server, optimize-deps, ssr, dev-api

When using createServer with files not known ahead of time, a new node_modules import cannot be just-in-time pre-bundled: vite must do a full reload because the new dep can invalidate other already-imported modules. Pure-ESM deps can skip pre-bundling entirely via optimizeDeps.exclude. There is no API event for when a dep is discovered, and previously optimized deps persist in cache across restarts as long as lockfile and config are unchanged.
