{"id":19468,"library":"esbuild-plugin-babel-cached","title":"esbuild-plugin-babel-cached","description":"esbuild-plugin-babel-cached (v0.2.3) is an esbuild plugin that runs files through Babel for transforms not supported natively by esbuild, with built-in caching. It wraps @babel/core and allows configuration via babel.config.json or inline options. Unlike other esbuild Babel plugins, it caches results to speed up rebuilds. The plugin is stable with weekly releases and is intended for scenarios where esbuild's own transforms (e.g., newer JavaScript/TypeScript) are insufficient and you need Babel for specific presets or plugins (e.g., for legacy browser support or custom transforms). It depends on @babel/core as a peer dependency and is ESM-only.","status":"active","version":"0.2.3","language":"javascript","source_language":"en","source_url":"https://github.com/nativew/esbuild-plugin-babel","tags":["javascript","babel","esbuild","esbuild-plugin"],"install":[{"cmd":"npm install esbuild-plugin-babel-cached","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-babel-cached","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-babel-cached","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required to run Babel transforms","package":"@babel/core","optional":false}],"imports":[{"note":"ESM-only package; CommonJS require() will fail.","wrong":"const babel = require('esbuild-plugin-babel-cached')","symbol":"babel","correct":"import babel from 'esbuild-plugin-babel-cached'"},{"note":"Default export only; named export does not exist.","wrong":"import { babel } from 'esbuild-plugin-babel-cached'","symbol":"babel","correct":"import babel from 'esbuild-plugin-babel-cached'"},{"note":"TypeScript types are not shipped; you may need to define your own type or use @types/esbuild.","symbol":"plugin type (TypeScript)","correct":"import type { Plugin } from 'esbuild'; import babel from 'esbuild-plugin-babel-cached'; const plugin: Plugin = babel();"}],"quickstart":{"code":"import esbuild from 'esbuild';\nimport babel from 'esbuild-plugin-babel-cached';\n\nawait esbuild.build({\n  entryPoints: ['src/index.ts'],\n  bundle: true,\n  outfile: 'dist/bundle.js',\n  plugins: [babel({\n    filter: /\\.(js|ts)$/,\n    config: {\n      presets: ['@babel/preset-env'],\n      plugins: ['@babel/plugin-transform-arrow-functions']\n    }\n  })],\n  target: ['es5']\n});","lang":"typescript","description":"Minimal esbuild build with Babel caching plugin and custom Babel config."},"warnings":[{"fix":"Use ES module imports (import babel from ...) and set \"type\": \"module\" in package.json or use .mjs extension.","message":"The plugin is ESM-only and cannot be loaded via require().","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"If using babel.config.json, ensure it is in the project root or set rootMode: 'upward' in config.","message":"The `config` option accepts Babel configuration; placing options in babel.config.json is also supported, but inline config takes precedence.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Set esbuild target to the desired output (e.g., 'es5') to let esbuild handle what it can, and use Babel for additional transforms that esbuild doesn't support.","message":"If you target es5 with esbuild's own target option, Babel may not transform output if esbuild already handles it; ensure the Babel plugin runs before esbuild's internal transforms.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Set process.env.CACHE_DIR to a temporary directory or disable caching by passing cache: false to babel() options.","message":"Caching may cause stale results if Babel config changes; clear cache by deleting node_modules/.cache/esbuild-plugin-babel-cached or setting CACHE_DIR environment variable.","severity":"gotcha","affected_versions":">=0.2.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Convert config file to ES module: rename to .mjs or add \"type\": \"module\" in package.json. Then use: import babel from 'esbuild-plugin-babel-cached'","cause":"Using CommonJS require() with an ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/esbuild-plugin-babel-cached/index.js from /path/to/project/esbuild.config.js not supported."},{"fix":"Use: import babel from 'esbuild-plugin-babel-cached' (no curly braces)","cause":"Named import instead of default import.","error":"TypeError: (0 , _default) is not a function"},{"fix":"Install: npm install @babel/core -D","cause":"Missing peer dependency @babel/core.","error":"Error: Cannot find module '@babel/core'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}