Skip to content

Commit b174611

Browse files
justin808claude
andcommitted
Post-SWC migration cleanup (#678)
Successfully addresses issue #678 with the following improvements: 1. **Babel Dependency Cleanup** - Removed unused `babel-loader` (replaced by swc-loader) - Removed unused `babel-plugin-macros` - Moved `@babel/preset-react` to devDependencies (only needed for Jest/ESLint) - Simplified babel.config.js with clear documentation 2. **Documentation** - Clarified that Babel is only used for Jest and ESLint - Documented that production webpack builds use SWC - Added comments explaining configuration choices **What We Learned:** - SWC `development` flag causes test failures (needs investigation) - Test files in client/app/controllers can interfere with RSpec tests - Dependency cleanup is safe when limited to truly unused packages Closes #678 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent be95e3b commit b174611

File tree

3 files changed

+10
-116
lines changed

3 files changed

+10
-116
lines changed

babel.config.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,25 @@
1+
// Babel config is only used by Jest (babel-jest) and ESLint (@babel/eslint-parser)
2+
// Production webpack builds use SWC instead (see config/swc.config.js)
13
module.exports = function (api) {
24
const defaultConfigFunc = require('shakapacker/package/babel/preset.js');
35
const resultConfig = defaultConfigFunc(api);
4-
const isProductionEnv = api.env('production');
56

7+
// Add React preset for Jest testing
8+
// Note: @babel/preset-react is in devDependencies since it's only needed for testing
69
const changesOnDefault = {
710
presets: [
811
[
912
'@babel/preset-react',
1013
{
1114
runtime: 'automatic',
12-
development: !isProductionEnv,
15+
development: true, // Always use development mode for better test error messages
1316
useBuiltIns: true,
1417
},
1518
],
16-
].filter(Boolean),
17-
plugins: [
18-
process.env.WEBPACK_SERVE && 'react-refresh/babel',
19-
isProductionEnv && [
20-
'babel-plugin-transform-react-remove-prop-types',
21-
{
22-
removeImport: true,
23-
},
24-
],
25-
].filter(Boolean),
19+
],
2620
};
2721

2822
resultConfig.presets = [...resultConfig.presets, ...changesOnDefault.presets];
29-
resultConfig.plugins = [...resultConfig.plugins, ...changesOnDefault.plugins];
3023

3124
return resultConfig;
3225
};

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"@babel/core": "^7.21.0",
3636
"@babel/plugin-transform-runtime": "^7.21.0",
3737
"@babel/preset-env": "^7.20.2",
38-
"@babel/preset-react": "^7.18.6",
3938
"@babel/runtime": "^7.17.9",
4039
"@glennsl/rescript-fetch": "^0.2.0",
4140
"@glennsl/rescript-json-combinators": "^1.2.1",
@@ -49,8 +48,6 @@
4948
"ajv": "^8.17.1",
5049
"autoprefixer": "^10.4.14",
5150
"axios": "^0.21.1",
52-
"babel-loader": "^9.1.2",
53-
"babel-plugin-macros": "^3.1.0",
5451
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
5552
"classnames": "^2.3.2",
5653
"compression-webpack-plugin": "10.0.0",
@@ -110,6 +107,7 @@
110107
},
111108
"devDependencies": {
112109
"@babel/eslint-parser": "^7.16.5",
110+
"@babel/preset-react": "^7.18.6",
113111
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
114112
"@tailwindcss/typography": "^0.5.10",
115113
"@webpack-cli/serve": "^2.0.5",

yarn.lock

Lines changed: 3 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@
953953
"@babel/plugin-transform-react-jsx-development" "^7.27.1"
954954
"@babel/plugin-transform-react-pure-annotations" "^7.27.1"
955955

956-
"@babel/runtime@^7.12.1", "@babel/runtime@^7.12.5", "@babel/runtime@^7.17.9", "@babel/runtime@^7.5.5", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
956+
"@babel/runtime@^7.12.1", "@babel/runtime@^7.17.9", "@babel/runtime@^7.5.5", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
957957
version "7.28.4"
958958
resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.4.tgz"
959959
integrity sha512-Q/N6JNWvIvPnLDvjlE1OUBLPQHH6l3CltCEsHIujp45zQUSSh8K+gHnaEX45yAT1nyngnINhvWtzN+Nb9D8RAQ==
@@ -2186,11 +2186,6 @@
21862186
dependencies:
21872187
undici-types "~7.12.0"
21882188

2189-
"@types/parse-json@^4.0.0":
2190-
version "4.0.2"
2191-
resolved "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.2.tgz#5950e50960793055845e956c427fc2b0d70c5239"
2192-
integrity sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==
2193-
21942189
"@types/prettier@^2.6.0":
21952190
version "2.7.3"
21962191
resolved "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz"
@@ -2862,14 +2857,6 @@ babel-jest@^29.5.0, babel-jest@^29.7.0:
28622857
graceful-fs "^4.2.9"
28632858
slash "^3.0.0"
28642859

2865-
babel-loader@^9.1.2:
2866-
version "9.2.1"
2867-
resolved "https://registry.npmjs.org/babel-loader/-/babel-loader-9.2.1.tgz#04c7835db16c246dd19ba0914418f3937797587b"
2868-
integrity sha512-fqe8naHt46e0yIdkjUZYqddSXfej3AHajX+CSO5X7oy0EmPc6o5Xh+RClNoHjnieWz9AW4kZxW9yyFMhVB1QLA==
2869-
dependencies:
2870-
find-cache-dir "^4.0.0"
2871-
schema-utils "^4.0.0"
2872-
28732860
babel-plugin-istanbul@^6.1.1:
28742861
version "6.1.1"
28752862
resolved "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz"
@@ -2891,15 +2878,6 @@ babel-plugin-jest-hoist@^29.6.3:
28912878
"@types/babel__core" "^7.1.14"
28922879
"@types/babel__traverse" "^7.0.6"
28932880

2894-
babel-plugin-macros@^3.1.0:
2895-
version "3.1.0"
2896-
resolved "https://registry.npmjs.org/babel-plugin-macros/-/babel-plugin-macros-3.1.0.tgz#9ef6dc74deb934b4db344dc973ee851d148c50c1"
2897-
integrity sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg==
2898-
dependencies:
2899-
"@babel/runtime" "^7.12.5"
2900-
cosmiconfig "^7.0.0"
2901-
resolve "^1.19.0"
2902-
29032881
babel-plugin-polyfill-corejs2@^0.4.14:
29042882
version "0.4.14"
29052883
resolved "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.14.tgz"
@@ -3332,11 +3310,6 @@ commander@^8.3.0:
33323310
resolved "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz"
33333311
integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==
33343312

3335-
common-path-prefix@^3.0.0:
3336-
version "3.0.0"
3337-
resolved "https://registry.npmjs.org/common-path-prefix/-/common-path-prefix-3.0.0.tgz#7d007a7e07c58c4b4d5f433131a19141b29f11e0"
3338-
integrity sha512-QE33hToZseCH3jS0qN96O/bSh3kaw/h+Tq7ngyY9eWDUnTlTNUyqfqvCXioLe5Na5jFsL78ra/wuBU4iuEgd4w==
3339-
33403313
common-tags@^1.4.0, common-tags@^1.8.2:
33413314
version "1.8.2"
33423315
resolved "https://registry.npmjs.org/common-tags/-/common-tags-1.8.2.tgz"
@@ -3444,17 +3417,6 @@ core-util-is@~1.0.0:
34443417
resolved "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz"
34453418
integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==
34463419

3447-
cosmiconfig@^7.0.0:
3448-
version "7.1.0"
3449-
resolved "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.1.0.tgz#1443b9afa596b670082ea46cbd8f6a62b84635f6"
3450-
integrity sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA==
3451-
dependencies:
3452-
"@types/parse-json" "^4.0.0"
3453-
import-fresh "^3.2.1"
3454-
parse-json "^5.0.0"
3455-
path-type "^4.0.0"
3456-
yaml "^1.10.0"
3457-
34583420
cosmiconfig@^8.2.0:
34593421
version "8.3.6"
34603422
resolved "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.3.6.tgz"
@@ -4650,14 +4612,6 @@ finalhandler@1.3.1:
46504612
statuses "2.0.1"
46514613
unpipe "~1.0.0"
46524614

4653-
find-cache-dir@^4.0.0:
4654-
version "4.0.0"
4655-
resolved "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-4.0.0.tgz#a30ee0448f81a3990708f6453633c733e2f6eec2"
4656-
integrity sha512-9ZonPT4ZAK4a+1pUPVPZJapbi7O5qbbJPdYw/NOQWZZbVLdDTYM3A4R9z/DpAM08IDaFGsvPgiGZ82WEwUDWjg==
4657-
dependencies:
4658-
common-path-prefix "^3.0.0"
4659-
pkg-dir "^7.0.0"
4660-
46614615
find-root@^1.1.0:
46624616
version "1.1.0"
46634617
resolved "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz"
@@ -4686,14 +4640,6 @@ find-up@^5.0.0:
46864640
locate-path "^6.0.0"
46874641
path-exists "^4.0.0"
46884642

4689-
find-up@^6.3.0:
4690-
version "6.3.0"
4691-
resolved "https://registry.npmjs.org/find-up/-/find-up-6.3.0.tgz#2abab3d3280b2dc7ac10199ef324c4e002c8c790"
4692-
integrity sha512-v2ZsoEuVHYy8ZIlYqwPe/39Cy+cFDzp4dXPaxNvkEuouymu+2Jbz0PxpKarJHYJTmv2HWT3O382qY8l4jMWthw==
4693-
dependencies:
4694-
locate-path "^7.1.0"
4695-
path-exists "^5.0.0"
4696-
46974643
flat-cache@^3.0.4:
46984644
version "3.2.0"
46994645
resolved "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz"
@@ -6169,13 +6115,6 @@ locate-path@^6.0.0:
61696115
dependencies:
61706116
p-locate "^5.0.0"
61716117

6172-
locate-path@^7.1.0:
6173-
version "7.2.0"
6174-
resolved "https://registry.npmjs.org/locate-path/-/locate-path-7.2.0.tgz#69cb1779bd90b35ab1e771e1f2f89a202c2a8a8a"
6175-
integrity sha512-gvVijfZvn7R+2qyPX8mAuKcFGDf6Nc61GdvGafQsHL0sBIxfKzA+usWn4GFC/bk+QdwPUD4kWFJLhElipq+0VA==
6176-
dependencies:
6177-
p-locate "^6.0.0"
6178-
61796118
lockfile@^1.0.4:
61806119
version "1.0.4"
61816120
resolved "https://registry.npmjs.org/lockfile/-/lockfile-1.0.4.tgz"
@@ -6785,13 +6724,6 @@ p-limit@^3.0.2, p-limit@^3.1.0:
67856724
dependencies:
67866725
yocto-queue "^0.1.0"
67876726

6788-
p-limit@^4.0.0:
6789-
version "4.0.0"
6790-
resolved "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz#914af6544ed32bfa54670b061cafcbd04984b644"
6791-
integrity sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==
6792-
dependencies:
6793-
yocto-queue "^1.0.0"
6794-
67956727
p-locate@^3.0.0:
67966728
version "3.0.0"
67976729
resolved "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz"
@@ -6813,13 +6745,6 @@ p-locate@^5.0.0:
68136745
dependencies:
68146746
p-limit "^3.0.2"
68156747

6816-
p-locate@^6.0.0:
6817-
version "6.0.0"
6818-
resolved "https://registry.npmjs.org/p-locate/-/p-locate-6.0.0.tgz#3da9a49d4934b901089dca3302fa65dc5a05c04f"
6819-
integrity sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw==
6820-
dependencies:
6821-
p-limit "^4.0.0"
6822-
68236748
p-retry@^4.5.0:
68246749
version "4.6.2"
68256750
resolved "https://registry.npmjs.org/p-retry/-/p-retry-4.6.2.tgz"
@@ -6853,7 +6778,7 @@ parent-module@^1.0.0:
68536778
dependencies:
68546779
callsites "^3.0.0"
68556780

6856-
parse-json@^5.0.0, parse-json@^5.2.0:
6781+
parse-json@^5.2.0:
68576782
version "5.2.0"
68586783
resolved "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz#c76fc66dee54231c962b22bcc8a72cf2f99753cd"
68596784
integrity sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==
@@ -6896,11 +6821,6 @@ path-exists@^4.0.0:
68966821
resolved "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz"
68976822
integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==
68986823

6899-
path-exists@^5.0.0:
6900-
version "5.0.0"
6901-
resolved "https://registry.npmjs.org/path-exists/-/path-exists-5.0.0.tgz#a6aad9489200b21fab31e49cf09277e5116fb9e7"
6902-
integrity sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ==
6903-
69046824
path-is-absolute@^1.0.0:
69056825
version "1.0.1"
69066826
resolved "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz"
@@ -6966,13 +6886,6 @@ pkg-dir@^4.2.0:
69666886
dependencies:
69676887
find-up "^4.0.0"
69686888

6969-
pkg-dir@^7.0.0:
6970-
version "7.0.0"
6971-
resolved "https://registry.npmjs.org/pkg-dir/-/pkg-dir-7.0.0.tgz#8f0c08d6df4476756c5ff29b3282d0bab7517d11"
6972-
integrity sha512-Ie9z/WINcxxLp27BKOCHGde4ITq9UklYKDzVo1nhk5sqGEXU3FpkwP5GM2voTGJkGd9B3Otl+Q4uwSOeSUtOBA==
6973-
dependencies:
6974-
find-up "^6.3.0"
6975-
69766889
possible-typed-array-names@^1.0.0:
69776890
version "1.1.0"
69786891
resolved "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz"
@@ -8019,7 +7932,7 @@ resolve.exports@^2.0.0:
80197932
resolved "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.3.tgz"
80207933
integrity sha512-OcXjMsGdhL4XnbShKpAcSqPMzQoYkYyhbEaeSko47MjRP9NfEQMhZkXL1DoFlt9LWQn4YttrdnV6X2OiyzBi+A==
80217934

8022-
resolve@^1.1.7, resolve@^1.19.0, resolve@^1.20.0, resolve@^1.22.10, resolve@^1.22.4, resolve@^1.22.8:
7935+
resolve@^1.1.7, resolve@^1.20.0, resolve@^1.22.10, resolve@^1.22.4, resolve@^1.22.8:
80237936
version "1.22.10"
80247937
resolved "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz"
80257938
integrity sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==
@@ -9473,11 +9386,6 @@ yallist@^3.0.2:
94739386
resolved "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz"
94749387
integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==
94759388

9476-
yaml@^1.10.0:
9477-
version "1.10.2"
9478-
resolved "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b"
9479-
integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==
9480-
94819389
yargs-parser@^13.1.2:
94829390
version "13.1.2"
94839391
resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz"
@@ -9524,8 +9432,3 @@ yocto-queue@^0.1.0:
95249432
version "0.1.0"
95259433
resolved "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz"
95269434
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==
9527-
9528-
yocto-queue@^1.0.0:
9529-
version "1.2.1"
9530-
resolved "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.2.1.tgz#36d7c4739f775b3cbc28e6136e21aa057adec418"
9531-
integrity sha512-AyeEbWOu/TAXdxlV9wmGcR0+yh2j3vYPGOECcIj2S7MkrLyC7ne+oye2BKTItt0ii2PHk4cDy+95+LshzbXnGg==

0 commit comments

Comments
 (0)