babel-preset-jaid
raw JSON → 17.0.0 verified Sat Apr 25 auth: no javascript
A personal Babel preset collection by Jaid that aims to minimize boilerplate for JavaScript projects. Current stable version is v17.0.0, released in 2022. The preset includes curated plugins for modern JavaScript, React, and optional minification. Key differentiators: pure ESM exports since v17, custom options for React (false/true/"lib"/"dom"/"dom-lib"), and built-in path aliases. It differs from other presets like @babel/preset-env by bundling multiple plugins into a single config, reducing setup overhead. Maintenance is sporadic, with breaking changes across major versions.
Common errors
error Error: Cannot find module 'babel-preset-jaid' ↓
cause Package not installed or incorrect path.
fix
Run npm install --save-dev babel-preset-jaid@^17.0.0
error Error [ERR_REQUIRE_ESM]: require() of ES Module ↓
cause Using CommonJS require() with ESM-only package (v17+).
fix
Use import syntax or use require('babel-preset-jaid').default in CommonJS.
error Error: preset-jaid: Unknown option 'react' with value 'string' ↓
cause V13+ changed react option to accept only specific string values.
fix
Set react option to one of: false, true, 'lib', 'dom', 'dom-lib'.
Warnings
breaking v17.0.0: Enabled ESM by default. The package now only exports ESM; CommonJS require() breaks. ↓
fix Switch to import syntax or update to latest version. For .babelrc.js, use module.exports = require('babel-preset-jaid').default.
breaking v13.0.0: Option 'react' must now be false, true, "lib", "dom", or "dom-lib". Boolean true/false no longer sufficient. ↓
fix Update react option to one of the allowed string values or boolean.
breaking v12.0.0: Removed support for ava and flow. Plugins for these are no longer included. ↓
fix If you need ava or flow support, pin to v11 or add the plugins manually.
breaking v14.0.0: Temporarily disabled reading Jest config; path aliases are now static (root, src, lib). ↓
fix Configure path aliases manually in your project if needed.
deprecated v13.1.0: Switched from react-hot-loader/babel to react-refresh/babel. The old plugin is deprecated. ↓
fix If using react-hot-loader, migrate to react-refresh. The preset now uses react-refresh/babel.
gotcha The preset uses dynamic requires internally; may cause issues with bundlers that don't support CommonJS in dependencies. ↓
fix Update to v17 which is ESM-only, or configure your bundler to handle CommonJS.
Install
npm install babel-preset-jaid yarn add babel-preset-jaid pnpm add babel-preset-jaid Imports
- default wrong
const preset = require('babel-preset-jaid')correctimport preset from 'babel-preset-jaid' - PluginConfig wrong
import { PluginConfig } from 'babel-preset-jaid'correctimport type { PluginConfig } from 'babel-preset-jaid' - default (in .babelrc.js) wrong
module.exports = require('babel-preset-jaid')correctmodule.exports = require('babel-preset-jaid').default
Quickstart
// Install: npm install --save-dev babel-preset-jaid
// .babelrc
{
"presets": [
["babel-preset-jaid", {
"react": true,
"minify": false,
"target": "node"
}]
]
}
// Or programmatically (ESM):
import preset from 'babel-preset-jaid';
const options = { react: true, minify: false, target: 'node' };
const config = preset({}, options);
console.log('Configured Babel with preset', Object.keys(config));