@@ -154,32 +154,35 @@ def check_component_registry_timeout
154
154
raise ReactOnRails ::Error , "component_registry_timeout must be a positive integer"
155
155
end
156
156
157
- # rubocop:disable Metrics/CyclomaticComplexity
157
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
158
158
def validate_generated_component_packs_loading_strategy
159
- # rubocop:enable Metrics/CyclomaticComplexity
159
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
160
+
161
+ if defer_generated_component_packs
162
+ if %i[ async sync ] . include? ( generated_component_packs_loading_strategy )
163
+ Rails . logger . warn "**WARNING** ReactOnRails: config.defer_generated_component_packs is " \
164
+ "superseded by config.generated_component_packs_loading_strategy"
165
+ else
166
+ Rails . logger . warn "[DEPRECATION] ReactOnRails: Use config." \
167
+ "generated_component_packs_loading_strategy = :defer rather than " \
168
+ "defer_generated_component_packs"
169
+ self . generated_component_packs_loading_strategy ||= :defer
170
+ end
171
+ end
172
+
173
+ msg = <<~MSG
174
+ ReactOnRails: Your current version of #{ ReactOnRails ::PackerUtils . packer_type . upcase_first } \
175
+ does not support async script loading, which may cause performance issues. Please either:
176
+ 1. Use :sync or :defer loading strategy instead of :async
177
+ 2. Upgrade to Shakapacker v8.2.0 or above to enable async script loading
178
+ MSG
160
179
if PackerUtils . shakapacker_version_requirement_met? ( [ 8 , 2 , 0 ] )
161
180
self . generated_component_packs_loading_strategy ||= :async
162
- elsif defer_generated_component_packs
163
- generated_component_packs_loading_strategy ||= :defer
164
- Rails . logger . warn "[DEPRECATION] ReactOnRails: Use config." \
165
- "generated_component_packs_loading_strategy = :defer rather than " \
166
- "defer_generated_component_packs"
167
181
elsif generated_component_packs_loading_strategy . nil?
168
- msg = <<~MSG
169
- **WARNING** ReactOnRails: Your current version of #{ ReactOnRails ::PackerUtils . packer_type . upcase_first } \
170
- does not support async script loading which may cause performance issues. Please upgrade to Shakapacker v8.2.0 \
171
- or above to enable async script loading for better performance.
172
- MSG
173
- Rails . logger . warn ( msg )
182
+ Rails . logger . warn ( "**WARNING** #{ msg } " )
174
183
self . generated_component_packs_loading_strategy = :sync
175
184
elsif generated_component_packs_loading_strategy == :async
176
- msg = <<~MSG
177
- **ERROR** ReactOnRails: Your current version of #{ ReactOnRails ::PackerUtils . packer_type . upcase_first } \
178
- does not support async script loading. Please either:
179
- 1. Use :sync or :defer loading strategy instead of :async
180
- 2. Upgrade to Shakapacker v8.2.0 or above to enable async script loading
181
- MSG
182
- raise ReactOnRails ::Error , msg
185
+ raise ReactOnRails ::Error , "**ERROR** #{ msg } "
183
186
end
184
187
185
188
return if %i[ async defer sync ] . include? ( generated_component_packs_loading_strategy )
0 commit comments