Background
Shakapacker 9.0.0-beta.7+ makes SWC the default JavaScript transpiler instead of Babel. This tutorial currently uses Babel for transpilation.
Benefits of SWC
- Performance: SWC is significantly faster than Babel (10-20x for large codebases)
- Modern default: Aligns with Shakapacker 9.0 defaults
- Active development: SWC is actively maintained and optimized
- Lower memory footprint: Uses less memory during builds
Migration Plan
1. Configuration Changes
2. SWC Configuration
Create a .swcrc file with settings equivalent to current Babel config:
{
"jsc": {
"parser": {
"syntax": "ecmascript",
"jsx": true
},
"transform": {
"react": {
"runtime": "automatic",
"development": false,
"refresh": true
}
},
"target": "es2015"
},
"module": {
"type": "es6"
}
}
3. Testing
4. Documentation Updates
Potential Issues
- Babel macros: SWC doesn't support Babel macros - need to find alternatives or remove
- Custom Babel plugins: Any custom plugins will need SWC equivalents
- Jest configuration: May need to update Jest to work with SWC
- ESLint parser: May need to switch from
@babel/eslint-parser
References
Acceptance Criteria
- All builds pass (test, development, production)
- No Babel dependencies remain
- Build time is noticeably faster
- All existing functionality works identically
- Documentation is updated
cc: @justin808
Background
Shakapacker 9.0.0-beta.7+ makes SWC the default JavaScript transpiler instead of Babel. This tutorial currently uses Babel for transpilation.
Benefits of SWC
Migration Plan
1. Configuration Changes
package.json:@babel/cli@babel/core@babel/plugin-transform-runtime@babel/preset-env@babel/preset-react@babel/eslint-parserbabel-loaderbabel-jestbabel-plugin-macrosbabel-plugin-transform-react-remove-prop-typesshakapacker.ymlto setjavascript_transpiler: swc.swcrcconfiguration file with equivalent settings2. SWC Configuration
Create a
.swcrcfile with settings equivalent to current Babel config:{ "jsc": { "parser": { "syntax": "ecmascript", "jsx": true }, "transform": { "react": { "runtime": "automatic", "development": false, "refresh": true } }, "target": "es2015" }, "module": { "type": "es6" } }3. Testing
yarn build:testyarn build:dev4. Documentation Updates
Potential Issues
@babel/eslint-parserReferences
Acceptance Criteria
cc: @justin808