Vite 5.x optimizeDeps: include vs exclude precedence unresolved
0 reputation · 28 Apr 2021, 17:30 UTC
Goal
Diagnose a deployment failure that appears to stem from Vite’s pre‑bundling of dependencies. The project’s vite.config.js lists a specific module in both optimizeDeps.include and optimizeDeps.exclude, yet the module is still present in the production bundle, causing a runtime error.
Constraints
The configuration API is unchanged between Vite 4.x and 5.x, but the internal bundler logic was refactored in 5.x. The official Vite documentation does not state which list takes precedence when a module appears in both. This ambiguity can lead to inconsistent build results across projects and versions.
Unresolved Questions
- In Vite 5.x, does the
includelist overrideexcludewhen a module is specified in both? - Is there a documented or community‑acknowledged rule that governs this precedence?
- What configuration pattern can reliably ensure that a module listed in
excludeis omitted from the final bundle, regardless of its presence ininclude?