Oxc Coverage Instrument
July 21, 2026 ยท View on GitHub
Istanbul-compatible JavaScript and TypeScript coverage instrumentation built on the Oxc parser.
Instrumentation happens at the AST level through oxc_traverse and
oxc_codegen, and the output is checked against istanbul-lib-instrument on a
shared fixture corpus, both by count and byte for byte. The workspace also
provides the surrounding Istanbul-compatible pipeline: the data model,
source-map remapping, V8-to-Istanbul conversion, report summarization, and the
text, text-summary, json-summary, lcov, cobertura, and html
reporters. It does not claim to port every Istanbul package or reporter.
Install
[dependencies]
oxc_coverage_instrument = "0.11"
npm install oxc-coverage-instrument
cargo install --git https://github.com/fallow-rs/oxc-coverage-instrument oxc_coverage_instrument_cli
Usage
use oxc_coverage_instrument::{instrument, InstrumentOptions};
let source = "function add(a, b) { return a + b; }";
let result = instrument(source, "add.js", &InstrumentOptions::default()).unwrap();
assert_eq!(result.coverage_map.fn_map["0"].name, "add");
println!("{}", result.code);
import { instrument } from 'oxc-coverage-instrument';
const result = instrument(source, 'file.js', { sourceMap: true });
const coverageMap = JSON.parse(result.coverageMap);
oxc-coverage-instrument src/app.js -o dist/app.js --source-map
oxc-coverage-instrument report --format text coverage-final.json
Vitest, vite-plugin-istanbul, and custom Vite or Rollup plugins are covered in
the Node.js package README.
Documentation
- ARCHITECTURE.md for the pipeline, the crate map, and the cross-cutting concerns, including how to run the benchmark comparison.
oxc_coverage_instrumentreplacesistanbul-lib-instrument, and documents the deliberate divergences from it.oxc_coverage_instrument_napiis theoxc-coverage-instrumentnpm package, including the runtime matrix.oxc_coverage_instrument_cliis theoxc-coverage-instrumentbinary.oxc_coverage_typesreplacesistanbul-lib-coverage.oxc_coverage_source_mapsreplacesistanbul-lib-source-maps.oxc_coverage_v8replacesv8-to-istanbul.oxc_coverage_reportreplacesistanbul-lib-report, andoxc_coverage_reportsprovides a selected set ofistanbul-reports-compatible formats.examples/carries runnable projects for Vitest with TypeScript, Node with WebAssembly, and Cloudflare Workers.
Compatibility
- Rust 1.95 or newer, 2024 edition
- Oxc 0.140.x
- Istanbul
coverage-final.jsonv3 or newer - Node.js 18 or newer, through napi-rs
Related projects
| Project | AST |
|---|---|
istanbul-lib-instrument | Babel |
babel-plugin-istanbul | Babel |
swc-plugin-coverage-instrument | SWC |
Contributing
See CONTRIBUTING.md, and AGENTS.md for the workspace layout and the check profiles.
License
MIT