babel-preset-kyt-core

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

An opinionated Babel preset optimized for kyt, the NYTimes' universal JavaScript toolchain. Current version 2.0.1, released November 2023. It provides a curated set of Babel plugins and presets for modern JavaScript and React, including @babel/preset-env, @babel/preset-react, and @babel/preset-typescript, with automatic polyfill injection via core-js. Unlike generic presets, it is tuned for kyt's isomorphic architecture, supporting both client and server builds. It follows a semver release cadence alongside kyt packages, with maintenance as active.

error Error: Cannot find module 'babel-preset-kyt-core'
cause The package is not installed or not in node_modules.
fix
Install the preset: npm install babel-preset-kyt-core --save-dev
error ReferenceError: regeneratorRuntime is not defined
cause Missing regenerator-runtime when using async/await or generators.
fix
Install regenerator-runtime: npm install regenerator-runtime and add import 'regenerator-runtime/runtime' at entry.
error Error: Plugin/Preset files are not allowed to export objects, only functions.
cause Babel config tries to import the preset as ESM but it is CJS.
fix
Use require() in Babel config: module.exports = { presets: [require('babel-preset-kyt-core')] };
gotcha Preset is CJS-only; cannot be imported as ESM in Babel config with 'import' syntax.
fix Use require() in .babelrc.js or babel.config.js: module.exports = { presets: [require('babel-preset-kyt-core')] };
deprecated Polyfill via @babel/polyfill is deprecated in favor of core-js and regenerator-runtime.
fix The preset uses core-js automatically; ensure core-js is installed.
gotcha Preset includes @babel/plugin-transform-runtime which can cause issues with instance methods if not configured properly.
fix If using '@babel/runtime' with helpers, ensure '@babel/runtime' is installed as a dependency.
breaking Version 2.0.0 removed support for Node.js versions < 12.
fix Use Node.js >= 12.
gotcha The preset sets 'useBuiltIns: usage' but does not automatically install core-js. Missing core-js causes runtime errors.
fix Install core-js: npm install core-js
deprecated The preset implicitly enables @babel/plugin-proposal-class-properties (legacy) – stage 4 proposals are now in @babel/preset-env.
fix No action needed in v2, but consider migrating to latest @babel/preset-env.
gotcha If using TypeScript, the preset expects @babel/preset-typescript to be installed; not included transitively.
fix Install @babel/preset-typescript as a devDependency.
npm install babel-preset-kyt-core
yarn add babel-preset-kyt-core
pnpm add babel-preset-kyt-core

Shows how to add the preset to a Babel configuration, with no additional options required.

// .babelrc
{
  "presets": [
    "babel-preset-kyt-core"
  ]
}

// or in package.json:
"babel": {
  "presets": ["babel-preset-kyt-core"]
}