Skip to content

Commit aaad32f

Browse files
justin808claude
andcommitted
Add supports_async_loading? semantic method
Replace specific version check with semantic method that clearly indicates what feature is being checked for. This improves code readability and makes version requirements more self-documenting. - Add PackerUtils.supports_async_loading? method - Replace shakapacker_version_requirement_met?("8.2.0") with supports_async_loading? - Version requirement is now encapsulated in the semantic method 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 27644c0 commit aaad32f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/react_on_rails/configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def validate_generated_component_packs_loading_strategy
186186
1. Use :sync or :defer loading strategy instead of :async
187187
2. Upgrade to Shakapacker v8.2.0 or above to enable async script loading
188188
MSG
189-
if ReactOnRails::PackerUtils.shakapacker_version_requirement_met?("8.2.0")
189+
if ReactOnRails::PackerUtils.supports_async_loading?
190190
self.generated_component_packs_loading_strategy ||= :async
191191
elsif generated_component_packs_loading_strategy.nil?
192192
Rails.logger.warn("**WARNING** #{msg}")

lib/react_on_rails/packer_utils.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ def self.supports_autobundling?
3333
shakapacker_version_requirement_met?(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION)
3434
end
3535

36+
def self.supports_async_loading?
37+
shakapacker_version_requirement_met?("8.2.0")
38+
end
39+
3640
# This returns either a URL for the webpack-dev-server, non-server bundle or
3741
# the hashed server bundle if using the same bundle for the client.
3842
# Otherwise returns a file path.

0 commit comments

Comments
 (0)