Registry / testing / esbuild-jest2

esbuild-jest2

JSON →
library0.6.7jsnpmunverified

A Jest transformer that uses esbuild for fast compilation of TypeScript, JavaScript, JSX, and TSX files. Version 0.6.7 is the latest stable release, maintained as a fork of the abandoned esbuild-jest with active updates for Jest v29+. It integrates esbuild's blazing-fast bundler into the Jest transform pipeline, supporting custom loaders, sourcemaps, JSX factory/fragment configuration, and target/format options. Unlike ts-jest, which relies on tsc, esbuild-jest2 offers significantly faster transformation but does not enforce type checking. It requires esbuild >=0.20.1 as a peer dependency and ships TypeScript declarations.

npm install esbuild-jest2
INSTALL
IMPORT
SIG · ESBUILD-JEST2
E
esbuild-jest2
testingjavascriptv0.6.7
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

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

esbuild-jest2
✓ import { createTransformer } from 'esbuild-jest2'
✗ import esbuildJest from 'esbuild-jest2'
The package exposes a named export `createTransformer`, not a default export. CommonJS users should use `const { createTransformer } = require('esbuild-jest2')`.
Options
✓ import type { Options } from 'esbuild-jest2'
✗ import { Options } from 'esbuild-jest2'
Options is a TypeScript interface and should be imported with `import type` to avoid runtime inclusion.
Jest config usage
✓ "esbuild-jest2"
✗ "esbuild-jest"
The package name is `esbuild-jest2`, not `esbuild-jest`. In Jest transform config, use the string `"esbuild-jest2"` or a tuple with options.

Configures Jest to transform .ts/.tsx files using esbuild-jest2 with sourcemaps, target es2020, and custom JSX settings.

// jest.config.js module.exports = { transform: { '^.+\\.tsx?$': [ 'esbuild-jest2', { sourcemap: true, target: 'es2020', jsxFactory: 'h', jsxFragment: 'Fragment', loaders: { '.spec.ts': 'tsx' } } ] } }; // example.spec.ts test('esbuild transform', () => { const x: number = 1; expect(x + 1).toBe(2); });
Debug
Known issues
gotchaesbuild-jest2 does not perform type checking; test may pass despite TypeScript errors.
fix
Run a separate type-check step (e.g., `tsc --noEmit`) before or in parallel with tests.
affects: >=0.0.0
gotchaThe package name is 'esbuild-jest2', not 'esbuild-jest' - using wrong name will cause Jest to fail to find transformer.
fix
Use correct string 'esbuild-jest2' in Jest transform configuration.
affects: >=0.0.0
breakingPeer dependency esbuild >=0.20.1 required; older esbuild versions may cause runtime errors or missing APIs.
fix
Update esbuild to >=0.20.1: `npm install esbuild@latest`
affects: >=0.6.0
deprecatedThe original esbuild-jest package is abandoned; esbuild-jest2 is the actively maintained fork.
fix
Migrate from esbuild-jest to esbuild-jest2 by changing package name and requiring esbuild >=0.20.1.
affects: >=0.0.0
gotchaTypeScript type imports (Options) must use `import type` to avoid runtime errors.
fix
Use `import type { Options } from 'esbuild-jest2'`
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'esbuild-jest2' from 'transform.js'
Package not installed or incorrectly spelled in Jest config.
fix
Run `npm install --save-dev esbuild-jest2` and ensure Jest config uses 'esbuild-jest2' (not 'esbuild-jest').
TypeError: (0 , esbuild_jest2.createTransformer) is not a function
Using default import instead of named import for createTransformer.
fix
Change import to `import { createTransformer } from 'esbuild-jest2'` or `const { createTransformer } = require('esbuild-jest2')`.
Error: esbuild: Expected ";" but found "<"
JSX syntax encountered but esbuild loader not set correctly for .tsx or .jsx files.
fix
Set transform regex to include .tsx and .jsx (e.g., `'^.+\\.(ts|tsx|jsx)$'`) or ensure loader config includes 'tsx' for appropriate files.
Upgrade
Version history
0.6.7latest on npm
Audit
Dependencies
esbuildrequiredPeer dependency that must be installed separately; esbuild-jest2 calls esbuild's transform API
Agent activity
13 hits · last 30 days
node
12
Resources
esbuild-jest2 — npm install esbuild-jest2 · libregistry