From a469465ad906218765f04f665739646603170cc2 Mon Sep 17 00:00:00 2001 From: Kurt Overmier Date: Sun, 20 Sep 2026 06:49:15 -0500 Subject: [PATCH] perf(test): persist vitest transforms with fsModuleCache vitest 5 reports that transforming the module graph took 51% of tracked time and is re-done on every run. fsModuleCache (new in 5.x, default false) persists transform results to disk and reuses them across reruns and separate vitest processes. Measured on this suite, 62 files / 892 tests: before (no cache) 21.62s tracked, transform 51%, 25.60s wall cold (cache empty) 20.87s tracked, transform 44% warm (cache warm) 18.91s tracked, transform 19%, 23.48s wall Transform drops from 51% to 19% of tracked time; wall time gains ~8%, since import cost now dominates rather than transform. The win is real but smaller than the 51% figure suggests -- transform overlaps other work. Cold runs are not penalised. Cache lands in node_modules/.vitest-cache (4.9M), the documented default. It sits inside node_modules so a reinstall invalidates it, and the existing node_modules/ entry in .gitignore already covers it -- no ignore change needed, and CI installs fresh so it is a no-op there. --- vitest.config.mts | 1 + 1 file changed, 1 insertion(+) diff --git a/vitest.config.mts b/vitest.config.mts index abbc009..c90c18f 100644 --- a/vitest.config.mts +++ b/vitest.config.mts @@ -3,5 +3,6 @@ import { defineConfig } from 'vitest/config'; export default defineConfig({ test: { include: ['packages/*/src/__tests__/**/*.test.ts'], + fsModuleCache: true, }, });