Babel plugin that instruments JavaScript code with Istanbul coverage. Version 8.0.0 (stable) requires Node >=18 and Babel 7/8. It automatically detects test files via nyc's exclude/include patterns and respects inline source maps. Unlike manual instrumentation, this plugin integrates seamlessly with existing Babel pipelines and tools like karma-coverage and nyc. Released as part of the istanbuljs project with regular updates and LTS support. Key differentiator: zero-config setup with nyc and Karma, and no need for separate coverage preprocessor.
npm install babel-plugin-istanbulVerified import paths — ran on the pinned version, not inferred.
Shows minimal setup to instrument code with babel-plugin-istanbul: install, configure .babelrc for test env, configure nyc to skip own instrumentation, and run tests with nyc.
Upgrade Node to 12 or later
Review exclude/include patterns; test-exclude now uses glob matching based on minimatch
Move exclude/include options to Babel plugin array: ["istanbul", { exclude: ["**/*.spec.js"] }]Set useInlineSourceMaps: false in plugin options if multiple build steps cause memory bloat.
Add 'nyc': { 'sourceMap': false, 'instrument': false }Update to babel-plugin-istanbul 7.0.0 or later, or ensure Babel config does not apply block scoping transform before instrumentation.
Run: npm install --save-dev babel-plugin-istanbul
Run: npm install --save-dev test-exclude