@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 17 apps in this directory
memos
Note Taking
Open-source, self-hosted note-taking built for quick capture — Markdown-native, lightweight, and fully yours.
Mistle
AI Agents · Developer Tools
Self-hostable platform for running autonomous coding agents in isolated, credentialless sandboxes with brokered credentials, reusable snapshots, and event-driven triggers.
OpenKnowledge
Code Editors · Knowledge Management · Note Taking
A beautiful, local-first markdown IDE that turns any git repo into a live collaborative workspace for humans and AI coding agents like Claude, Codex, and OpenCode.
Arize Phoenix
Analytics · Devops · Monitoring
Open-source AI observability platform for tracing, evaluating, and debugging LLM applications with built-in intelligence and MCP support.
Probo
Automation · Security
Open-source GRC platform for engineering and security teams.
rakazo
AI Agents · AI Assistants
An open-source platform for persistent AI teammates that own their own conversations, memory, routines, and computers — self-hosted, model-agnostic, and available on web, desktop, and mobile.
Sanity
CMS
Open-source headless CMS with a fully customizable React Studio, real-time collaborative editing, structured content modeling, and GROQ query language
Unleash
Ab Testing Experimentation · Developer Tools · Devops
The open-source feature management platform that lets you ship code to production and control who sees it — without redeploying.