react_on_rails 16.2.0.test.6 → 16.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96c65c2ad30fb286eb0f181994d7201f57a386c0370363f6d3356c7d2e9a1317
4
- data.tar.gz: 83f9308811c6f328296ad9a68232a7b7fd104ff46857ea239c621cedc7e285f8
3
+ metadata.gz: a9c2f0777db9628ff37563b2f8546bf1f61019fc10bbcd32b973b5816767e200
4
+ data.tar.gz: 5a095ac47764234bdba71c57030674b026e3898c680ad0d4cbf8d683285e79da
5
5
  SHA512:
6
- metadata.gz: 796d8a27960b07fe2234e19be037ccca56dd85d5aebe9153d59fd26a4a560c5f504d55e8f3984eee545fc5deb159154abe019eced470da28c037352d45c19af9
7
- data.tar.gz: 9ed658b9e921a68ab1dad98d01a9197b3c15b96bd634f4973f781682243f2b7da641c0efb8372bcae52a1976676f209b9d41e37ee70daadb40b9bd691b3cfe0f
6
+ metadata.gz: 024ec86c92012b0be90dcc33b9b19958911181d392098b58a5ba3deb71d4d71de00a4dc5bd7c61ce271a8bbeb9d3af5f804ba5714540276dc5dd8c547979deb6
7
+ data.tar.gz: 6982985357e090f38ca9c60e41950de05f29a021d149f77e22da61dc483da01a52616597e42fd893fe79e98de0932f05f9d8d661c52bafdf16dba50ec57bdb5a
data/.rubocop.yml CHANGED
@@ -1,36 +1,16 @@
1
- # This is the configuration used to check the rubocop source code.
2
- # Check out: https://github.com/bbatsov/rubocop
3
- require:
4
- - rubocop-performance
5
- - rubocop-rspec
1
+ # Inherits from root config
2
+ inherit_from: ../.rubocop.yml
3
+
4
+ # Merge Exclude arrays with parent instead of replacing them
5
+ inherit_mode:
6
+ merge:
7
+ - Exclude
6
8
 
7
9
  AllCops:
8
- NewCops: enable
9
- DisplayCopNames: true
10
- TargetRubyVersion: 3.0.0
11
10
  SuggestExtensions: false
12
11
 
13
- Include:
14
- - '**/Rakefile'
15
- - '**/config.ru'
16
- - 'Gemfile'
17
- - '**/*.rb'
18
- - '**/*.rake'
19
-
20
12
  Exclude:
21
- - '**/*.js'
22
- - '**/node_modules/**/*'
23
- - '**/public/**/*'
24
- - '**/tmp/**/*'
25
- - 'coverage/**/*'
26
- - 'gen-examples/examples/**/*'
27
- - 'node_modules/**/*'
28
- - '../react_on_rails_pro/**/*' # Exclude pro package (has its own linting)
29
13
  - 'spec/dummy/bin/*'
30
- - 'spec/fixtures/**/*'
31
- - 'spec/react_on_rails/dummy-for-generators/**/*'
32
- - 'tmp/**/*'
33
- - 'vendor/**/*'
34
14
 
35
15
  Naming/FileName:
36
16
  Exclude:
@@ -38,24 +18,6 @@ Naming/FileName:
38
18
  - '**/Rakefile'
39
19
  - '**/Steepfile'
40
20
 
41
- Layout/LineLength:
42
- Max: 120
43
-
44
- Style/StringLiterals:
45
- EnforcedStyle: double_quotes
46
-
47
- Style/Documentation:
48
- Enabled: false
49
-
50
- Style/HashEachMethods:
51
- Enabled: true
52
-
53
- Style/HashTransformKeys:
54
- Enabled: true
55
-
56
- Style/HashTransformValues:
57
- Enabled: true
58
-
59
21
  Lint/AssignmentInCondition:
60
22
  Exclude:
61
23
  - 'spec/dummy/bin/spring'
@@ -66,33 +28,19 @@ Lint/SuppressedException:
66
28
  - 'spec/dummy/bin/rake'
67
29
 
68
30
  Metrics/AbcSize:
69
- Max: 28
70
31
  Exclude:
71
32
  - 'lib/generators/react_on_rails/install_generator.rb' # Generator setup methods require comprehensive error handling
72
33
 
73
- Metrics/CyclomaticComplexity:
74
- Max: 7
75
-
76
- Metrics/PerceivedComplexity:
77
- Max: 10
78
-
79
34
  Metrics/ClassLength:
80
- Max: 150
81
35
  Exclude:
82
36
  - 'lib/generators/react_on_rails/base_generator.rb' # Generator complexity justified
83
37
  - 'lib/react_on_rails/dev/server_manager.rb' # Dev tool with comprehensive help system
84
38
 
85
- Metrics/ParameterLists:
86
- Max: 5
87
- CountKeywordArgs: false
88
-
89
39
  Metrics/MethodLength:
90
- Max: 41
91
40
  Exclude:
92
41
  - 'lib/generators/react_on_rails/install_generator.rb' # Generator setup methods require comprehensive error handling
93
42
 
94
43
  Metrics/ModuleLength:
95
- Max: 180
96
44
  Exclude:
97
45
  - 'spec/react_on_rails/engine_spec.rb' # Comprehensive engine tests require many examples
98
46
 
@@ -107,18 +55,6 @@ RSpec/AnyInstance:
107
55
  - 'spec/react_on_rails/binstubs/dev_static_spec.rb'
108
56
  - 'spec/react_on_rails/dev/**/*_spec.rb' # Dev module tests require system mocking
109
57
 
110
- RSpec/DescribeClass:
111
- Enabled: false
112
-
113
- RSpec/ExampleLength:
114
- Enabled: false
115
-
116
- RSpec/MessageSpies:
117
- Enabled: false
118
-
119
- RSpec/NestedGroups:
120
- Max: 4
121
-
122
58
  RSpec/BeforeAfterAll:
123
59
  Exclude:
124
60
  - 'spec/react_on_rails/generators/dev_tests_generator_spec.rb'
@@ -127,19 +63,10 @@ RSpec/BeforeAfterAll:
127
63
  - 'spec/react_on_rails/binstubs/dev_static_spec.rb'
128
64
  - 'spec/react_on_rails/dev/**/*_spec.rb' # Dev module tests require global setup
129
65
 
130
- RSpec/MessageChain:
131
- Enabled: false
132
-
133
- RSpec/MultipleExpectations:
134
- Enabled: false
135
-
136
66
  RSpec/MultipleDescribes:
137
67
  Exclude:
138
68
  - 'spec/dummy/spec/system/integration_spec.rb'
139
69
 
140
- RSpec/MultipleMemoizedHelpers:
141
- Max: 12
142
-
143
70
  Style/GlobalVars:
144
71
  Exclude:
145
72
  - 'spec/dummy/config/environments/development.rb'
@@ -156,4 +83,3 @@ RSpec/InstanceVariable:
156
83
  RSpec/StubbedMock:
157
84
  Exclude:
158
85
  - 'spec/react_on_rails/dev/**/*_spec.rb' # Dev module tests use mixed stub/mock patterns
159
-
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ eval_gemfile File.expand_path("../Gemfile.shared_dev_dependencies", __dir__)
4
+
3
5
  gem "shakapacker", "9.4.0"
4
6
  gem "bootsnap", require: false
5
- gem "rails", "~> 7.1"
7
+ gem "rails", "~> 7.1.0"
6
8
 
7
9
  gem "sqlite3", "~> 1.6"
8
10
  gem "sass-rails", "~> 6.0"
@@ -35,9 +37,6 @@ group :development, :test do
35
37
  gem "pry-rescue"
36
38
  gem "rbs", require: false
37
39
  gem "steep", require: false
38
- gem "rubocop", "1.61.0", require: false
39
- gem "rubocop-performance", "~>1.20.0", require: false
40
- gem "rubocop-rspec", "~>2.26", require: false
41
40
  gem "spring", "~> 4.0"
42
41
  gem "lefthook", require: false
43
42
  # Added for Ruby 3.5+ compatibility to silence warnings
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- react_on_rails (16.2.0.test.6)
4
+ react_on_rails (16.2.0)
5
5
  addressable
6
6
  connection_pool
7
7
  execjs (~> 2.5)
@@ -12,35 +12,36 @@ PATH
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- actioncable (7.1.3.2)
16
- actionpack (= 7.1.3.2)
17
- activesupport (= 7.1.3.2)
15
+ actioncable (7.1.6)
16
+ actionpack (= 7.1.6)
17
+ activesupport (= 7.1.6)
18
18
  nio4r (~> 2.0)
19
19
  websocket-driver (>= 0.6.1)
20
20
  zeitwerk (~> 2.6)
21
- actionmailbox (7.1.3.2)
22
- actionpack (= 7.1.3.2)
23
- activejob (= 7.1.3.2)
24
- activerecord (= 7.1.3.2)
25
- activestorage (= 7.1.3.2)
26
- activesupport (= 7.1.3.2)
21
+ actionmailbox (7.1.6)
22
+ actionpack (= 7.1.6)
23
+ activejob (= 7.1.6)
24
+ activerecord (= 7.1.6)
25
+ activestorage (= 7.1.6)
26
+ activesupport (= 7.1.6)
27
27
  mail (>= 2.7.1)
28
28
  net-imap
29
29
  net-pop
30
30
  net-smtp
31
- actionmailer (7.1.3.2)
32
- actionpack (= 7.1.3.2)
33
- actionview (= 7.1.3.2)
34
- activejob (= 7.1.3.2)
35
- activesupport (= 7.1.3.2)
31
+ actionmailer (7.1.6)
32
+ actionpack (= 7.1.6)
33
+ actionview (= 7.1.6)
34
+ activejob (= 7.1.6)
35
+ activesupport (= 7.1.6)
36
36
  mail (~> 2.5, >= 2.5.4)
37
37
  net-imap
38
38
  net-pop
39
39
  net-smtp
40
40
  rails-dom-testing (~> 2.2)
41
- actionpack (7.1.3.2)
42
- actionview (= 7.1.3.2)
43
- activesupport (= 7.1.3.2)
41
+ actionpack (7.1.6)
42
+ actionview (= 7.1.6)
43
+ activesupport (= 7.1.6)
44
+ cgi
44
45
  nokogiri (>= 1.8.5)
45
46
  racc
46
47
  rack (>= 2.2.4)
@@ -48,43 +49,47 @@ GEM
48
49
  rack-test (>= 0.6.3)
49
50
  rails-dom-testing (~> 2.2)
50
51
  rails-html-sanitizer (~> 1.6)
51
- actiontext (7.1.3.2)
52
- actionpack (= 7.1.3.2)
53
- activerecord (= 7.1.3.2)
54
- activestorage (= 7.1.3.2)
55
- activesupport (= 7.1.3.2)
52
+ actiontext (7.1.6)
53
+ actionpack (= 7.1.6)
54
+ activerecord (= 7.1.6)
55
+ activestorage (= 7.1.6)
56
+ activesupport (= 7.1.6)
56
57
  globalid (>= 0.6.0)
57
58
  nokogiri (>= 1.8.5)
58
- actionview (7.1.3.2)
59
- activesupport (= 7.1.3.2)
59
+ actionview (7.1.6)
60
+ activesupport (= 7.1.6)
60
61
  builder (~> 3.1)
62
+ cgi
61
63
  erubi (~> 1.11)
62
64
  rails-dom-testing (~> 2.2)
63
65
  rails-html-sanitizer (~> 1.6)
64
- activejob (7.1.3.2)
65
- activesupport (= 7.1.3.2)
66
+ activejob (7.1.6)
67
+ activesupport (= 7.1.6)
66
68
  globalid (>= 0.3.6)
67
- activemodel (7.1.3.2)
68
- activesupport (= 7.1.3.2)
69
- activerecord (7.1.3.2)
70
- activemodel (= 7.1.3.2)
71
- activesupport (= 7.1.3.2)
69
+ activemodel (7.1.6)
70
+ activesupport (= 7.1.6)
71
+ activerecord (7.1.6)
72
+ activemodel (= 7.1.6)
73
+ activesupport (= 7.1.6)
72
74
  timeout (>= 0.4.0)
73
- activestorage (7.1.3.2)
74
- actionpack (= 7.1.3.2)
75
- activejob (= 7.1.3.2)
76
- activerecord (= 7.1.3.2)
77
- activesupport (= 7.1.3.2)
75
+ activestorage (7.1.6)
76
+ actionpack (= 7.1.6)
77
+ activejob (= 7.1.6)
78
+ activerecord (= 7.1.6)
79
+ activesupport (= 7.1.6)
78
80
  marcel (~> 1.0)
79
- activesupport (7.1.3.2)
81
+ activesupport (7.1.6)
80
82
  base64
83
+ benchmark (>= 0.3)
81
84
  bigdecimal
82
85
  concurrent-ruby (~> 1.0, >= 1.0.2)
83
86
  connection_pool (>= 2.2.5)
84
87
  drb
85
88
  i18n (>= 1.6, < 2)
89
+ logger (>= 1.4.2)
86
90
  minitest (>= 5.1)
87
91
  mutex_m
92
+ securerandom (>= 0.3)
88
93
  tzinfo (~> 2.0)
89
94
  addressable (2.8.7)
90
95
  public_suffix (>= 2.0.2, < 7.0)
@@ -92,7 +97,7 @@ GEM
92
97
  ast (2.4.2)
93
98
  base64 (0.3.0)
94
99
  benchmark (0.4.1)
95
- bigdecimal (3.3.1)
100
+ bigdecimal (4.0.1)
96
101
  bootsnap (1.18.3)
97
102
  msgpack (~> 1.2)
98
103
  builder (3.3.0)
@@ -109,10 +114,11 @@ GEM
109
114
  capybara-screenshot (1.0.26)
110
115
  capybara (>= 1.0, < 4)
111
116
  launchy
117
+ cgi (0.5.1)
112
118
  childprocess (5.0.0)
113
119
  coderay (1.1.3)
114
- concurrent-ruby (1.3.5)
115
- connection_pool (2.5.5)
120
+ concurrent-ruby (1.3.6)
121
+ connection_pool (3.0.2)
116
122
  coveralls (0.8.23)
117
123
  json (>= 1.8, < 3)
118
124
  simplecov (~> 0.16.1)
@@ -123,7 +129,7 @@ GEM
123
129
  csv (3.3.5)
124
130
  cypress-on-rails (1.20.0)
125
131
  rack
126
- date (3.5.0)
132
+ date (3.5.1)
127
133
  debug (1.9.2)
128
134
  irb (~> 1.10)
129
135
  reline (>= 0.3.8)
@@ -132,7 +138,7 @@ GEM
132
138
  drb (2.2.3)
133
139
  equivalent-xml (0.6.0)
134
140
  nokogiri (>= 1.4.3)
135
- erb (6.0.0)
141
+ erb (6.0.1)
136
142
  erubi (1.13.1)
137
143
  execjs (2.9.1)
138
144
  ffi (1.16.3)
@@ -141,13 +147,13 @@ GEM
141
147
  generator_spec (0.10.0)
142
148
  activesupport (>= 3.0.0)
143
149
  railties (>= 3.0.0)
144
- globalid (1.2.1)
150
+ globalid (1.3.0)
145
151
  activesupport (>= 6.1)
146
- i18n (1.14.7)
152
+ i18n (1.14.8)
147
153
  concurrent-ruby (~> 1.0)
148
154
  interception (0.5)
149
- io-console (0.8.1)
150
- irb (1.15.3)
155
+ io-console (0.8.2)
156
+ irb (1.16.0)
151
157
  pp (>= 0.6.0)
152
158
  rdoc (>= 4.0.0)
153
159
  reline (>= 0.4.2)
@@ -168,32 +174,34 @@ GEM
168
174
  rb-fsevent (~> 0.10, >= 0.10.3)
169
175
  rb-inotify (~> 0.9, >= 0.9.10)
170
176
  logger (1.7.0)
171
- loofah (2.24.1)
177
+ loofah (2.25.0)
172
178
  crass (~> 1.0.2)
173
179
  nokogiri (>= 1.12.0)
174
- mail (2.8.1)
180
+ mail (2.9.0)
181
+ logger
175
182
  mini_mime (>= 0.1.1)
176
183
  net-imap
177
184
  net-pop
178
185
  net-smtp
179
- marcel (1.0.4)
186
+ marcel (1.1.0)
180
187
  matrix (0.4.3)
181
188
  method_source (1.1.0)
182
189
  mini_mime (1.1.5)
183
190
  mini_portile2 (2.8.9)
184
- minitest (5.26.2)
191
+ minitest (6.0.1)
192
+ prism (~> 1.5)
185
193
  msgpack (1.7.2)
186
194
  mutex_m (0.3.0)
187
- net-imap (0.4.11)
195
+ net-imap (0.6.2)
188
196
  date
189
197
  net-protocol
190
198
  net-pop (0.1.2)
191
199
  net-protocol
192
200
  net-protocol (0.2.2)
193
201
  timeout
194
- net-smtp (0.5.0)
202
+ net-smtp (0.5.1)
195
203
  net-protocol
196
- nio4r (2.7.3)
204
+ nio4r (2.7.5)
197
205
  nokogiri (1.18.10)
198
206
  mini_portile2 (~> 2.8.2)
199
207
  racc (~> 1.4)
@@ -206,6 +214,7 @@ GEM
206
214
  pp (0.6.3)
207
215
  prettyprint
208
216
  prettyprint (0.2.0)
217
+ prism (1.7.0)
209
218
  pry (0.14.2)
210
219
  coderay (~> 1.1)
211
220
  method_source (~> 1.0)
@@ -220,11 +229,11 @@ GEM
220
229
  pry-rescue (1.6.0)
221
230
  interception (>= 0.5)
222
231
  pry (>= 0.12.0)
223
- psych (5.2.6)
232
+ psych (5.3.1)
224
233
  date
225
234
  stringio
226
235
  public_suffix (6.0.2)
227
- puma (6.4.2)
236
+ puma (6.6.1)
228
237
  nio4r (~> 2.0)
229
238
  racc (1.8.1)
230
239
  rack (3.2.4)
@@ -235,22 +244,22 @@ GEM
235
244
  rack (>= 3.0.0)
236
245
  rack-test (2.2.0)
237
246
  rack (>= 1.3)
238
- rackup (2.2.1)
247
+ rackup (2.3.1)
239
248
  rack (>= 3)
240
- rails (7.1.3.2)
241
- actioncable (= 7.1.3.2)
242
- actionmailbox (= 7.1.3.2)
243
- actionmailer (= 7.1.3.2)
244
- actionpack (= 7.1.3.2)
245
- actiontext (= 7.1.3.2)
246
- actionview (= 7.1.3.2)
247
- activejob (= 7.1.3.2)
248
- activemodel (= 7.1.3.2)
249
- activerecord (= 7.1.3.2)
250
- activestorage (= 7.1.3.2)
251
- activesupport (= 7.1.3.2)
249
+ rails (7.1.6)
250
+ actioncable (= 7.1.6)
251
+ actionmailbox (= 7.1.6)
252
+ actionmailer (= 7.1.6)
253
+ actionpack (= 7.1.6)
254
+ actiontext (= 7.1.6)
255
+ actionview (= 7.1.6)
256
+ activejob (= 7.1.6)
257
+ activemodel (= 7.1.6)
258
+ activerecord (= 7.1.6)
259
+ activestorage (= 7.1.6)
260
+ activesupport (= 7.1.6)
252
261
  bundler (>= 1.15.0)
253
- railties (= 7.1.3.2)
262
+ railties (= 7.1.6)
254
263
  rails-dom-testing (2.3.0)
255
264
  activesupport (>= 5.0.0)
256
265
  minitest
@@ -258,13 +267,15 @@ GEM
258
267
  rails-html-sanitizer (1.6.2)
259
268
  loofah (~> 2.21)
260
269
  nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
261
- railties (7.1.3.2)
262
- actionpack (= 7.1.3.2)
263
- activesupport (= 7.1.3.2)
270
+ railties (7.1.6)
271
+ actionpack (= 7.1.6)
272
+ activesupport (= 7.1.6)
273
+ cgi
264
274
  irb
265
275
  rackup (>= 1.0.0)
266
276
  rake (>= 12.2)
267
277
  thor (~> 1.0, >= 1.2.2)
278
+ tsort (>= 0.2)
268
279
  zeitwerk (~> 2.6)
269
280
  rainbow (3.1.1)
270
281
  rake (13.3.1)
@@ -273,15 +284,14 @@ GEM
273
284
  ffi (~> 1.0)
274
285
  rbs (3.9.5)
275
286
  logger
276
- rdoc (6.15.1)
287
+ rdoc (7.0.3)
277
288
  erb
278
289
  psych (>= 4.0.0)
279
290
  tsort
280
291
  regexp_parser (2.11.3)
281
292
  reline (0.6.3)
282
293
  io-console (~> 0.5)
283
- rexml (3.2.7)
284
- strscan (>= 3.0.9)
294
+ rexml (3.4.4)
285
295
  rspec-core (3.13.0)
286
296
  rspec-support (~> 3.13.0)
287
297
  rspec-expectations (3.13.1)
@@ -387,7 +397,7 @@ GEM
387
397
  strscan (>= 1.0.0)
388
398
  terminal-table (>= 2, < 4)
389
399
  uri (>= 0.12.0)
390
- stringio (3.1.8)
400
+ stringio (3.2.0)
391
401
  strscan (3.1.0)
392
402
  sync (0.5.0)
393
403
  term-ansicolor (1.8.0)
@@ -396,15 +406,14 @@ GEM
396
406
  unicode-display_width (>= 1.1.1, < 3)
397
407
  thor (1.4.0)
398
408
  tilt (2.3.0)
399
- timeout (0.4.1)
409
+ timeout (0.6.0)
400
410
  tins (1.33.0)
401
411
  bigdecimal
402
412
  sync
403
413
  tsort (0.2.0)
404
- turbo-rails (2.0.6)
405
- actionpack (>= 6.0.0)
406
- activejob (>= 6.0.0)
407
- railties (>= 6.0.0)
414
+ turbo-rails (2.0.20)
415
+ actionpack (>= 7.1.0)
416
+ railties (>= 7.1.0)
408
417
  turbolinks (5.2.1)
409
418
  turbolinks-source (~> 5.2)
410
419
  turbolinks-source (5.2.0)
@@ -419,13 +428,14 @@ GEM
419
428
  rubyzip (>= 1.3.0)
420
429
  selenium-webdriver (~> 4.0, < 4.11)
421
430
  websocket (1.2.10)
422
- websocket-driver (0.7.6)
431
+ websocket-driver (0.8.0)
432
+ base64
423
433
  websocket-extensions (>= 0.1.0)
424
434
  websocket-extensions (0.1.5)
425
435
  xpath (3.2.0)
426
436
  nokogiri (~> 1.8)
427
437
  yard (0.9.36)
428
- zeitwerk (2.7.3)
438
+ zeitwerk (2.7.4)
429
439
 
430
440
  PLATFORMS
431
441
  ruby
@@ -456,7 +466,7 @@ DEPENDENCIES
456
466
  pry-rails
457
467
  pry-rescue
458
468
  puma (~> 6.0)
459
- rails (~> 7.1)
469
+ rails (~> 7.1.0)
460
470
  rbs
461
471
  react_on_rails!
462
472
  rspec-rails
@@ -31,7 +31,8 @@ module ReactOnRails
31
31
 
32
32
  def add_test_related_gems_to_gemfile
33
33
  gem("rspec-rails", group: :test)
34
- gem("chromedriver-helper", group: :test)
34
+ # NOTE: chromedriver-helper was deprecated in 2019. Modern selenium-webdriver (4.x)
35
+ # and GitHub Actions have built-in driver management, so no driver helper is needed.
35
36
  gem("coveralls", require: false)
36
37
  end
37
38
 
@@ -124,4 +124,75 @@ module GeneratorHelper
124
124
  true
125
125
  end
126
126
  end
127
+
128
+ # Check if SWC is configured as the JavaScript transpiler in shakapacker.yml
129
+ #
130
+ # @return [Boolean] true if SWC is configured or should be used by default
131
+ #
132
+ # Detection logic:
133
+ # 1. If shakapacker.yml exists and specifies javascript_transpiler: parse it
134
+ # 2. For Shakapacker 9.3.0+, SWC is the default if not specified
135
+ # 3. Returns true for fresh installations (SWC is recommended default)
136
+ #
137
+ # @note This method is used to determine whether to install SWC dependencies
138
+ # (@swc/core, swc-loader) instead of Babel dependencies during generation.
139
+ #
140
+ # @note Caching: The result is memoized for the lifetime of the generator instance.
141
+ # If shakapacker.yml changes during generator execution (unlikely), the cached
142
+ # value will not update. This is acceptable since generators run quickly.
143
+ def using_swc?
144
+ return @using_swc if defined?(@using_swc)
145
+
146
+ @using_swc = detect_swc_configuration
147
+ end
148
+
149
+ private
150
+
151
+ def detect_swc_configuration
152
+ shakapacker_yml_path = File.join(destination_root, "config/shakapacker.yml")
153
+
154
+ if File.exist?(shakapacker_yml_path)
155
+ config = parse_shakapacker_yml(shakapacker_yml_path)
156
+ transpiler = config.dig("default", "javascript_transpiler")
157
+
158
+ # Explicit configuration takes precedence
159
+ return transpiler == "swc" if transpiler
160
+
161
+ # For Shakapacker 9.3.0+, SWC is the default
162
+ return shakapacker_version_9_3_or_higher?
163
+ end
164
+
165
+ # Fresh install: SWC is recommended default for Shakapacker 9.3.0+
166
+ shakapacker_version_9_3_or_higher?
167
+ end
168
+
169
+ def parse_shakapacker_yml(path)
170
+ require "yaml"
171
+ # Use safe_load_file for security (defense-in-depth, even though this is user's own config)
172
+ # permitted_classes: [Symbol] allows symbol keys which shakapacker.yml may use
173
+ # aliases: true allows YAML anchors (&default, *default) commonly used in Rails configs
174
+ YAML.safe_load_file(path, permitted_classes: [Symbol], aliases: true)
175
+ rescue ArgumentError
176
+ # Older Psych versions don't support all parameters - try without aliases
177
+ begin
178
+ YAML.safe_load_file(path, permitted_classes: [Symbol])
179
+ rescue ArgumentError
180
+ # Very old Psych - fall back to safe_load with File.read
181
+ YAML.safe_load(File.read(path), permitted_classes: [Symbol]) # rubocop:disable Style/YAMLFileRead
182
+ end
183
+ rescue StandardError
184
+ # If we can't parse the file, return empty config
185
+ {}
186
+ end
187
+
188
+ # Check if Shakapacker 9.3.0 or higher is available
189
+ # This version made SWC the default JavaScript transpiler
190
+ def shakapacker_version_9_3_or_higher?
191
+ return true unless defined?(ReactOnRails::PackerUtils)
192
+
193
+ ReactOnRails::PackerUtils.shakapacker_version_requirement_met?("9.3.0")
194
+ rescue StandardError
195
+ # If we can't determine version, assume latest (which uses SWC)
196
+ true
197
+ end
127
198
  end
@@ -99,6 +99,13 @@ module ReactOnRails
99
99
  @types/react-dom
100
100
  ].freeze
101
101
 
102
+ # SWC transpiler dependencies (for Shakapacker 9.3.0+ default transpiler)
103
+ # SWC is ~20x faster than Babel and is the default for new Shakapacker installations
104
+ SWC_DEPENDENCIES = %w[
105
+ @swc/core
106
+ swc-loader
107
+ ].freeze
108
+
102
109
  private
103
110
 
104
111
  def setup_js_dependencies
@@ -118,6 +125,8 @@ module ReactOnRails
118
125
  add_css_dependencies
119
126
  # Rspack dependencies are only added when --rspack flag is used
120
127
  add_rspack_dependencies if respond_to?(:options) && options&.rspack?
128
+ # SWC dependencies are only added when SWC is the configured transpiler
129
+ add_swc_dependencies if using_swc?
121
130
  # Dev dependencies vary based on bundler choice
122
131
  add_dev_dependencies
123
132
  end
@@ -232,6 +241,26 @@ module ReactOnRails
232
241
  MSG
233
242
  end
234
243
 
244
+ def add_swc_dependencies
245
+ puts "Installing SWC transpiler dependencies (20x faster than Babel)..."
246
+ return if add_packages(SWC_DEPENDENCIES, dev: true)
247
+
248
+ GeneratorMessages.add_warning(<<~MSG.strip)
249
+ ⚠️ Failed to add SWC dependencies.
250
+
251
+ SWC is the default JavaScript transpiler for Shakapacker 9.3.0+.
252
+ You can install them manually by running:
253
+ npm install --save-dev #{SWC_DEPENDENCIES.join(' ')}
254
+ MSG
255
+ rescue StandardError => e
256
+ GeneratorMessages.add_warning(<<~MSG.strip)
257
+ ⚠️ Error adding SWC dependencies: #{e.message}
258
+
259
+ You can install them manually by running:
260
+ npm install --save-dev #{SWC_DEPENDENCIES.join(' ')}
261
+ MSG
262
+ end
263
+
235
264
  def add_typescript_dependencies
236
265
  puts "Installing TypeScript dependencies..."
237
266
  return if add_packages(TYPESCRIPT_DEPENDENCIES, dev: true)