Releases: craigvandotcom/vitest-affected
Releases · craigvandotcom/vitest-affected
v0.4.1 — Windows path fixes and hygiene
Fixed
- Windows path normalization — all file paths (git output, oxc-resolver output,
changedFilesoption, glob results) now consistently use forward slashes matching Vite convention. Previously,path.sepmismatches caused silent BFS failures on Windows, making every run fall back to full suite. isUnderRootDircache miss on Windows — usedpath.sepbut stored paths use/, causing every cache load to be a missCONFIG_BASENAMESmissing.cts/.cjsvariants — changingvitest.config.ctsorvite.config.cjswould not trigger full-suite safety fallbacksetupFilesrelative path comparison — relative setupFile paths from Vitest now resolved to absolute before comparison, preventing silent bypass of full-suite triggerwriteStatsLinesilent failures — now logs errors in verbose mode instead of swallowing all failures
Install
npm install -D vitest-affected@0.4.1v0.4.0 — Runtime-first architecture
What's New
Runtime-First Architecture
Replaced the static analysis pipeline (~1,500 lines) with runtime importDurations from Vitest. First run executes the full suite and caches the reverse dependency map; subsequent runs load the cache, delta-parse only changed files (~5ms), and BFS-select affected tests.
- v2 cache format (
{ version: 2, builtAt, reverseMap }) with automatic v1 migration builder.tsreduced from ~253 to ~133 linescache.tsreduced from ~834 to ~210 linesplugin.tsrewritten aroundconfigureVitesthook with runtime reporter injection- Net reduction: -2,969 lines across source and tests
Bug Fixes
- Cache overwrite on selective runs — was replacing entire cache with edges from only the tests that ran, now uses per-test merge strategy
- Stale edge pruning — cache was grow-only, now prunes edges for tests that ran before re-adding fresh ones
testModule.moduleIdnormalization — un-normalized paths with query strings failed lookup- Cross-platform path handling fixes (Windows compat, Vite
/vspath.sep) saveCacheSynctemp file cleanup onrenameSyncfailure
Removed
buildFullGraph,buildFullGraphSync, and all v1-only cache functions- 4 obsolete v1 test files
Install
npm install -D vitest-affectedSee README for setup instructions.
v0.3.0
What's New
Dependency Graph Caching (Phase 2)
- Graph persists to
.vitest-affected/graph.jsonwith mtime-based staleness detection - Only changed files are re-parsed on subsequent runs — cold-start graph building is a one-time cost
- New file discovery on incremental loads via glob pass
- Schema validation, path confinement, and stale entry pruning for cache integrity
Watch Mode + Runtime Edges (Phase 3)
- Runtime reporter captures actual module imports during test execution
- Runtime edges are merged into the static graph for more accurate watch-cycle filtering
- Handles cases where static analysis can't resolve dynamic imports
Security & Correctness Fixes
- Fix
normalizeModuleIdoff-by-one (/@fs/is 5 chars, not 4) - Add prototype pollution protection via
safeJsonReviveron all JSON.parse sites - Add forward-graph guard in runtime reporter callback
- Validate and prune
runtimeEdgesfrom existing cache before merging
Dogfooding
Successfully tested on a 2,863-test Next.js project (body-compass-app). With changedFiles pointing at a single utility file, the plugin selected 3 test files (22 tests) out of 162 test files — a 98% reduction in tests run.
Install
npm install -D vitest-affectedSee README for setup instructions.