Describe the bug
cacheDir not honored if deps.optimizer.{mode}.enabled is true. vitest will save cache to node_modules/.vite as if cacheDir is not specified.
Reproduction
Run
npm create vite@latest
npm i
Edit the config
/// <reference types="vitest/config" />
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
cacheDir: ".vite",
plugins: [react()],
test: {
deps: {
optimizer: {
ssr: {
enabled: true // toggling this to repro
}
}
}
}
})
Create a test src/App.test.tsx
import { describe, expect, test } from "vitest";
describe("App", () =>{
test("works", () => {
expect(1).not.toBe(2);
});
});
Run
- Observe cache is unexpectedly created in
node_modules/.vite.
- Toggle
test.deps.optimizer.ssr.enabled to false, and run npx vitest again
- Observe cache is created in
.vite as expected
System Info
System:
OS: Windows 11 10.0.26120
CPU: (32) x64 AMD Ryzen 9 5950X 16-Core Processor
Memory: 41.33 GB / 63.91 GB
Binaries:
Node: 18.20.4 - ~\dotbin\extra\portable\nvm\symlink\node.EXE
npm: 10.7.0 - ~\dotbin\extra\portable\nvm\symlink\npm.CMD
bun: 1.1.6 - ~\.bun\bin\bun.EXE
Browsers:
Edge: Chromium (127.0.2651.86)
Internet Explorer: 11.0.26100.1
npmPackages:
@vitejs/plugin-react: ^4.3.2 => 4.3.2
vite: ^5.4.8 => 5.4.9
vitest: ^2.1.3 => 2.1.3
Used Package Manager
npm
Validations
Describe the bug
cacheDirnot honored ifdeps.optimizer.{mode}.enabledis true. vitest will save cache tonode_modules/.viteas ifcacheDiris not specified.Reproduction
Run
Edit the config
Create a test
src/App.test.tsxRun
node_modules/.vite.test.deps.optimizer.ssr.enabledtofalse, and runnpx vitestagain.viteas expectedSystem Info
System: OS: Windows 11 10.0.26120 CPU: (32) x64 AMD Ryzen 9 5950X 16-Core Processor Memory: 41.33 GB / 63.91 GB Binaries: Node: 18.20.4 - ~\dotbin\extra\portable\nvm\symlink\node.EXE npm: 10.7.0 - ~\dotbin\extra\portable\nvm\symlink\npm.CMD bun: 1.1.6 - ~\.bun\bin\bun.EXE Browsers: Edge: Chromium (127.0.2651.86) Internet Explorer: 11.0.26100.1 npmPackages: @vitejs/plugin-react: ^4.3.2 => 4.3.2 vite: ^5.4.8 => 5.4.9 vitest: ^2.1.3 => 2.1.3Used Package Manager
npm
Validations