Skip to content

Commit 00d2670

Browse files
justin808claude
andcommitted
Add comprehensive improvements based on feedback
- Add CHANGELOG entry explaining version requirement fixes and backward compatibility - Add defensive programming with shakapacker_gem_available? check - Improve error handling for LoadError when Shakapacker gem is missing - Add comprehensive version requirements matrix in configuration documentation - Include feature compatibility table showing exactly what works with each Shakapacker version - Enhanced configuration comments with version requirement notes These improvements address all suggestions for migration guidance, defensive programming, and documentation clarity. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 943b843 commit 00d2670

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Changes since the last non-beta release.
2626
#### Bug Fixes
2727

2828
- **Doctor rake task**: Fixed LoadError in `rake react_on_rails:doctor` when using packaged gem. The task was trying to require excluded `rakelib/task_helpers` file. [PR 1795](https://github.com/shakacode/react_on_rails/pull/1795)
29+
- **Shakapacker version requirements**: Fixed inconsistent version requirements between basic pack generation (6.5.1+) and advanced auto-registration features (7.0.0+). Added backward compatibility for users on Shakapacker 6.5.1-6.9.x while providing clear upgrade guidance for advanced features. [PR 1798](https://github.com/shakacode/react_on_rails/pull/1798)
2930

3031
### [16.0.1-rc.0] - 2025-09-19
3132

docs/guides/configuration.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,19 @@ ReactOnRails.configure do |config|
195195
# `render_component` and `render_component_hash` view helper methods can
196196
# auto-load the bundle for the generated component, to avoid having to specify the
197197
# bundle manually for each view with the component.
198+
#
199+
# SHAKAPACKER VERSION REQUIREMENTS:
200+
# - Basic pack generation: Shakapacker 6.5.1+
201+
# - Advanced auto-registration with nested entries: Shakapacker 7.0.0+
202+
# - Async loading support: Shakapacker 8.2.0+
203+
#
204+
# Feature Compatibility Matrix:
205+
# | Shakapacker Version | Basic Pack Generation | Auto-Registration | Nested Entries | Async Loading |
206+
# |-------------------|----------------------|-------------------|----------------|---------------|
207+
# | 6.5.1 - 6.9.x | ✅ Yes | ❌ No | ❌ No | ❌ No |
208+
# | 7.0.0 - 8.1.x | ✅ Yes | ✅ Yes | ✅ Yes | ❌ No |
209+
# | 8.2.0+ | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
210+
#
198211
################################################################################
199212
# components_subdirectory is the name of the subdirectory matched to detect and register components automatically
200213
# The default is nil. You can enable the feature by updating it in the next line.
@@ -205,6 +218,8 @@ ReactOnRails.configure do |config|
205218
# Default is false.
206219
# The default can be overridden as an option in calls to view helpers
207220
# `render_component` and `render_component_hash`. You may set to true to change the default to auto loading.
221+
# NOTE: Requires Shakapacker 6.5.1+ for basic functionality, 7.0.0+ for full auto-registration features.
222+
# See version requirements matrix above for complete feature compatibility.
208223
config.auto_load_bundle = false
209224

210225
# Default is false

lib/react_on_rails/packer_utils.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ module PackerUtils
55
def self.packer
66
require "shakapacker"
77
::Shakapacker
8+
rescue LoadError => e
9+
raise ReactOnRails::Error, "Shakapacker gem is required but not available. Please add 'shakapacker' to your Gemfile. Error: #{e.message}"
810
end
911

1012
def self.dev_server_running?
@@ -39,12 +41,25 @@ def self.supports_async_loading?
3941
end
4042

4143
def self.supports_basic_pack_generation?
44+
return false unless shakapacker_gem_available?
45+
4246
shakapacker_version_requirement_met?(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION)
4347
end
4448

4549
def self.supports_auto_registration?
50+
return false unless shakapacker_gem_available?
51+
4652
min_version = ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_REGISTRATION
4753
packer.config.respond_to?(:nested_entries?) && shakapacker_version_requirement_met?(min_version)
54+
rescue StandardError
55+
false
56+
end
57+
58+
def self.shakapacker_gem_available?
59+
require "shakapacker"
60+
true
61+
rescue LoadError
62+
false
4863
end
4964

5065
# This returns either a URL for the webpack-dev-server, non-server bundle or

0 commit comments

Comments
 (0)