{"id":34353131,"url":"https://github.com/webpack-contrib/istanbul-instrumenter-loader","last_synced_at":"2025-12-30T03:01:31.047Z","repository":{"id":21139092,"uuid":"24441159","full_name":"webpack-contrib/istanbul-instrumenter-loader","owner":"webpack-contrib","description":"Istanbul Instrumenter Loader","archived":true,"fork":false,"pushed_at":"2020-12-10T17:11:12.000Z","size":1092,"stargazers_count":270,"open_issues_count":27,"forks_count":63,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-12-21T07:56:20.339Z","etag":null,"topics":["coverage","istanbul","karma","webpack-loader"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webpack-contrib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-25T02:48:17.000Z","updated_at":"2025-12-01T16:26:27.000Z","dependencies_parsed_at":"2022-08-08T11:30:16.148Z","dependency_job_id":null,"html_url":"https://github.com/webpack-contrib/istanbul-instrumenter-loader","commit_stats":null,"previous_names":["deepsweet/istanbul-instrumenter-loader"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/webpack-contrib/istanbul-instrumenter-loader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fistanbul-instrumenter-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fistanbul-instrumenter-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fistanbul-instrumenter-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fistanbul-instrumenter-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webpack-contrib","download_url":"https://codeload.github.com/webpack-contrib/istanbul-instrumenter-loader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fistanbul-instrumenter-loader/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27995845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-24T02:00:07.193Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coverage","istanbul","karma","webpack-loader"],"created_at":"2025-12-18T01:39:16.623Z","updated_at":"2025-12-30T03:01:31.042Z","avatar_url":"https://github.com/webpack-contrib.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm][npm]][npm-url]\n[![node][node]][node-url]\n[![deps][deps]][deps-url]\n[![tests][tests]][tests-url]\n[![coverage][cover]][cover-url]\n[![chat][chat]][chat-url]\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/webpack/webpack\"\u003e\n    \u003cimg width=\"200\" height=\"200\"\n      src=\"https://webpack.js.org/assets/icon-square-big.svg\"\u003e\n  \u003c/a\u003e\n  \u003ch1\u003eIstanbul Instrumenter Loader\u003c/h1\u003e\n\u003c/div\u003e\n\nInstrument JS files with [istanbul-lib-instrument](https://github.com/istanbuljs/istanbuljs/tree/master/packages/istanbul-lib-instrument) for subsequent code coverage reporting\n\n\u003ch2 align=\"center\"\u003eInstall\u003c/h2\u003e\n\n```bash\nnpm i -D istanbul-instrumenter-loader\n```\n\n\u003ch2 align=\"center\"\u003e\u003ca href=\"https://webpack.js.org/concepts/loaders\"\u003eUsage\u003c/a\u003e\u003c/h2\u003e\n\n### `References`\n\n* [karma-webpack](https://github.com/webpack/karma-webpack)\n* [karma-coverage-istanbul-reporter](https://github.com/mattlewis92/karma-coverage-istanbul-reporter)\n\n### `Structure`\n\n```\n├─ src\n│ |– components\n│ | |– bar\n│ | │ |─ index.js\n│ | |– foo/\n│     |– index.js\n|– test\n| |– src\n| | |– components\n| | | |– foo\n| | | | |– index.js\n```\n\nTo create a code coverage report for all components (even for those for which you have no tests yet) you have to require all the 1) sources and 2) tests. Something like it's described in [\"alternative usage\" of karma-webpack](https://github.com/webpack/karma-webpack#alternative-usage)\n\n**test/index.js**\n```js\n// requires all tests in `project/test/src/components/**/index.js`\nconst tests = require.context('./src/components/', true, /index\\.js$/);\n\ntests.keys().forEach(tests);\n\n// requires all components in `project/src/components/**/index.js`\nconst components = require.context('../src/components/', true, /index\\.js$/);\n\ncomponents.keys().forEach(components);\n```\n\n\u003e ℹ️  This file will be the only `entry` point for `karma`\n\n**karma.conf.js**\n```js\nconfig.set({\n  ...\n  files: [\n    'test/index.js'\n  ],\n  preprocessors: {\n    'test/index.js': 'webpack'\n  },\n  webpack: {\n    ...\n    module: {\n      rules: [\n        // instrument only testing sources with Istanbul\n        {\n          test: /\\.js$/,\n          use: { loader: 'istanbul-instrumenter-loader' },\n          include: path.resolve('src/components/')\n        }\n      ]\n    }\n    ...\n  },\n  reporters: [ 'progress', 'coverage-istanbul' ],\n  coverageIstanbulReporter: {\n    reports: [ 'text-summary' ],\n    fixWebpackSourcePaths: true\n  }\n  ...\n});\n```\n\n### with `Babel`\n\nYou must run the instrumentation as a post step\n\n**webpack.config.js**\n```js\n{\n  test: /\\.js$|\\.jsx$/,\n  use: {\n    loader: 'istanbul-instrumenter-loader',\n    options: { esModules: true }\n  },\n  enforce: 'post',\n  exclude: /node_modules|\\.spec\\.js$/,\n}\n```\n\n\u003ch2 align=\"center\"\u003e\u003ca href=\"https://github.com/istanbuljs/istanbuljs/blob/master/packages/istanbul-lib-instrument/api.md#instrumenter\"\u003eOptions\u003c/a\u003e\u003c/h2\u003e\n\nThe loader supports all options supported by `istanbul-lib-instrument`\n\n|Name|Type|Default|Description|\n|:--:|:--:|:-----:|:----------|\n|**`debug`**|`{Boolean}`|`false`|Turn on debugging mode|\n|**`compact`**|`{Boolean}`|`true`|Generate compact code|\n|**`autoWrap`**|`{Boolean}`|`false`|Set to `true` to allow return statements outside of functions|\n|**`esModules`**|`{Boolean}`|`false`|Set to `true` to instrument ES2015 Modules|\n|**`coverageVariable`**|`{String}`|`__coverage__`|Name of global coverage variable|\n|**`preserveComments`**|`{Boolean}`|`false`|Preserve comments in `output`|\n|**`produceSourceMap`**|`{Boolean}`|`false`|Set to `true` to produce a source map for the instrumented code|\n|**`sourceMapUrlCallback`**|`{Function}`|`null`|A callback function that is called when a source map URL is found in the original code. This function is called with the source filename and the source map URL|\n\n**webpack.config.js**\n```js\n{\n  test: /\\.js$/,\n  use: {\n    loader: 'istanbul-instrumenter-loader',\n    options: {...options}\n  }\n}\n```\n\n\u003ch2 align=\"center\"\u003eMaintainers\u003c/h2\u003e\n\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003cimg width=\"150\" height=\"150\"\n        src=\"https://avatars.githubusercontent.com/u/266822?v=3\u0026s=150\"\u003e\n        \u003c/br\u003e\n        \u003ca href=\"https://github.com/deepsweet\"\u003eKir Belevich\u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003ca href=\"https://github.com/bebraw\"\u003e\n          \u003cimg width=\"150\" height=\"150\" src=\"https://github.com/bebraw.png?v=3\u0026s=150\"\u003e\n          \u003c/br\u003e\n          Juho Vepsäläinen\n        \u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003ca href=\"https://github.com/d3viant0ne\"\u003e\n          \u003cimg width=\"150\" height=\"150\" src=\"https://github.com/d3viant0ne.png?v=3\u0026s=150\"\u003e\n          \u003c/br\u003e\n          Joshua Wiens\n        \u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003ca href=\"https://github.com/michael-ciniawsky\"\u003e\n          \u003cimg width=\"150\" height=\"150\" src=\"https://github.com/michael-ciniawsky.png?v=3\u0026s=150\"\u003e\n          \u003c/br\u003e\n          Michael Ciniawsky\n        \u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003ca href=\"https://github.com/mattlewis92\"\u003e\n          \u003cimg width=\"150\" height=\"150\" src=\"https://github.com/mattlewis92.png?v=3\u0026s=150\"\u003e\n          \u003c/br\u003e\n          Matt Lewis\n        \u003c/a\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n  \u003ctbody\u003e\n\u003c/table\u003e\n\n\n[npm]: https://img.shields.io/npm/v/istanbul-instrumenter-loader.svg\n[npm-url]: https://npmjs.com/package/istanbul-instrumenter-loader\n\n[node]: https://img.shields.io/node/v/istanbul-instrumenter-loader.svg\n[node-url]: https://nodejs.org\n\n[deps]: https://david-dm.org/webpack-contrib/istanbul-instrumenter-loader.svg\n[deps-url]: https://david-dm.org/webpack-contrib/istanbul-instrumenter-loader\n\n[tests]: http://img.shields.io/travis/webpack-contrib/istanbul-instrumenter-loader.svg\n[tests-url]: https://travis-ci.org/webpack-contrib/istanbul-instrumenter-loader\n\n[cover]: https://codecov.io/gh/webpack-contrib/istanbul-instrumenter-loader/branch/master/graph/badge.svg\n[cover-url]: https://codecov.io/gh/webpack-contrib/istanbul-instrumenter-loader\n\n[chat]: https://badges.gitter.im/webpack/webpack.svg\n[chat-url]: https://gitter.im/webpack/webpack\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack-contrib%2Fistanbul-instrumenter-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebpack-contrib%2Fistanbul-instrumenter-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack-contrib%2Fistanbul-instrumenter-loader/lists"}