Esta página se muestra en inglés. Una traducción al español está en curso.
ConfigsMay 30, 2026·3 min de lectura

Sucrase — Super-Fast Alternative to Babel for Modern Runtimes

A lightweight JavaScript and TypeScript compiler that focuses on speed by only supporting transforms needed for modern runtimes, achieving 20x faster compilation than Babel.

Listo para agents

Instalación lista para agent

Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
Sucrase
Comando de instalación directa
npx -y tokrepo@latest install 557720ac-5c65-11f1-9bc6-00163e2b0d79 --target codex

Ejecutar después de confirmar el plan con dry-run.

Introduction

Sucrase is a JavaScript and TypeScript compiler built for speed. Unlike Babel, which supports every possible syntax transform, Sucrase focuses exclusively on transforms needed for modern environments — TypeScript, JSX, and module syntax — and does them extremely fast.

What Sucrase Does

  • Compiles TypeScript to JavaScript by stripping type annotations
  • Transforms JSX syntax into React.createElement or JSX runtime calls
  • Converts ES module import/export to CommonJS require/module.exports
  • Processes Flow type annotations by removing them from source
  • Operates as a CLI tool, Node.js register hook, or programmatic API

Architecture Overview

Sucrase works as a single-pass compiler. It tokenizes the source, identifies transform boundaries (type annotations, JSX tags, import statements), and generates output by copying source text and only modifying the relevant spans. This approach avoids building a full AST, which is why it is dramatically faster than Babel. The tradeoff is that it does not support every Babel plugin — only the most common transforms.

Self-Hosting & Configuration

  • Install via npm: npm install --save-dev sucrase
  • Run from the CLI: sucrase ./src -d ./dist --transforms typescript,jsx
  • Use as a Node.js register hook: node -r sucrase/register script.ts
  • Integrate with bundlers via @rollup/plugin-sucrase or esbuild (which uses a similar approach)
  • Available transforms: typescript, jsx, imports, flow, react-hot-loader

Key Features

  • Up to 20x faster than Babel for supported transforms
  • Single-pass architecture with no full AST construction
  • Supports TypeScript, JSX, ES modules, and Flow out of the box
  • Node.js register hook for running TypeScript files directly
  • Drop-in Babel replacement for projects that only need common transforms

Comparison with Similar Tools

  • Babel — full-featured compiler with plugin ecosystem; Sucrase is faster but supports fewer transforms
  • SWC — Rust-based compiler with broader transform support; Sucrase is pure JS and simpler to debug
  • esbuild — Go-based bundler and compiler; faster than Sucrase but primarily a bundler
  • tsc — official TypeScript compiler with type-checking; Sucrase only strips types without checking
  • tsx — Node.js loader for TypeScript; uses esbuild under the hood rather than Sucrase

FAQ

Q: Can Sucrase replace Babel in my project? A: If you only need TypeScript, JSX, and module transforms, yes. If you rely on advanced Babel plugins, no.

Q: Does Sucrase type-check TypeScript? A: No. It strips types without checking them. Run tsc separately for type-checking.

Q: How does the speed compare? A: Sucrase is typically 4-20x faster than Babel depending on the transform set and file size.

Q: Is it production-ready? A: Yes. It is used in production by tools like Vitest, Bun, and various build pipelines.

Sources

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados