@rolldown/plugin-babel
Official Babel transform plugin for Rolldown and Vite, with per-file preset filtering.
Repository Health
Technical Analysis
@rolldown/plugin-babel is the official Babel integration for Rolldown, the Rust-based bundler that powers Vite’s next-generation build pipeline. It runs Babel’s transform pass over .js, .jsx, .ts, and .tsx files, automatically wiring up the correct parser plugins so consumers don’t need to hand-configure Babel’s parser options for each file type.
Beyond a drop-in Babel-in-Rolldown bridge, the plugin adds a RolldownBabelPreset abstraction that lets a single Babel preset apply conditionally to a subset of files (by path, Rolldown module type, or file content) instead of running against every module. Those per-preset filters are compiled once and unioned into Rolldown’s native transform-hook filter, so files that no preset would touch never even reach the JavaScript transform callback. It also understands Vite’s multi-environment builds, supports both Babel 7 and Babel 8 through a type-safe compatibility layer, and can automatically wire in @babel/plugin-transform-runtime to deduplicate Babel’s helper functions across a project.
What You Get
- A Rolldown/Vite plugin that runs Babel transforms with automatic JSX/TS/TSX parser configuration
- Dual Babel 7 and Babel 8 compatibility via a type-safe compat layer, with no consumer-side branching required
- Per-preset conditional application via
defineRolldownBabelPreset, filtering by file path, Rolldown module type, or file content - Optional automatic
@babel/plugin-transform-runtimewiring for deduplicated Babel helper output - Vite-aware per-environment (
applyToEnvironmentHook) and resolved-config-aware (configResolvedHook) preset gating
Common Use Cases
- Adding a Babel plugin or preset (e.g. decorators, throw-expressions) to a Rolldown or Vite build that Rolldown doesn’t transform natively
- Applying different Babel presets to different file types or Vite environments (client vs SSR) in the same build
- Migrating an existing rollup-plugin-babel configuration to Rolldown
- Deduplicating Babel helper code across a large codebase via the
runtimeVersionoption
Under The Hood
Architecture
The plugin implements the Rolldown/Vite plugin lifecycle (config, configResolved, applyToEnvironment, outputOptions, transform) in index.ts, delegating option merging to options.ts (resolveOptions, createBabelOptionsConverter), transform-hook filter computation to filter.ts (calculateTransformFilter, which unions and intersects HookFilter dimensions — id, moduleType, code — across every registered RolldownBabelPreset), and Babel 7/8 type compatibility to babelCompat.ts. An envState map keyed by Vite environment name lets multi-environment builds carry distinct, pre-compiled Babel option converters computed once at configResolved/applyToEnvironment time and reused on every subsequent transform call, keeping the per-file hot path free of repeated filter recompilation.
Tech Stack
Written in TypeScript and published as ESM-only (type: module, single dist/index.mjs entry), built with tsdown and tested with Vitest as part of the rolldown/plugins pnpm monorepo, which shares Rolldown and Vite dev-dependency versions across packages via a pnpm catalog. The only runtime dependency is picomatch for glob-style path matching; @babel/core, @babel/plugin-transform-runtime, @babel/runtime, rolldown, and vite are all peer dependencies, with the Babel runtime helpers and Vite itself marked optional so the plugin stays usable in pure-Rolldown builds without Vite.
Code Quality
The package carries an extensive test suite relative to its size — over 1,700 lines across filter.test.ts, index.test.ts, and rolldownPreset.test.ts — exercising real Rolldown and Vite builds rather than mocking the bundler, including override merging, multi-dimension preset filtering, per-environment behavior, and Babel error propagation. The monorepo enforces oxlint --type-aware --type-check and oxfmt formatting repo-wide, plus CI workflows for linting, GitHub Actions security scanning (zizmor), and automated releases. Babel’s incompatible v7/v8 types are handled explicitly through conditional types rather than any-casting past the problem.
What Makes It Unique
The standout design choice is RolldownBabelPreset: instead of a preset applying unconditionally to every file, it carries its own filter (by path, Rolldown module type, or matched code) that the plugin compiles once and unions across all registered presets into Rolldown’s native transform-hook filter — meaning files no preset would touch skip the JS transform callback entirely, a genuine performance win specific to Rolldown’s filter-hook API rather than something bolted on afterward. Layered on top of that is Vite-specific environment and resolved-config gating for presets, and a from-scratch Babel 7/8 compatibility shim built on TypeScript conditional types so the same plugin code works against either major version’s API and type surface.
Used by 13 apps in this directory
Actual
Invoicing Finance
Local-first personal finance with envelope budgeting, end-to-end encryption, and multi-device sync — no subscription required.
Apache Airflow
Data Engineering
Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.
Anarlog
Note Taking · AI Assistants · Productivity
Anarlog is an open-source, local-first AI meeting notetaker that records, transcribes, and summarizes meetings entirely on your device — no cloud lock-in, no mandatory account, and every note saved as a plain markdown file you own forever.
ByteChef
Automation · AI Agents
Unified open-source platform for AI agent orchestration and workflow automation with 180+ connectors, MCP support, and durable execution.
Coder
Devops · Developer Tools · Code Editors
Self-hosted cloud development environments and AI coding agents — defined in Terraform, connected via WireGuard, automatically shut down when idle.
Gotify
Monitoring · Developer Tools
A lightweight, self-hosted push notification server that sends and receives messages in real time over WebSocket, with a sleek web UI and a native Go plugin system.
likec4
Developer Tools · Devops
Define your software architecture as code and get always up-to-date, interactive C4 diagrams generated automatically from a DSL.
Mastodon
Social Media
Run your own federated social network on the open ActivityPub standard with no ads, no algorithms, and no corporate control over your community.
memos
Note Taking
Open-source, self-hosted note-taking built for quick capture — Markdown-native, lightweight, and fully yours.