Registry / devops / esbuild-plugin-babel-cjs

esbuild-plugin-babel-cjs

JSON →
library1.0.0jsnpmunverified

A CommonJS-compatible Babel plugin for esbuild. Current stable version 1.0.0. This plugin allows you to apply Babel transformations within esbuild bundles when esbuild's native transform capabilities are insufficient. Unlike alternatives (e.g., esbuild-plugin-babel or @aspect-build/esbuild), this package explicitly targets CommonJS environments and provides a simple, minimal API. It requires @babel/core as a peer dependency and delegates Babel configuration to babel.config.json or inline config. Suitable for legacy projects or those locked into CJS.

devopsweb-framework
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

Package uses CommonJS default export; require directly returns the plugin function.

const babel = require('esbuild-plugin-babel-cjs');

Default import works because the module has a default export that resolves to the plugin function.

import babel from 'esbuild-plugin-babel-cjs';

Type imports are available for config interface. Named type import is correct.

import type { BabelPluginConfig } from 'esbuild-plugin-babel-cjs';

Minimal esbuild config that applies Babel transformations via the plugin. Ensure @babel/core is installed and Babel configuration is set separately.

const esbuild = require('esbuild'); const babel = require('esbuild-plugin-babel-cjs'); esbuild.build({ entryPoints: ['index.js'], bundle: true, outfile: 'main.js', plugins: [babel()], }).catch(() => process.exit(1));
Debug
Known footguns
gotchaPlugin does not apply any transforms by default: you must provide a Babel config via babel.config.json or the 'config' option. Without one, Babel runs as a no-op.
gotchaIf targeting es5, esbuild must also have target: ['es5'] set; otherwise esbuild will output modern syntax first and Babel may not produce valid es5.
deprecatedThe package README references esbuild-plugin-babel (without cjs) in the example code (line: const babel = require('esbuild-plugin-babel');). This is a copy-paste error; the correct package is esbuild-plugin-babel-cjs.
gotchaPlugin uses a synchronous transform under the hood; large files or complex Babel presets may cause performance issues or blocking in esbuild's async pipeline.
gotchaThe plugin namespace option defaults to an empty string, which may conflict with other plugins. Use a specific namespace like 'babel' to isolate.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
11 hits · last 30 days
claudebot
5
gptbot
3
ahrefsbot
3
Resources