babel-preset-cf

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

A Babel preset for Cloudflare Workers and Pages projects. Current stable version is 2.0.0. This preset configures Babel transforms optimized for the Cloudflare runtime environment, including compatibility with Cloudflare's specific JavaScript engine features and limitations. It simplifies setup by bundling necessary plugins and presets, reducing configuration overhead for Cloudflare-targeted JavaScript code. Released infrequently; relies on underlying Babel ecosystem.

error Cannot find module 'babel-preset-cf'
cause Package not installed or not in node_modules.
fix
Run 'npm install --save-dev babel-preset-cf' or ensure it's in dependencies.
error Unknown preset "cf" in .babelrc
cause Babel cannot resolve the preset by its short name.
fix
Use fully qualified name: 'babel-preset-cf' or ensure module is installed and Babel version is compatible.
gotcha The preset does not include polyfills for modern JS APIs; you may need @babel/polyfill or core-js separately.
fix Install and configure @babel/preset-env or add polyfills manually.
deprecated This preset may be incompatible with newer Babel versions (>=7.0.0).
fix Use '@babel/preset-env' with target 'cloudflare' or check for updated compatibility.
breaking Version 2.0.0 dropped support for Node.js <10.
fix Upgrade Node.js to version 10 or later.
npm install babel-preset-cf
yarn add babel-preset-cf
pnpm add babel-preset-cf

Install the preset and add it to your .babelrc file to enable Cloudflare-targeted Babel transforms.

// Install: npm install --save-dev babel-preset-cf
// .babelrc
{
  "presets": ["cf"]
}

// Then run babel on your files
// npx babel src --out-dir lib