babel-plugin-fast-async
raw JSON → 6.1.2 verified Sat Apr 25 auth: no javascript
A Babel v6 plugin that transforms ES7 async/await syntax using fast synchronous transformation instead of generators/regenerator, achieving 3-4x performance improvements in browsers and Node, and up to 10x on mobile. Currently at v6.2.1, it uses the nodent library for compilation and supports options like Promise-based output, generator fallback, and runtime module imports. Requires nodent runtime unless using 'spec' mode with noRuntime. Released under MIT.
Common errors
error Module not found: Can't resolve 'nodent' ↓
cause nodent is a peer dependency but not installed.
fix
Run 'npm install nodent --save' alongside fast-async.
error SyntaxError: Unexpected token function ↓
cause Babel v7+ does not support fast-async; use built-in plugins.
fix
Use @babel/plugin-transform-async-to-generator instead of fast-async.
error TypeError: Cannot assign to read only property 'exports' of object '#<Object>' ↓
cause Mixing ESM and CJS in compiled code; runtime conflict.
fix
Ensure consistent module system; set Babel sourceType appropriately.
Warnings
breaking Babel v6 only; does not support Babel v7+. ↓
fix Upgrade to Babel v7 and use @babel/plugin-transform-async-to-generator or similar.
gotcha Runtime must be included manually for multi-file projects. Set runtimePattern for single include. ↓
fix Set 'runtimePattern' option to a regex matching one file, or use 'useRuntimeModule' for import.
gotcha Stack trace mapping disabled by default (dontMapStackTraces: true) as of v6.1.x. ↓
fix Set 'dontMapStackTraces: false' in env options if you need mapped stack traces.
Install
npm install babel-plugin-fast-async yarn add babel-plugin-fast-async pnpm add babel-plugin-fast-async Imports
- plugin wrong
import fastAsync from 'fast-async'correct// .babelrc { "plugins": ["fast-async"] } - default wrong
const fastAsync = require('fast-async')correct// No JavaScript import required; plugin applied via Babel config - PluginFactory wrong
import { fastAsync } from 'fast-async'correct// Programmatic Babel usage: const fastAsync = require('fast-async'); babel.transform(code, { plugins: [fastAsync] });
Quickstart
{
"plugins": ["fast-async"]
}