Skip to content

Commit e3a65aa

Browse files
committed
Migrate from Babel to SWC transpiler
- Updated shakapacker.yml to use SWC transpiler - Created .swcrc with configuration (without jsc.target to avoid conflict with Shakapacker's env config) - Removed Babel configuration and most Babel dependencies - Added SWC dependencies (@swc/core, @swc/jest, swc-loader) - Kept @babel/core, @babel/eslint-parser, and @babel/preset-react for ESLint (used by eslint-config-shakacode) - Configured ESLint parser with requireConfigFile: false to work without babel.config.js - Kept @babel/runtime for polyfills - Updated Jest to use @swc/jest instead of babel-jest
1 parent 104f07a commit e3a65aa

File tree

6 files changed

+199
-947
lines changed

6 files changed

+199
-947
lines changed

.eslintrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ extends:
55
- plugin:jsx-a11y/recommended
66
- prettier
77

8+
parserOptions:
9+
requireConfigFile: false
10+
babelOptions:
11+
presets:
12+
- "@babel/preset-react"
13+
814
plugins:
915
- react
1016
- jsx-a11y

.swcrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"jsc": {
3+
"parser": {
4+
"syntax": "ecmascript",
5+
"jsx": true,
6+
"dynamicImport": true
7+
},
8+
"transform": {
9+
"react": {
10+
"runtime": "automatic"
11+
}
12+
}
13+
},
14+
"module": {
15+
"type": "es6"
16+
}
17+
}

babel.config.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

config/shakapacker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ default: &default
88
cache_path: tmp/shakapacker
99
webpack_compile_output: true
1010
nested_entries: true
11-
javascript_transpiler: babel
11+
javascript_transpiler: swc
1212

1313
# Additional paths webpack should lookup modules
1414
# ['app/assets', 'engine/foo/app/assets']

package.json

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@
3131
"build:clean": "rm -rf public/packs || true"
3232
},
3333
"dependencies": {
34-
"@babel/cli": "^7.21.0",
35-
"@babel/core": "^7.21.0",
36-
"@babel/plugin-transform-runtime": "^7.21.0",
37-
"@babel/preset-env": "^7.20.2",
38-
"@babel/preset-react": "^7.18.6",
3934
"@babel/runtime": "^7.17.9",
4035
"@glennsl/rescript-fetch": "^0.2.0",
4136
"@glennsl/rescript-json-combinators": "^1.2.1",
@@ -47,9 +42,6 @@
4742
"@rescript/react": "^0.11.0",
4843
"autoprefixer": "^10.4.14",
4944
"axios": "^0.21.1",
50-
"babel-loader": "^9.1.2",
51-
"babel-plugin-macros": "^3.1.0",
52-
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
5345
"classnames": "^2.3.2",
5446
"compression-webpack-plugin": "10.0.0",
5547
"css-loader": "^6.7.3",
@@ -106,11 +98,15 @@
10698
"webpack-merge": "5"
10799
},
108100
"devDependencies": {
101+
"@babel/core": "^7.20.0",
109102
"@babel/eslint-parser": "^7.16.5",
103+
"@babel/preset-react": "^7.18.6",
110104
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
105+
"@swc/core": "^1.3.100",
106+
"@swc/jest": "^0.2.29",
111107
"@tailwindcss/typography": "^0.5.10",
108+
"swc-loader": "^0.2.3",
112109
"@webpack-cli/serve": "^2.0.5",
113-
"babel-jest": "^29.5.0",
114110
"body-parser": "^1.20.2",
115111
"eslint": "^8.35.0",
116112
"eslint-config-prettier": "^8.6.0",
@@ -155,7 +151,7 @@
155151
],
156152
"testRegex": "./app/.*.spec\\.jsx?$",
157153
"transform": {
158-
"^.+\\.jsx?$": "babel-jest"
154+
"^.+\\.jsx?$": "@swc/jest"
159155
}
160156
},
161157
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"

0 commit comments

Comments
 (0)