Registry / testing / rollup-plugin-istanbul

rollup-plugin-istanbul

JSON →
library5.0.0jsnpmunverified

A Rollup plugin that provides seamless integration with Istanbul for code coverage. Version 5.0.0 supports Rollup v4 and uses istanbul-lib-instrument v6.0.1. Dropped Node.js 14 support in v5.0.0. Key differentiator: instruments source files before bundling to avoid instrumenting test code, with source map support. Released occasionally, maintained actively.

npm install rollup-plugin-istanbul
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-ISTA
R
rollup-plugin-istanbul
testingjavascriptv5.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import istanbul from 'rollup-plugin-istanbul'
const istanbul = require('rollup-plugin-istanbul')
Package ships CommonJS but also exports ESM; default import is the plugin function.
IstanbulPluginOptions (TypeScript)
import type { IstanbulPluginOptions } from 'rollup-plugin-istanbul'
TypeScript types are included; options interface is exported.
require() in CommonJS
const istanbul = require('rollup-plugin-istanbul')
const { istanbul } = require('rollup-plugin-istanbul')
The plugin is a default export; no named exports in CJS.

Shows how to use rollup-plugin-istanbul with Rollup to instrument source files for code coverage, excluding test files.

import { rollup } from 'rollup'; import istanbul from 'rollup-plugin-istanbul'; const bundle = await rollup({ input: 'src/index.js', plugins: [ istanbul({ exclude: ['test/**/*.js', 'node_modules/**'], instrumenterConfig: { esModules: true, compact: true, produceSourceMap: true, autoWrap: true, preserveComments: true } }) ] }); await bundle.write({ file: 'dist/bundle.js', format: 'iife' });
Debug
Known issues
breakingNode.js 14 dropped in v5.0.0; requires Node.js 16+. Also istanbul-lib-instrument v6.0.1 may have breaking changes in options.
fix
Upgrade Node.js to >=16 and review istanbul-lib-instrument migration.
affects: >=5.0.0
breakingv4.0.0: Dropped support for Node.js 10 and 12; istanbul-lib-instrument updated to v5.2.1.
fix
Use Node.js >=14 or stay on v3.x.
affects: >=4.0.0 <5.0.0
breakingv3.0.0: Defaults for autoWrap, preserveComments, esModules, produceSourceMap changed to true. Rollup minimum version 1.20.0. istanbul-lib-instrument v4.0.3.
fix
Explicitly set old defaults if needed; ensure Rollup >=1.20.0.
affects: >=3.0.0 <4.0.0
breakingv2.0.0: Switched from deprecated istanbul to istanbul-lib-instrument. API changed.
fix
Update instrumenterConfig options per istanbul-lib-instrument docs.
affects: >=2.0.0 <3.0.0
gotchaThe 'include' option defaults to all files if omitted; be sure to use 'exclude' to skip test files.
fix
Always set exclude or include patterns to avoid instrumenting tests.
affects: >=1.0.0
gotchaSource maps must be enabled in both the plugin (produceSourceMap: true) and Rollup output for accurate coverage.
fix
Set output.sourcemap: true or 'inline' in Rollup config.
affects: >=1.1.0
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-istanbul'
Package not installed or missing from dependencies.
fix
Run npm install --save-dev rollup-plugin-istanbul
TypeError: istanbul is not a function
Using named import instead of default import.
fix
Use import istanbul from 'rollup-plugin-istanbul' (default import).
Error: [plugin:istanbul] This plugin only works with Rollup >=1.20.0
Using an older version of Rollup.
fix
Upgrade Rollup to ^1.20.0||^2.0.0||^3.0.0||^4.0.0.
Error: Could not resolve source map from instrumented file
produceSourceMap is false or Rollup output sourcemap is disabled.
fix
Set instrumenterConfig.produceSourceMap: true and output.sourcemap: 'inline' or true.
Upgrade
Version history
5.0.0latest on npm
Audit
Dependencies
rolluprequiredPeer dependency, required to use the plugin.
Agent activity
9 hits · last 30 days
node
8
Resources
rollup-plugin-istanbul — npm install rollup-plugin-istanbul · libregistry