> ## Documentation Index
> Fetch the complete documentation index at: https://extension.js.org/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Extension.js needs Node.js 22.12 or newer; Node.js 18 and 20 do not work. It also runs on Deno 2.5+ and Bun 1.2+.
> The default browser target is chromium and a build lands in dist/<browser>, so dist/chromium by default. extension build writes a zip only when --zip is passed.
> Prefix a manifest key with a browser name when browsers differ. chromium: covers every Chromium-family target and Safari builds read it too. Since 4.1.19 chrome: means Chrome alone and edge: means Edge alone.
> Write one background.service_worker in manifest.json instead of hand-writing per-browser background keys; Extension.js converts it for each browser.
> package.json or deno.json marks the project root, not manifest.json. A config file is optional, and only extension.config.js, .mjs and .cjs are loaded, never .ts.
> The bundler is Rspack, extended through the config hook in extension.config.js. A project needs no separate bundler config file.
> Use --no-browser to skip the browser launch; --no-runner no longer exists and --no-open still launches the browser. Use --output for machine output; --format and --wait-format are deprecated.

# Babel integration for custom transforms

> Add Babel to an Extension.js project only when you need transforms SWC cannot cover. Keep SWC as the default and scope Babel to specific files.

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

| Capability | What it gives you |
| - | - |
| Targeted transforms | Run Babel for specific file types (for example, MDX) without replacing the full build pipeline |
| Plugin ecosystem access | Use Babel-only presets/plugins from existing web projects |
| Incremental migration | Move legacy Babel extension projects to Extension.js in smaller steps |
| Rspack (Extension.js bundler) integration | Configure Babel through `extension.config.*` `config` hook |

## Example setup

Install Babel dependencies:

```bash npm theme={null}
npm install -D @babel/core @babel/preset-env babel-loader
```

```bash pnpm theme={null}
pnpm add -D @babel/core @babel/preset-env babel-loader
```

```bash yarn theme={null}
yarn add -D @babel/core @babel/preset-env babel-loader
```

```bash bun theme={null}
bun add -d @babel/core @babel/preset-env babel-loader
```

```bash deno theme={null}
deno add -D npm:@babel/core npm:@babel/preset-env npm:babel-loader
```

Create `babel.config.json`:

```json theme={null}
{
  "presets": ["@babel/preset-env"]
}
```

Wire Babel into `extension.config.js` for MDX only:

```js theme={null}
export default {
  config: (config) => {
    config.module.rules.push({
      test: /\.mdx$/,
      use: ["babel-loader", "@mdx-js/loader"],
    });
    return config;
  },
};
```

## Replace SWC for JS/TS only if required

Use this pattern only when you need Babel to process JS/TS entry files directly:

```js theme={null}
export default {
  config: (config) => {
    config.module.rules = [
      {
        test: /\.[jt]sx?$/,
        exclude: /node_modules/,
        use: [{ loader: "babel-loader" }],
      },
      ...config.module.rules.filter(
        (rule) => !String(rule?.test || "").includes("[jt]sx"),
      ),
    ];
    return config;
  },
};
```

## Best practices

* Prefer targeted Babel usage before replacing the default JS/TS pipeline.
* Keep Babel rules explicit so loader ordering stays predictable.
* Reuse Babel only where migration or plugin compatibility requires it.

## Next steps

* Learn how to customize [Rspack configuration](https://extension.js.org/docs/features/rspack-configuration.md).
* Keep code quality high with [ESLint](https://extension.js.org/docs/integrations/eslint.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.