Function: xmOptimizeDeps()
API / @xmachines/shared / vite-aliases / xmOptimizeDeps
function xmOptimizeDeps(include?): DepOptimizationOptions;Defined in: vite-aliases.ts:291
Returns the standard Vite optimizeDeps config for browser test projects.
Tells Vite’s dep optimizer which packages to pre-bundle at startup rather than discovering them lazily at runtime. Without this, adding or changing dependencies (e.g. a lockfile change) causes Vite to re-optimize mid-run, producing the “Re-optimizing dependencies because lockfile has changed” warnings that slow down and occasionally destabilise browser test runs.
Every entry has to be a dependency the calling package declares. pnpm gives each
package its own node_modules, so a specifier the project does not declare cannot
be resolved from its root — and the optimizer only warns: Failed to resolve dependency: <name>, present in client 'optimizeDeps.include' on stderr, with the
run carrying on. That reads as a failure inside a passing job, and it hides the
same message when it is real. So nothing is pre-bundled by default: pass the
packages this project actually depends on.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
include | string[] | [] | Package specifiers to pre-bundle, each declared by the caller. |
Returns
DepOptimizationOptions