Skip to main content
Add Babel only when you need transforms or plugins that SWC (Speedy Web Compiler) does not cover. Keep SWC as the default pipeline, then scope Babel to the files that need it.

When Babel is a good fit

  • You depend on Babel-only plugins or presets.
  • You are migrating an existing Babel-heavy project incrementally.
  • You want targeted transforms for specific file types (for example, MDX).

Babel capabilities

Example setup

Install Babel dependencies:
Create babel.config.json:
Wire Babel into extension.config.js for MDX only:

Your Babel config runs before SWC

From the release after 4.2.0, a Babel config in the project folder runs without any rule from you. Extension.js finds babel.config.*, .babelrc, .babelrc.*, or a babel key in package.json, and runs Babel first on every project script, never on node_modules. SWC then compiles what Babel returns, so TypeScript, JSX, browser targets, and React Refresh stay SWC’s work. Your config needs no TypeScript or JSX preset, because Extension.js gives Babel the syntax plugins it needs to read those files. Extension.js ships babel-loader and @babel/core for this. A project without a Babel config never loads Babel for its scripts.
babel.config.json
So the babel.config.json from the setup above also runs on every script in the project. Releases up to 4.2.0 ran Babel only through a rule that you added. Babel cannot replace SWC. A rule in config adds a loader and cannot take one away, so SWC still compiles your scripts after Babel. See Loader order.

Best practices

  • Keep the Babel config to the plugins that SWC lacks, because it runs on every project script.
  • Keep Babel rules explicit so loader ordering stays predictable.
  • Reuse Babel only where migration or plugin compatibility requires it.

Next steps