Registry / testing / esbuild-plugin-istanbul

esbuild-plugin-istanbul

JSON →
library0.3.0jsnpmunverified

An esbuild plugin that instruments JavaScript/TypeScript source code with Istanbul/nyc code coverage instrumentation during the build process. Version 0.3.0 is the current stable release; the package is updated infrequently with no fixed cadence. It works as an esbuild plugin, applying Istanbul's instrumentation to files matched by configurable filters and loaders (js, jsx, ts, tsx). Unlike alternatives that require Babel or Webpack, this plugin integrates directly with esbuild's fast build pipeline. It ships TypeScript definitions and supports both ESM and CJS environments. Key differentiator: native esbuild integration without additional transform steps.

npm install esbuild-plugin-istanbul
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-IST
E
esbuild-plugin-istanbul
testingjavascriptv0.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

esbuildPluginIstanbul
import { esbuildPluginIstanbul } from 'esbuild-plugin-istanbul'
import esbuildPluginIstanbul from 'esbuild-plugin-istanbul'
This is a named export, not a default export. Both ESM and CJS work.
esbuildPluginIstanbul
const { esbuildPluginIstanbul } = require('esbuild-plugin-istanbul')
const esbuildPluginIstanbul = require('esbuild-plugin-istanbul')
CommonJS destructuring is required because it's a named export.
PluginOptions
import type { PluginOptions } from 'esbuild-plugin-istanbul'
TypeScript only; not available at runtime.

Shows how to instrument TypeScript source with Istanbul coverage using esbuild.

import { esbuildPluginIstanbul } from 'esbuild-plugin-istanbul'; import * as esbuild from 'esbuild'; await esbuild.build({ entryPoints: ['src/index.ts'], bundle: true, outdir: 'dist', plugins: [ esbuildPluginIstanbul({ filter: /\.tsx?$/, loader: 'ts', name: 'istanbul', }), ], });
Debug
Known issues
gotchaMust specify correct loader for file type (js/jsx/ts/tsx). Using wrong loader may break instrumentation.
fix
Set loader to match file extension: 'js' for .js, 'jsx' for .jsx, 'ts' for .ts, 'tsx' for .tsx.
affects: >=0.0.0
gotchaThe plugin only processes files matched by the filter regex. If filter is too narrow, some files may be skipped.
fix
Ensure filter regex matches all files you intend to instrument (e.g., /\.(js|jsx|ts|tsx)$/).
affects: >=0.0.0
gotchaInstrumentation may significantly slow down builds for large projects.
fix
Consider using incremental builds or caching mechanisms in development.
affects: >=0.0.0
deprecatedPlugin options may change in future minor versions; no deprecation notices yet.
fix
Pin exact version in package.json.
affects: 0.x
Errors
Common errors & fixes
Error: Cannot find module 'esbuild-plugin-istanbul'
Package not installed or import path is incorrect.
fix
Run npm install esbuild-plugin-istanbul and ensure import uses correct named export.
Module 'esbuild-plugin-istanbul' has no default export
Attempting default import instead of named import.
fix
Use import { esbuildPluginIstanbul } from 'esbuild-plugin-istanbul'.
TypeError: esbuildPluginIstanbul is not a function
CommonJS require without destructuring returns an object with the function as a property.
fix
Use const { esbuildPluginIstanbul } = require('esbuild-plugin-istanbul').
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies
esbuildrequiredpeer dependency required to register the plugin
nycrequiredinstalls istanbul-lib-instrument for code instrumentation
Agent activity
4 hits · last 30 days
node
4
Resources
esbuild-plugin-istanbul — npm install esbuild-plugin-istanbul · libregistry