Skip to main content
The Babel transform feature enables secure TSX/JSX transformation inside the enclave sandbox. This allows LLM-generated React components to be compiled to JavaScript safely, without exposing the host system to code execution risks.

Overview

Quick Start

Security Model

The Babel transform runs in an isolated VM context with multiple security layers:

Configuration

Security Levels

Each security level provides different limits for Babel transforms:

Creating a Babel Enclave

Transform API

Inside the enclave, the Babel global provides a restricted transform API:

Transform Options

The following Babel options are blocked for security:
  • plugins - Completely blocked (execute arbitrary code)
  • sourceMaps - Blocked (path leakage)
  • ast - Blocked (not needed, reduces attack surface)
  • babelrc / configFile - Blocked (no file system access)

Common Use Cases

Transform React Components

Transform TypeScript + JSX

Tool Integration for Dynamic Components

Error Handling

Babel transform errors are sanitized to prevent path leakage:

Common Errors

Performance

Babel transforms are optimized with context caching:
The Babel context is cached between transforms. The first transform (cold start) takes ~20-50ms, subsequent transforms are much faster.

Performance Tips

  1. Batch transforms - Transform multiple components in a single enclave run
  2. Reuse enclave - Don’t create/dispose for each transform
  3. Minimize types - Complex TypeScript types increase transform time
  4. Use STANDARD level - Good balance of security and performance

Direct API (Outside Enclave)

For server-side use without the full enclave sandbox, use createRestrictedBabel:
The direct API still runs Babel in an isolated VM context, but doesn’t provide the full enclave sandbox features (tool calls, iteration limits, etc.). Use the full enclave for LLM-generated code.