Babel plugin that compiles async functions to ES5 for backward compatibility
npx @tessl/cli install tessl/npm-babel-plugin-transform-async-functions@6.22.0⚠️ IMPORTANT: This plugin only enables async function syntax parsing and does NOT perform any transformations. Despite its name and description claiming to "compile async functions to ES5", this plugin is essentially incomplete and only provides syntax support.
Babel Plugin Transform Async Functions is a minimal Babel plugin that enables parsing of async function syntax. It does not transform or compile async functions - it only allows Babel to parse the syntax without throwing errors. For actual async function transformation, you should use babel-plugin-transform-async-to-generator instead.
npm install --save-dev babel-plugin-transform-async-functionsThis plugin is not imported directly into application code. It is configured as part of a Babel build pipeline.
⚠️ WARNING: The following configurations will only enable async syntax parsing - no transformations will occur.
{
"plugins": ["transform-async-functions"]
}babel --plugins transform-async-functions script.jsrequire("babel-core").transform("code", {
plugins: ["transform-async-functions"]
});{
"plugins": ["transform-async-to-generator"]
}⚠️ This plugin performs NO transformations - it only enables syntax parsing.
This plugin works by inheriting from babel-plugin-syntax-async-functions, which adds the "asyncFunctions" parser plugin to Babel. This allows Babel to parse async function syntax without throwing syntax errors, but no code transformation occurs.
Key architectural components:
babel-plugin-syntax-async-functions for syntax parsingHistorical Context: This plugin appears to be an incomplete implementation from the Babel 6.0.0 era. It was intended to provide async function transformation but was never finished. The actual transformation functionality exists in babel-plugin-transform-async-to-generator.
The main export provides a Babel plugin factory that returns the plugin configuration for enabling async function syntax parsing (NOT transformation).
/**
* Creates a Babel plugin configuration for enabling async function syntax parsing
* ⚠️ WARNING: This does NOT transform async functions - only enables parsing
* @returns {Object} Babel plugin configuration object
*/
export default function(): BabelPluginConfig;
interface BabelPluginConfig {
/** Inherits functionality from babel-plugin-syntax-async-functions */
inherits: any;
}Usage Example:
// This is how Babel uses the plugin internally
const plugin = require("babel-plugin-transform-async-functions");
const pluginConfig = plugin();
// pluginConfig.inherits contains babel-plugin-syntax-async-functions
// This will only enable parsing - NO transformation occurs/**
* Babel plugin configuration object returned by the factory function
* ⚠️ WARNING: This configuration only provides syntax parsing, not transformation
*/
interface BabelPluginConfig {
/** Reference to babel-plugin-syntax-async-functions for async syntax parsing only */
inherits: any;
}⚠️ CRITICAL: This plugin does NOT transform code - it only enables syntax parsing.
babel-plugin-syntax-async-functionsbabel-core to be installed and configured for the build processTo actually transform async functions to ES5-compatible code, use:
{
"plugins": ["transform-async-to-generator"]
}Or include it as part of a preset like babel-preset-es2017 or babel-preset-env.