esbuild-plugin-ignoretests

raw JSON →
0.0.7 verified Fri May 01 auth: no javascript

An esbuild plugin to exclude test files from the build output. Version 0.0.7 is current; release frequency is low. It integrates seamlessly with tsup and other esbuild-based builders. The plugin accepts an optional custom regular expression for fine-grained control. Differentiates by specifically targeting test files that co-locate with source components, a pattern common in large libraries like Chakra UI. Ships TypeScript types. Minimal footprint with no runtime dependencies.

error ReferenceError: ignoretestsPlugin is not defined
cause Using named import or incorrect import syntax when the package only provides a default export.
fix
Use default import: import ignoretestsPlugin from 'esbuild-plugin-ignoretests'
gotcha The plugin only filters files based on path patterns; it does not exclude test imports from the bundle if they are referenced by non-test files.
fix Ensure test files are not imported by any production code. The plugin only prevents direct entry points or matching path patterns from being built.
deprecated Version 0.0.7 is the latest; no deprecation warnings issued.
fix N/A
npm install esbuild-plugin-ignoretests
yarn add esbuild-plugin-ignoretests
pnpm add esbuild-plugin-ignoretests

Build an esbuild bundle while ignoring test files (e.g., *.test.ts, *.spec.ts) from the output.

// esbuild.config.js
import * as esbuild from 'esbuild';
import ignoretestsPlugin from 'esbuild-plugin-ignoretests';

await esbuild.build({
  entryPoints: ['src/index.ts'],
  outfile: 'dist/index.js',
  bundle: true,
  plugins: [ignoretestsPlugin()],
});