Repository navigation
🚨 Breaking Changes
- lib-instrument: Replace
babelwithrolldown+magic-string- by @AriPerkkio in #28 (fdd34)
@vitest/istanbul-lib-instrument no longer uses Babel. Code is parsed with OXC (via rolldown) and coverage counters are inserted into the original code with magic-string. The coverage maps produced are the same as before. (#28)
rolldownis now a dependency (^1.0.0). Vite 8 and Vitest 5 already depend on it.- Removed
programVisitor(and theVisitorOptions/VisitorExitResulttypes). The Babel-plugin API has no replacement. - Removed the
parserPluginsandgeneratorOptsoptions. JSX, decorators, import attributes and other modern syntax parse without plugins. TypeScript is not parsed; transpile it before instrumenting. compact,preserveCommentsanddebugare deprecated and have no effect. The original code, including its formatting and comments, is kept as-is.- Instrumented output looks different. The original formatting, comments and line numbers are kept, and the coverage header sits on the first line (after any hashbang or
"use strict"). readInitialCoverage()accepts a code string or an ESTreeProgram(from OXC/rolldown) instead of a Babel AST. Code instrumented by previous versions is still read correctly.- Source maps referenced by
sourceMappingURLcomments are no longer loaded automatically. PassinputSourceMaptoinstrumentSync()explicitly. - Parse errors are OXC
SyntaxErrors, with different messages. Some strict-mode errors Babel reported, such aswithin ES modules, are no longer raised.
🚀 Features
- lib-instrument: Add
combineSourceMapsoption to support vitest-dev/vitest#9040 better - by @AriPerkkio in #29
🏎 Performance
Instrumenting with @vitest/istanbul-lib-instrument 1.0.2 vs 2.0.0. TypeScript inputs are first transformed to JavaScript with a source map, the same way Vite does before Vitest's coverage plugin runs, and instrumented with the options of @vitest/coverage-istanbul.
Usage via @vitest/coverage-istanbul.
Includes speed-up from combineSourceMaps: false (see vitest-dev/vitest#9040):
| Input | Vitest 5.x + 1.0.2 |
Vitest + 2.0.0 |
Speedup |
|---|---|---|---|
TypeScript's checker.ts |
4,328 ms | 501 ms | 8.6× |
| Vitest repository, 479 files | 3,727 ms | 376 ms | 9.9× |
Plain library usage:
| Input | Size (JS) | 1.0.2 |
2.0.0 |
Speedup | Memory (RSS) 1.0.2 → 2.0.0 |
|---|---|---|---|---|---|
TypeScript's checker.ts, 1 file |
2.4 MB, 48k lines | 2,198 ms | 567 ms | 3.9× | 2.7 GB → 0.8 GB |
| Vitest repository, 479 source files | 1.9 MB, 56k lines | 1,913 ms | 443 ms | 4.3× | 313 MB → 211 MB |
Coverage results are identical between the versions: the same statements, functions and branches (39,720 for checker.ts, 39,985 for the Vitest repository).
Apple M2, 16 GB, Node.js 22.22.0. Each number is the median of 3 separate processes with 5 iterations each, after a warmup run. Time covers instrumentSync() only, not parsing the TypeScript source.
📦 Dependency reduction
@babel/core and @babel/parser are removed from the dependency tree. @vitest/istanbul-lib-instrument now depends on @istanbuljs/schema, @jridgewell/remapping, @jridgewell/trace-mapping, magic-string and rolldown. Most of these are transitive dependencies in Vitest.