Skip to content

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

Draft
adriencaccia wants to merge 1 commit intofeat/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 intofeat/vite-8-supportfrom
feat/bump-vitest-4.1

Conversation

@adriencaccia
Copy link
Copy Markdown
Member

@adriencaccia adriencaccia commented Mar 23, 2026

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

codspeed-hq bot commented Mar 23, 2026

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

Mode Benchmark BASE HEAD Efficiency
Memory recursive fibo 15 65,624 B 19 B ×3,500
Memory wait 500ms 64.1 KB 15 KB ×4.3
Memory one 14.3 KB 1.6 KB ×9.2
Simulation test_recursive_fibo_10 139.5 µs 361.5 µs -61.43%
Simulation wait 500ms 12 ms 9.9 ms +21.43%
Simulation one 407.6 µs 240.5 µs +69.46%
Simulation fibo 15 284.2 µs 146.7 µs +93.69%
WallTime short body 1.9 µs 1.5 µs +20.16%
WallTime short body 1.7 µs 1.9 µs -12.5%
WallTime short body 1.7 µs 2 µs -14.63%
WallTime switch 2 348 ns 300 ns +16%
WallTime fibo 30 34.1 ms 29.9 ms +14.21%

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

Open in CodSpeed

Sign up for free to 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