Skip to content

fix(vitest-plugin): migrate deprecated vitest 4.1 imports - #75

Draft
adriencaccia wants to merge 1 commit into
feat/vite-8-supportfrom
feat/bump-vitest-4.1
Draft

fix(vitest-plugin): migrate deprecated vitest 4.1 imports#75
adriencaccia wants to merge 1 commit into
feat/vite-8-supportfrom
feat/bump-vitest-4.1

Conversation

@adriencaccia

@adriencacciaadriencaccia commented Mar 23, 2026

Copy link
Copy Markdown
Member

Migrate away from deprecated vitest/runners and vitest/suite subpath imports.

Vitest 4.1 deprecated these subpath imports, printing console.warn on every load:

  • vitest/runners → use BenchmarkRunner from vitest
  • vitest/suite → use TestRunner static methods from vitest

Since the plugin still supports vitest 3.2 (which doesn't export from the main entry), a compat module (src/compat.ts) dynamically resolves the correct import path at runtime using top-level await:

  • vitest 4.1+: imports from vitest main entry (no warnings)
  • vitest 3.x: falls back to vitest/runners and vitest/suite (no warnings on 3.x)

Verified locally with codspeed run — both simulation and walltime modes work on vitest 4.1.1 (no deprecation warnings) and vitest 3.2.4 (backwards compatible).

Other changes:

  • Bump vitest devDep from ^4.0.18 to ^4.1.1
  • Revert vite devDep to ^7.0.0 — vite 8 + rolldown requires Node 20.19+, dev env is 20.5.1. See chore: bump Node.js minimum to 20.19+ for vite 8 dev testing #76 for the Node.js bump.
  • Add jsPluginsWithTarget to rollup options for runner bundles that need esnext target (top-level await)
  • Remove stale @ts-expect-error comments (vitest 4.1 fixed the getBenchFn types)
  • Update instrumented test to mock ../compat instead of vitest/suite

…e imports
Vitest 4.1 deprecated the `vitest/runners` and `vitest/suite` subpath
imports, printing console warnings on every load. Introduce a compat
module that dynamically resolves imports: on vitest 4.1+ it uses the
main `vitest` entry point (BenchmarkRunner, TestRunner statics), and
on vitest 3.x it falls back to the old subpath imports (no warnings
on either version).
Also bump vitest devDependency from 4.0.18 to 4.1.1, revert vite
devDependency to ^7 to keep compatibility with Node 20.5.1 (vite 8
+ rolldown requires Node 20.19+), and remove the now-unnecessary
rolldown devDependency and tsconfig paths workaround.
Co-Authored-By: Claude <noreply@anthropic.com>
@codspeed-hq

Copy link
Copy Markdown

Merging this PR will degrade performance by 61.43%

⚡ 9 improved benchmarks
❌ 3 regressed benchmarks
✅ 156 untouched benchmarks

⚠️Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

ModeBenchmarkBASEHEADEfficiency
Memoryrecursive fibo 1565,624 B19 B×3,500
Memorywait 500ms64.1 KB15 KB×4.3
Memoryone14.3 KB1.6 KB×9.2
Simulationtest_recursive_fibo_10139.5 µs361.5 µs-61.43%
Simulationwait 500ms12 ms9.9 ms+21.43%
Simulationone407.6 µs240.5 µs+69.46%
Simulationfibo 15284.2 µs146.7 µs+93.69%
WallTimeshort body1.9 µs1.5 µs+20.16%
WallTimeshort body1.7 µs1.9 µs-12.5%
WallTimeshort body1.7 µs2 µs-14.63%
WallTimeswitch 2348 ns300 ns+16%
WallTimefibo 3034.1 ms29.9 ms+14.21%

Comparing feat/bump-vitest-4.1 (d104278) with feat/vite-8-support (1a48730)

Open in CodSpeed

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@adriencaccia