babel-preset-async-to-bluebird
raw JSON → 1.1.0 verified Sat Apr 25 auth: no javascript maintenance
A Babel preset that transforms async functions into Bluebird coroutines using .coroutine(). It is a specialized preset for projects already using Bluebird, providing an alternative to the default regenerator-based async-to-generator transform. This package is in maintenance mode with no recent updates; the current version is 1.1.0 and it works with Babel 6.
Common errors
error Error: Cannot find module 'babel-preset-async-to-bluebird' ↓
cause Package not installed or not in node_modules.
fix
npm install --save-dev babel-preset-async-to-bluebird
error ReferenceError: regeneratorRuntime is not defined ↓
cause Using async-to-bluebird without having installed or configured Bluebird.
fix
npm install bluebird and ensure it is available at runtime (e.g., require('bluebird')).
error TypeError: (0 , _asyncToBluebird) is not a function ↓
cause Misconfigured Babel preset; likely using an outdated Babel version or incorrect preset reference.
fix
Check Babel version (should be 6) and ensure presets are listed correctly in .babelrc.
Warnings
deprecated Babel 6 is end-of-life. This preset does not support Babel 7+ (unless using @babel/plugin-transform-async-to-generator with regenerator). ↓
fix Upgrade to Babel 7 and use @babel/plugin-transform-async-to-generator or keep Babel 6 if legacy.
breaking Bluebird must be installed separately as a peer dependency (v3+). If Bluebird is missing, async functions will not be transformed correctly. ↓
fix npm install bluebird
gotcha This preset replaces native async/await with Bluebird coroutines. If you later remove Bluebird, async functions will break. ↓
fix Only use this preset if you are committed to Bluebird as a dependency.
gotcha The preset does not include any environment-specific transformations (e.g., polyfills for fetch). You need additional presets like babel-preset-env. ↓
fix Add babel-preset-env to your presets array before async-to-bluebird.
Install
npm install babel-preset-async-to-bluebird yarn add babel-preset-async-to-bluebird pnpm add babel-preset-async-to-bluebird Imports
- async-to-bluebird preset wrong
In .babelrc: "presets": ["babel-preset-async-to-bluebird"]correctIn .babelrc: "presets": ["async-to-bluebird"] - require in Node API wrong
require('babel-preset-async-to-bluebird').transform(...)correctrequire('babel-core').transform('code', { presets: ['async-to-bluebird'] }) - require in Node API (explicit)
const preset = require('babel-preset-async-to-bluebird'); require('babel-core').transform('code', { presets: [preset] })
Quickstart
// .babelrc
{
"presets": ["async-to-bluebird"]
}
// install
// npm install --save-dev babel-preset-async-to-bluebird babel-preset-env
// src.js
async function fetchData() {
const res = await fetch('https://api.example.com/data');
return res.json();
}
// Run: npx babel src.js --out-file compiled.js