Registry / web-framework / esbuild-plugin-babel-cached

esbuild-plugin-babel-cached

JSON →
library0.2.3jsnpmunverified

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-cached
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-BAB
E
esbuild-plugin-babel-cached
web-frameworkjavascriptv0.2.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

babel
import babel from 'esbuild-plugin-babel-cached'
const babel = require('esbuild-plugin-babel-cached')
ESM-only package; CommonJS require() will fail.
babel
import babel from 'esbuild-plugin-babel-cached'
import { babel } from 'esbuild-plugin-babel-cached'
Default export only; named export does not exist.
plugin type (TypeScript)
import type { Plugin } from 'esbuild'; import babel from 'esbuild-plugin-babel-cached'; const plugin: Plugin = babel();
TypeScript types are not shipped; you may need to define your own type or use @types/esbuild.

Minimal esbuild build with Babel caching plugin and custom Babel config.

import esbuild from 'esbuild'; import babel from 'esbuild-plugin-babel-cached'; await esbuild.build({ entryPoints: ['src/index.ts'], bundle: true, outfile: 'dist/bundle.js', plugins: [babel({ filter: /\.(js|ts)$/, config: { presets: ['@babel/preset-env'], plugins: ['@babel/plugin-transform-arrow-functions'] } })], target: ['es5'] });
Debug
Known issues
breakingThe plugin is ESM-only and cannot be loaded via require().
fix
Use ES module imports (import babel from ...) and set "type": "module" in package.json or use .mjs extension.
affects: >=0.2.0
deprecatedThe `config` option accepts Babel configuration; placing options in babel.config.json is also supported, but inline config takes precedence.
fix
If using babel.config.json, ensure it is in the project root or set rootMode: 'upward' in config.
affects: >=0.1.0
gotchaIf 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.
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.
affects: >=0.1.0
gotchaCaching 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.
fix
Set process.env.CACHE_DIR to a temporary directory or disable caching by passing cache: false to babel() options.
affects: >=0.2.0
Errors
Common errors & fixes
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.
Using CommonJS require() with an ESM-only package.
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'
TypeError: (0 , _default) is not a function
Named import instead of default import.
fix
Use: import babel from 'esbuild-plugin-babel-cached' (no curly braces)
Error: Cannot find module '@babel/core'
Missing peer dependency @babel/core.
fix
Install: npm install @babel/core -D
Upgrade
Version history
0.2.3latest on npm
Audit
Dependencies
@babel/corerequiredPeer dependency required to run Babel transforms
Agent activity
2 hits · last 30 days
node
2
Resources
esbuild-plugin-babel-cached — npm install esbuild-plugin-babel-cached · libregistry