Skip to content

Commit 9037d5e

Browse files
justin808claude
andcommitted
Use SWC transpiler for all JavaScript and TypeScript
- Remove babel.config.js and all Babel transpilation dependencies - Configure shakapacker.yml to use javascript_transpiler: swc - Update swc.config.js with spec-compliant settings for Stimulus: - keepClassNames: true to preserve class names - loose: false for spec-compliant class transforms - externalHelpers: false to avoid binding issues - target: es2015 for broad compatibility - Move @swc/core and swc-loader to dependencies - Update Jest to use @swc/jest - Keep @babel/runtime for runtime helpers and @babel/eslint-parser for ESLint This is a pure SWC migration (not the hybrid Babel/SWC approach). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5a2fc17 commit 9037d5e

File tree

4 files changed

+21
-49
lines changed

4 files changed

+21
-49
lines changed

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']

config/swc.config.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,27 @@
44

55
module.exports = {
66
jsc: {
7+
parser: {
8+
syntax: "ecmascript",
9+
jsx: true,
10+
dynamicImport: true,
11+
decorators: false
12+
},
713
transform: {
814
react: {
915
runtime: "automatic"
1016
}
1117
},
12-
// Preserve ES6 classes for Stimulus compatibility
18+
// Critical for Stimulus: preserve class names and use spec-compliant transforms
1319
keepClassNames: true,
14-
// Disable loose mode to ensure proper class method binding for Stimulus
15-
loose: false
20+
// Use spec-compliant class transforms (not loose mode)
21+
loose: false,
22+
// Don't use external helpers to avoid any potential binding issues
23+
externalHelpers: false,
24+
target: "es2015"
25+
},
26+
// Preserve original semantics for class fields/methods
27+
module: {
28+
type: "es6"
1629
}
1730
};

package.json

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,8 @@
3131
"build:clean": "rm -rf public/packs || true"
3232
},
3333
"dependencies": {
34-
"@babel/plugin-transform-runtime": "^7.21.0",
35-
"@babel/preset-env": "^7.20.2",
36-
"@babel/preset-react": "^7.18.6",
3734
"@babel/runtime": "^7.17.9",
38-
"babel-loader": "^9.1.2",
39-
"babel-plugin-macros": "^3.1.0",
40-
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
35+
"@swc/core": "^1.3.100",
4136
"@glennsl/rescript-fetch": "^0.2.0",
4237
"@glennsl/rescript-json-combinators": "^1.2.1",
4338
"@hotwired/stimulus": "^3.2.1",
@@ -101,18 +96,15 @@
10196
"webpack": "5",
10297
"webpack-assets-manifest": "5",
10398
"webpack-cli": "5",
104-
"webpack-merge": "5"
99+
"webpack-merge": "5",
100+
"swc-loader": "^0.2.6"
105101
},
106102
"devDependencies": {
107-
"@babel/cli": "^7.21.0",
108-
"@babel/core": "^7.21.0",
109103
"@babel/eslint-parser": "^7.16.5",
110104
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
111-
"@swc/core": "^1.3.100",
112105
"@swc/jest": "^0.2.29",
113106
"@tailwindcss/typography": "^0.5.10",
114107
"@webpack-cli/serve": "^2.0.5",
115-
"babel-jest": "^29.5.0",
116108
"body-parser": "^1.20.2",
117109
"eslint": "^8.35.0",
118110
"eslint-config-prettier": "^8.6.0",
@@ -135,7 +127,6 @@
135127
"react-refresh": "^0.14.0",
136128
"react-transform-hmr": "^1.0.4",
137129
"regenerator-runtime": "^0.13.11",
138-
"swc-loader": "^0.2.3",
139130
"typescript": "^5.1.3",
140131
"webpack-dev-server": "^4.11.1"
141132
},
@@ -158,7 +149,7 @@
158149
],
159150
"testRegex": "./app/.*.spec\\.jsx?$",
160151
"transform": {
161-
"^.+\\.jsx?$": "babel-jest"
152+
"^.+\\.jsx?$": "@swc/jest"
162153
}
163154
},
164155
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"

0 commit comments

Comments
 (0)