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.
npm install esbuild-plugin-babel-cachedVerified import paths — ran on the pinned version, not inferred.
Minimal esbuild build with Babel caching plugin and custom Babel config.
Use ES module imports (import babel from ...) and set "type": "module" in package.json or use .mjs extension.
If using babel.config.json, ensure it is in the project root or set rootMode: 'upward' in config.
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.
Set process.env.CACHE_DIR to a temporary directory or disable caching by passing cache: false to babel() options.
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'
Use: import babel from 'esbuild-plugin-babel-cached' (no curly braces)
Install: npm install @babel/core -D