or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-babel-plugin-transform-async-functions

Babel plugin that compiles async functions to ES5 for backward compatibility

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/babel-plugin-transform-async-functions@6.22.x

To install, run

npx @tessl/cli install tessl/npm-babel-plugin-transform-async-functions@6.22.0

index.mddocs/

Babel Plugin Transform Async Functions

⚠️ 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.

Package Information

  • Package Name: babel-plugin-transform-async-functions
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install --save-dev babel-plugin-transform-async-functions

Core Imports

This plugin is not imported directly into application code. It is configured as part of a Babel build pipeline.

Basic Usage

⚠️ WARNING: The following configurations will only enable async syntax parsing - no transformations will occur.

Via .babelrc (Syntax Parsing Only)

{
  "plugins": ["transform-async-functions"]
}

Via CLI (Syntax Parsing Only)

babel --plugins transform-async-functions script.js

Via Node API (Syntax Parsing Only)

require("babel-core").transform("code", {
  plugins: ["transform-async-functions"]
});

For Actual Transformation (Recommended)

{
  "plugins": ["transform-async-to-generator"]
}

Architecture

⚠️ 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:

  • Plugin Factory: Main export function that returns Babel plugin configuration
  • Inheritance Pattern: Only extends babel-plugin-syntax-async-functions for syntax parsing
  • Parser Integration: Adds async function syntax support to Babel's parser (not transformer)

Historical 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.

Capabilities

Plugin Factory Function

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

Types

/**
 * 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;
}

Integration Notes

⚠️ CRITICAL: This plugin does NOT transform code - it only enables syntax parsing.

  • This plugin must be used as part of a Babel build process
  • It does NOT transform async/await syntax - it only allows Babel to parse it without errors
  • The plugin inherits only syntax parsing functionality from babel-plugin-syntax-async-functions
  • No transformations occur during compilation with this plugin alone
  • Requires babel-core to be installed and configured for the build process

For Actual Async Function Transformation:

To 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.

Dependencies

  • babel-plugin-syntax-async-functions: ^6.8.0 - Provides async function syntax parsing
  • babel-runtime: ^6.22.0 - Babel runtime helpers (not used by this plugin since no transformation occurs)