{"id":19421,"library":"coverage-istanbul-loader","title":"coverage-istanbul-loader","description":"A Webpack loader that uses Istanbul to add code coverage instrumentation to JavaScript/TypeScript files. Current stable version is 3.0.5. Release cadence is low; last major update was in 2020. Key differentiators include support for modern Istanbul API (istanbul-lib-instrument) and better source map handling compared to the older istanbul-instrumenter-loader. Ships TypeScript definitions. Requires Node >=10 and Webpack 4+. Works with Karma, TypeScript, and custom options.","status":"active","version":"3.0.5","language":"javascript","source_language":"en","source_url":"https://github.com/JS-DevTools/coverage-istanbul-loader","tags":["javascript","webpack-loader","webpack","loader","istanbul","coverage","code coverage","instrumentation","instrumenter","typescript"],"install":[{"cmd":"npm install coverage-istanbul-loader","lang":"bash","label":"npm"},{"cmd":"yarn add coverage-istanbul-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add coverage-istanbul-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for loader usage","package":"webpack","optional":false},{"reason":"Core instrumentation library","package":"istanbul-lib-instrument","optional":false}],"imports":[{"note":"ESM-only since v3. CommonJS require will fail.","wrong":"const CoverageIstanbulLoader = require('@jsdevtools/coverage-istanbul-loader')","symbol":"default","correct":"import CoverageIstanbulLoader from '@jsdevtools/coverage-istanbul-loader'"},{"note":"In CommonJS, must grab .default property.","wrong":"const loader = require('@jsdevtools/coverage-istanbul-loader')","symbol":"loader function","correct":"const { default: loader } = require('@jsdevtools/coverage-istanbul-loader')"},{"note":"Full scoped package name required.","wrong":"use: 'coverage-istanbul-loader' (without @jsdevtools scope)","symbol":"Webpack rule usage","correct":"module.exports = { module: { rules: [ { test: /\\.js$/, use: { loader: '@jsdevtools/coverage-istanbul-loader', options: { esModules: true } } } ] } }"}],"quickstart":{"code":"// webpack.config.js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        exclude: /node_modules/,\n        use: {\n          loader: '@jsdevtools/coverage-istanbul-loader',\n          options: {\n            esModules: true,\n            produceSourceMap: true\n          }\n        }\n      }\n    ]\n  }\n};\n// Run webpack, output bundle will have coverage instrumentation.\n// Then run tests with Karma + karma-coverage-istanbul-reporter.","lang":"javascript","description":"Configures Webpack to instrument JavaScript files for code coverage using Istanbul, with modern options."},"warnings":[{"fix":"Use import or dynamic import(), or downgrade to v2.x.","message":"Version 3.0 is ESM-only. Using require() will fail with 'require() of ES modules not supported'.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Ensure this loader is listed last in the 'use' array (i.e., executed first).","message":"Loader must be placed before other loaders (like babel-loader) in webpack config to instrument original source.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Replace 'instrumenter' with 'istanbul-lib-instrument' options (e.g., 'esModules').","message":"Option 'instrumenter' is deprecated in favor of 'istanbul-lib-instrument' options.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Set produceSourceMap: true in loader options.","message":"Source maps may not work correctly if options.produceSourceMap is not set to true.","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install @jsdevtools/coverage-istanbul-loader --save-dev","cause":"Loader not installed or typo in package name.","error":"Error: Cannot find module '@jsdevtools/coverage-istanbul-loader'"},{"fix":"Use dynamic import: const loader = (await import('@jsdevtools/coverage-istanbul-loader')).default;","cause":"Using CommonJS require() on ESM-only v3.","error":"TypeError: loader.run is not a function"},{"fix":"npm install istanbul-lib-instrument --save-dev","cause":"Missing peer dependency.","error":"Module build failed: Error: Cannot find module 'istanbul-lib-instrument'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}