{"id":20562,"library":"sourcemap-istanbul-instrumenter-loader","title":"istanbul-instrumenter-loader","description":"Webpack loader that instruments JavaScript files with Istanbul for code coverage reporting. Version 0.2.0 is the latest stable release. This package is deprecated in favor of the official Istanbul monorepo loaders. It works with webpack 1 only and uses preLoaders. For webpack 2+, use babel-plugin-istanbul or the @istanbuljs/load-nyc-loader. Differentiator: it supports legacy webpack 1 projects; modern projects should use the official Istanbul toolchain.","status":"deprecated","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/zakhenry/istanbul-instrumenter-loader","tags":["javascript","webpack","loader","istanbul","coverage"],"install":[{"cmd":"npm install sourcemap-istanbul-instrumenter-loader","lang":"bash","label":"npm"},{"cmd":"yarn add sourcemap-istanbul-instrumenter-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add sourcemap-istanbul-instrumenter-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core instrumentation library","package":"istanbul","optional":false},{"reason":"Webpack loader utilities","package":"loader-utils","optional":false}],"imports":[{"note":"This is a CommonJS module; ES imports will fail. Only use require().","wrong":"import istanbulInstrumenterLoader from 'istanbul-instrumenter-loader'","symbol":"istanbul-instrumenter-loader","correct":"require('istanbul-instrumenter-loader')"},{"note":"In webpack 1, the loader must be in preLoaders, not loaders, to run before other transformations.","wrong":"loaders: [{ test: /\\.js$/, include: path.resolve('src/components/'), loader: 'istanbul-instrumenter' }]","symbol":"Webpack config usage (preLoaders)","correct":"preLoaders: [{ test: /\\.js$/, include: path.resolve('src/components/'), loader: 'istanbul-instrumenter' }]"},{"note":"The npm package name differs from the loader name. The correct loader name is 'istanbul-instrumenter', not 'sourcemap-istanbul-instrumenter'.","wrong":"loader: 'sourcemap-istanbul-instrumenter'","symbol":"Loader name in webpack config","correct":"loader: 'istanbul-instrumenter'"}],"quickstart":{"code":"// Install: npm i -D istanbul-instrumenter-loader istanbul karma karma-webpack karma-coverage\n\n// karma.conf.js\nconfig.set({\n  files: ['test/index.js'],\n  preprocessors: { 'test/index.js': 'webpack' },\n  webpack: {\n    module: {\n      preLoaders: [\n        {\n          test: /\\.js$/,\n          include: path.resolve('src/components/'),\n          loader: 'istanbul-instrumenter'\n        }\n      ]\n    }\n  },\n  reporters: ['progress', 'coverage'],\n  coverageReporter: { type: 'text' }\n});\n\n// test/index.js\nconst testsContext = require.context('./src/components/', true, /\\.js$/);\ntestsContext.keys().forEach(testsContext);\nconst componentsContext = require.context('../src/components/', true, /\\.js$/);\ncomponentsContext.keys().forEach(componentsContext);","lang":"javascript","description":"Shows webpack 1 karma setup with istanbul-instrumenter-loader in preLoaders for code coverage."},"warnings":[{"fix":"Migrate to babel-plugin-istanbul: install and add to babel plugins.","message":"This package is deprecated. Use babel-plugin-istanbul or @istanbuljs/load-nyc-loader instead.","severity":"deprecated","affected_versions":">=0"},{"fix":"Use the rules property with enforce: 'pre' or use a custom plugin.","message":"In webpack 2+, preLoaders are no longer supported.","severity":"breaking","affected_versions":">=0"},{"fix":"Install using npm i -D istanbul-instrumenter-loader, not sourcemap-istanbul-instrumenter-loader.","message":"The package name on npm is 'istanbul-instrumenter-loader', but the repository URL points to 'sourcemap-istanbul-instrumenter-loader'. This discrepancy can cause confusion.","severity":"gotcha","affected_versions":">=0"},{"fix":"Use @istanbuljs/load-nyc-loader for nyc compatibility.","message":"This loader only works with Istanbul v0.x, not Istanbul v1+ (nyc).","severity":"gotcha","affected_versions":">=0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use 'istanbul-instrumenter-loader' in the loader field, or ensure webpack resolves the loader correctly.","cause":"Loader name is missing the '-loader' suffix in webpack config.","error":"Module not found: Error: Cannot resolve module 'istanbul-instrumenter'"},{"fix":"Move the loader configuration to the preLoaders property.","cause":"Loader is not applied because it's placed in loaders instead of preLoaders (webpack 1).","error":"Module parse failed: Unexpected token (1:0)\nYou may need an appropriate loader to handle this file type."},{"fix":"Run npm i -D istanbul to install Istanbul explicitly.","cause":"Istanbul is not listed as a dependency, but it is a peer dependency.","error":"Cannot find module 'istanbul'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}