kaba-babel-preset

raw JSON →
4.1.4 verified Sat Apr 25 auth: no javascript

A custom Babel preset for use with the Kaba build system, currently at v4.1.4. Provides legacy and modern environment configurations via `@babel/preset-env` and includes support for React, nullish coalescing, and numeric separators. Peer dependency on `core-js ^3.16.1`. Key differentiator: returns separate configs for legacy and modern browsers, allowing differential serving. Release cadence is irregular, with minor and patch updates as needed.

error Cannot find module 'core-js'
cause Missing peer dependency `core-js`.
fix
Install core-js: npm install core-js@^3.16.1
error TypeError: kabaBabelPreset is not a function
cause Incorrectly assuming the preset is a function; it's an object with properties `legacy` and `modern`.
fix
Use const { legacy, modern } = require('kaba-babel-preset');
error Error: Multiple presets/plugins with the same name
cause Duplicate application of kaba-babel-preset due to misconfiguration.
fix
Ensure the preset is only listed once in your Babel config.
breaking v4.0.0 changed from a single preset config to returning an object with `legacy` and `modern` presets.
fix Update usage to destructure the exported object: `const { legacy, modern } = require('kaba-babel-preset');`
breaking v3.0.0 switched from individual transforms to `@babel/preset-env`, which may alter polyfilling behavior.
fix Ensure `core-js` is installed as a peer dependency and configure `useBuiltIns` appropriately.
deprecated The `loose` mode warning in build output has been removed in v4.1.3, but older versions may produce warnings.
fix Upgrade to v4.1.3 or later to suppress the warning.
gotcha The preset expects `core-js` as a peer dependency; missing it will cause polyfill errors at runtime.
fix Run `npm install core-js@^3.16.1` or add it to your project's dependencies.
npm install kaba-babel-preset
yarn add kaba-babel-preset
pnpm add kaba-babel-preset

Shows how to use kaba-babel-preset in a Babel config, selecting legacy or modern preset based on an environment variable.

// babel.config.js
module.exports = function (api) {
  api.cache(true);
  const { legacy, modern } = require('kaba-babel-preset');
  // Example for differential serving based on browser targets
  const isModern = process.env.BROWSERS_ENV === 'modern';
  return isModern ? modern : legacy;
};