{"id":25292,"library":"esbuild-jest-cli","title":"esbuild-jest-cli","description":"A CLI tool that bundles Jest test projects using esbuild for faster test execution. Current stable version is 4.0.4 (March 2025), with irregular releases. It supports Jest 27-29 and Node.js 14+. Differentiating features: automatic Jest config generation, esbuild plugin support, and optional dependency transformation. It can handle ESM and CJS, and includes metafile generation to produce jest.config.json. The tool is maintained by Wix Incubator and is suitable for projects seeking lightweight, efficient test bundling.","status":"active","version":"4.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/wix-incubator/esbuild-jest-cli","tags":["javascript","typescript"],"install":[{"cmd":"npm install esbuild-jest-cli","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-jest-cli","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-jest-cli","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required as a peer dependency for bundling tests; must be >=0.17.4 per v4.x.","package":"esbuild","optional":false}],"imports":[{"note":"Package is ESM-first; CJS require may fail depending on Node version and configuration.","wrong":"const { build } = require('esbuild-jest-cli')","symbol":"build","correct":"import { build } from 'esbuild-jest-cli'"},{"note":"No default export exists (only named exports). The import will fail.","wrong":"const esbuildJestCli = require('esbuild-jest-cli')","symbol":"default","correct":"import esbuildJestCli from 'esbuild-jest-cli'"},{"note":"Type import only; not a runtime value.","wrong":"import { JestCliOptions } from 'esbuild-jest-cli'","symbol":"JestCliOptions","correct":"import type { JestCliOptions } from 'esbuild-jest-cli'"}],"quickstart":{"code":"// In your project root, create .esbuild-jestrc.js:\nmodule.exports = {\n  esbuild: {\n    outdir: '.bundle',\n    sourcemap: true,\n    platform: 'node'\n  },\n  package: {\n    name: 'my-test-bundle'\n  }\n};\n\n// Run the CLI:\n// npx esbuild-jest --testPathPattern=.*.test.js\n\n// Programmatic usage:\nimport { build } from 'esbuild-jest-cli';\nawait build({\n  esbuild: {\n    outdir: 'dist',\n    sourcemap: true,\n    external: ['chalk']\n  },\n  package: {\n    name: 'custom-bundle'\n  }\n});\nconsole.log('Tests bundled successfully!');","lang":"typescript","description":"Shows how to configure and run esbuild-jest-cli using a config file or programmatic API."},"warnings":[{"fix":"Migrate to new transformer mechanism; remove any usage of preTransform/postTransform. See changelog for v3->v4 migration.","message":"v4.0.0 switched to optional dependencies and @swc/jest internally; preTransform/postTransform callbacks from v3.x are removed.","severity":"breaking","affected_versions":">=4.0.0 <5.0.0"},{"fix":"Update custom transformers to match the new API. See release notes.","message":"v3.0.0 changed the transformer callback signatures (preTransform and postTransform).","severity":"breaking","affected_versions":">=3.0.0 <4.0.0"},{"fix":"Do not set bundle, splitting, metafile, or outbase in esbuild config — they are internally overridden.","message":"The tool forces bundle: true, splitting: true, metafile: true, and sets outbase to cwd. Overriding these can cause breakage.","severity":"gotcha","affected_versions":"*"},{"fix":"Upgrade Node.js to >=16.x.","message":"Support for Node.js 14.x is deprecated and may be removed in a future major version.","severity":"deprecated","affected_versions":"*"},{"fix":"Use dynamic import() or ensure your project is configured for ESM.","message":"The package is ESM-only; using require() directly may fail in older Node or CJS projects.","severity":"gotcha","affected_versions":">=4.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install --save-dev esbuild-jest-cli esbuild' and ensure node_modules is correct.","cause":"Package not installed, or missing peer dependency esbuild.","error":"Cannot find module 'esbuild-jest-cli'"},{"fix":"Change to dynamic import: const { build } = await import('esbuild-jest-cli'); or set type: module in package.json.","cause":"Using CommonJS require() on an ESM-only package.","error":"TypeError: (0 , _esbuildJestCli.build) is not a function"},{"fix":"Ensure Jest config uses esbuild-jest-cli's transformer or run via CLI with correct testPathPattern.","cause":"esbuild-jest-cli did not transform the file correctly, possibly due to misconfiguration.","error":"Jest encountered an unexpected token. Use babel-jest or ts-jest"},{"fix":"Install esbuild globally or set ESBUILD_BINARY_PATH to the esbuild binary location.","cause":"The internal esbuild binary path is missing (rare).","error":"Error: ESBUILD_BINARY_PATH environment variable is not set"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}