Lesson 25 / 30

Migrating from Babel to SWC

Step-by-step guide to switch from Babel to SWC.

Assessment: is your project ready?

Check if your Babel plugins are available in SWC. If you use only common transforms (JSX, TypeScript, class properties), migration is straightforward. If you use exotic plugins, stay with Babel.

Step 1: Uninstall Babel, install SWC

Remove Babel packages and add SWC. Test that the build still works.

npm uninstall @babel/core @babel/cli @babel/preset-env @babel/preset-react
npm install --save-dev @swc/core @swc/cli

Step 2: Replace .babelrc with .swcrc

Convert your Babel config to SWC format. Most settings map directly.

# Keep .babelrc for reference, create .swcrc
cp .babelrc .babelrc.backup
# Edit new .swcrc with equivalent SWC settings