Registry / testing / sourcemap-istanbul-instrumenter-loader

sourcemap-istanbul-instrumenter-loader

JSON →
library0.2.0jsnpmunverified

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.

npm install sourcemap-istanbul-instrumenter-loader
INSTALL
IMPORT
SIG · SOURCEMAP-ISTANBUL
S
sourcemap-istanbul-instrumenter-loader
testingjavascriptv0.2.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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

istanbul-instrumenter-loader
require('istanbul-instrumenter-loader')
import istanbulInstrumenterLoader from 'istanbul-instrumenter-loader'
This is a CommonJS module; ES imports will fail. Only use require().
Webpack config usage (preLoaders)
preLoaders: [{ test: /\.js$/, include: path.resolve('src/components/'), loader: 'istanbul-instrumenter' }]
loaders: [{ test: /\.js$/, include: path.resolve('src/components/'), loader: 'istanbul-instrumenter' }]
In webpack 1, the loader must be in preLoaders, not loaders, to run before other transformations.
Loader name in webpack config
loader: 'istanbul-instrumenter'
loader: 'sourcemap-istanbul-instrumenter'
The npm package name differs from the loader name. The correct loader name is 'istanbul-instrumenter', not 'sourcemap-istanbul-instrumenter'.

Shows webpack 1 karma setup with istanbul-instrumenter-loader in preLoaders for code coverage.

// Install: npm i -D istanbul-instrumenter-loader istanbul karma karma-webpack karma-coverage // karma.conf.js config.set({ files: ['test/index.js'], preprocessors: { 'test/index.js': 'webpack' }, webpack: { module: { preLoaders: [ { test: /\.js$/, include: path.resolve('src/components/'), loader: 'istanbul-instrumenter' } ] } }, reporters: ['progress', 'coverage'], coverageReporter: { type: 'text' } }); // test/index.js const testsContext = require.context('./src/components/', true, /\.js$/); testsContext.keys().forEach(testsContext); const componentsContext = require.context('../src/components/', true, /\.js$/); componentsContext.keys().forEach(componentsContext);
Debug
Known issues
deprecatedThis package is deprecated. Use babel-plugin-istanbul or @istanbuljs/load-nyc-loader instead.
fix
Migrate to babel-plugin-istanbul: install and add to babel plugins.
affects: >=0
breakingIn webpack 2+, preLoaders are no longer supported.
fix
Use the rules property with enforce: 'pre' or use a custom plugin.
affects: >=0
gotchaThe package name on npm is 'istanbul-instrumenter-loader', but the repository URL points to 'sourcemap-istanbul-instrumenter-loader'. This discrepancy can cause confusion.
fix
Install using npm i -D istanbul-instrumenter-loader, not sourcemap-istanbul-instrumenter-loader.
affects: >=0
gotchaThis loader only works with Istanbul v0.x, not Istanbul v1+ (nyc).
fix
Use @istanbuljs/load-nyc-loader for nyc compatibility.
affects: >=0
Errors
Common errors & fixes
Module not found: Error: Cannot resolve module 'istanbul-instrumenter'
Loader name is missing the '-loader' suffix in webpack config.
fix
Use 'istanbul-instrumenter-loader' in the loader field, or ensure webpack resolves the loader correctly.
Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type.
Loader is not applied because it's placed in loaders instead of preLoaders (webpack 1).
fix
Move the loader configuration to the preLoaders property.
Cannot find module 'istanbul'
Istanbul is not listed as a dependency, but it is a peer dependency.
fix
Run npm i -D istanbul to install Istanbul explicitly.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
istanbulrequiredCore instrumentation library
loader-utilsrequiredWebpack loader utilities
Agent activity
14 hits · last 30 days
node
10
Resources
sourcemap-istanbul-instrumenter-loader — npm install sourcemap-istanbul-instrumenter-loader · libregistry