Skip to content

Commit 92b58ea

Browse files
Update changelog and configuration to reflect breaking changes and enhancements
- Added a breaking change note regarding the removal of `generated_assets_dirs` configuration, emphasizing the transition to Shakapacker for asset path management. - Updated documentation in configuration.md to clarify the purpose of `components_subdirectory` for automatic component registration. - Refactored version constants for Shakapacker compatibility, ensuring consistent terminology for auto-bundling features. These changes improve clarity and guide users through the updated configuration requirements.
1 parent a9aff90 commit 92b58ea

File tree

7 files changed

+44
-59
lines changed

7 files changed

+44
-59
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ After a release, please make sure to run `bundle exec rake update_changelog`. Th
2323

2424
Changes since the last non-beta release.
2525

26+
#### Breaking Changes
27+
28+
- **Removed `generated_assets_dirs` configuration**: The legacy `config.generated_assets_dirs` option is no longer supported and will raise an error if used. Since Shakapacker is now required, asset paths are automatically determined from `shakapacker.yml` configuration. Remove any `config.generated_assets_dirs` from your `config/initializers/react_on_rails.rb` file. Use `public_output_path` in `config/shakapacker.yml` to customize asset output location instead. [PR 1798](https://github.com/shakacode/react_on_rails/pull/1798)
29+
2630
#### New Features
2731

2832
- **Server Bundle Security**: Added new configuration options for enhanced server bundle security and organization:
@@ -54,6 +58,7 @@ Changes since the last non-beta release.
5458
#### Bug Fixes
5559

5660
- **Non-Packer Environment Compatibility**: Fixed potential NoMethodError when using bundle path resolution in environments without Shakapacker
61+
- **Shakapacker version requirements**: Fixed inconsistent version requirements between basic pack generation (6.5.1+) and advanced auto-bundling 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. Added new constants `MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_BUNDLING` and improved version checking performance with caching. [PR 1798](https://github.com/shakacode/react_on_rails/pull/1798)
5762

5863
### [16.0.1-rc.2] - 2025-09-20
5964

docs/guides/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ ReactOnRails.configure do |config|
254254
# | 8.2.0+ | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
255255
#
256256
################################################################################
257-
# components_subdirectory is the name of the subdirectory matched to detect components for auto-bundle-loading
257+
# components_subdirectory is the name of the subdirectory matched to detect and register components automatically
258258
# The default is nil. You can enable the feature by updating it in the next line.
259259
config.components_subdirectory = nil
260260
# Change to a value like this example to enable this feature

lib/react_on_rails/configuration.rb

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ def setup_config_values
144144
ensure_webpack_generated_files_exists
145145
configure_generated_assets_dirs_deprecation
146146
configure_skip_display_none_deprecation
147-
ensure_generated_assets_dir_present
148147
check_server_render_method_is_only_execjs
149148
error_if_using_packer_and_generated_assets_dir_not_match_public_output_path
150149
# check_deprecated_settings
@@ -224,23 +223,17 @@ def validate_enforce_private_server_bundles
224223
"the public directory. Please set it to a directory outside of public."
225224
end
226225

227-
def check_autobundling_requirements
228-
raise_missing_components_subdirectory if auto_load_bundle && !components_subdirectory.present?
229-
return unless components_subdirectory.present?
230-
231-
# Check basic pack generation support for auto_load_bundle
226+
def check_minimum_shakapacker_version
232227
ReactOnRails::PackerUtils.raise_shakapacker_version_incompatible_for_basic_pack_generation unless
233228
ReactOnRails::PackerUtils.supports_basic_pack_generation?
229+
end
234230

235-
# Additional checks for advanced features requiring nested entries
236-
if ReactOnRails::PackerUtils.supports_autobundling?
237-
ReactOnRails::PackerUtils.raise_nested_entries_disabled unless ReactOnRails::PackerUtils.nested_entries?
238-
else
239-
# Warn users about missing advanced features but don't block basic functionality
240-
min_version = ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_REGISTRATION
241-
Rails.logger.warn("React on Rails: Basic pack generation enabled. " \
242-
"Upgrade to Shakapacker #{min_version}+ for advanced auto-registration features.")
243-
end
231+
def check_autobundling_requirements
232+
raise_missing_components_subdirectory unless components_subdirectory.present?
233+
234+
ReactOnRails::PackerUtils.raise_shakapacker_version_incompatible_for_autobundling unless
235+
ReactOnRails::PackerUtils.supports_autobundling?
236+
ReactOnRails::PackerUtils.raise_nested_entries_disabled unless ReactOnRails::PackerUtils.nested_entries?
244237
end
245238

246239
def adjust_precompile_task
@@ -280,15 +273,15 @@ def error_if_using_packer_and_generated_assets_dir_not_match_public_output_path
280273

281274
if File.expand_path(generated_assets_dir) == packer_public_output_path.to_s
282275
Rails.logger.warn("You specified generated_assets_dir in `config/initializers/react_on_rails.rb` " \
283-
"with shakapacker. " \
276+
"with Shakapacker. " \
284277
"Remove this line from your configuration file.")
285278
else
286279
msg = <<~MSG
287-
Configuration mismatch in config/initializers/react_on_rails.rb:
288-
289-
Your generated_assets_dir setting (#{generated_assets_dir}) does not match the value for public_output_path (#{packer_public_output_path}).
290-
291-
Remove the generated_assets_dir configuration and let Shakapacker manage the output path.
280+
Error configuring /config/initializers/react_on_rails.rb: You are using Shakapacker
281+
and your specified value for generated_assets_dir = #{generated_assets_dir}
282+
that does not match the value for public_output_path specified in
283+
shakapacker.yml = #{packer_public_output_path}. You should remove the configuration
284+
value for "generated_assets_dir" from your config/initializers/react_on_rails.rb file.
292285
MSG
293286
raise ReactOnRails::Error, msg
294287
end
@@ -306,23 +299,20 @@ def check_server_render_method_is_only_execjs
306299
raise ReactOnRails::Error, msg
307300
end
308301

309-
def ensure_generated_assets_dir_present
310-
return if generated_assets_dir.present?
311-
312-
# When using Shakapacker, don't set a default generated_assets_dir since
313-
# Shakapacker manages its own public_output_path configuration
314-
# This prevents configuration mismatches between ReactOnRails and Shakapacker
315-
Rails.logger.warn "ReactOnRails: No generated_assets_dir specified, using Shakapacker public_output_path"
316-
end
317-
318302
def configure_generated_assets_dirs_deprecation
319303
return if generated_assets_dirs.blank?
320304

321305
packer_public_output_path = ReactOnRails::PackerUtils.packer_public_output_path
322-
Rails.logger.warn "You specified generated_assets_dirs in `config/initializers/react_on_rails.rb` " \
323-
"with Shakapacker. Remove this configuration as the output path is automatically " \
324-
"determined by `public_output_path` in shakapacker.yml " \
325-
"(currently: #{packer_public_output_path})."
306+
307+
msg = <<~MSG
308+
ReactOnRails Configuration Error: The 'generated_assets_dirs' configuration option is no longer supported.
309+
Since Shakapacker is now required, asset paths are automatically determined from your shakapacker.yml configuration.
310+
Please remove 'config.generated_assets_dirs' from your config/initializers/react_on_rails.rb file.
311+
Assets will be loaded from: #{packer_public_output_path}
312+
If you need to customize the output path, configure it in config/shakapacker.yml under 'public_output_path'.
313+
MSG
314+
315+
raise ReactOnRails::Error, msg
326316
end
327317

328318
def ensure_webpack_generated_files_exists

lib/react_on_rails/packer_utils.rb

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def self.supports_basic_pack_generation?
4141
end
4242

4343
def self.supports_autobundling?
44-
min_version = ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_REGISTRATION
44+
min_version = ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_BUNDLING
4545
::Shakapacker.config.respond_to?(:nested_entries?) && shakapacker_version_requirement_met?(min_version)
4646
end
4747

@@ -115,7 +115,7 @@ def self.check_manifest_not_cached
115115
msg = <<-MSG.strip_heredoc
116116
ERROR: you have enabled cache_manifest in the #{Rails.env} env when using the
117117
ReactOnRails::TestHelper.configure_rspec_to_compile_assets helper
118-
To fix this: edit your config/shaka::Shakapacker.yml file and set cache_manifest to false for test.
118+
To fix this: edit your config/shakapacker.yml file and set cache_manifest to false for test.
119119
MSG
120120
puts wrap_message(msg)
121121
exit!
@@ -135,8 +135,8 @@ def self.webpack_assets_status_checker
135135

136136
def self.raise_nested_entries_disabled
137137
msg = <<~MSG
138-
**ERROR** ReactOnRails: `nested_entries` is configured to be disabled in shaka::Shakapacker. Please update \
139-
config/shaka::Shakapacker.yml to enable nested entries. for more information read
138+
**ERROR** ReactOnRails: `nested_entries` is configured to be disabled in shakapacker. Please update \
139+
config/shakapacker.yml to enable nested entries. for more information read
140140
https://www.shakacode.com/react-on-rails/docs/guides/file-system-based-automated-bundle-generation.md#enable-nested_entries-for-shakapacker
141141
MSG
142142

@@ -145,7 +145,7 @@ def self.raise_nested_entries_disabled
145145

146146
def self.raise_shakapacker_version_incompatible_for_autobundling
147147
msg = <<~MSG
148-
**ERROR** ReactOnRails: Please upgrade ::Shakapacker to version #{ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_REGISTRATION} or \
148+
**ERROR** ReactOnRails: Please upgrade ::Shakapacker to version #{ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_BUNDLING} or \
149149
above to use the automated bundle generation feature (which requires nested_entries support). \
150150
The currently installed version is #{ReactOnRails::PackerUtils.shakapacker_version}. \
151151
Basic pack generation requires ::Shakapacker #{ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION} or above.
@@ -162,15 +162,5 @@ def self.raise_shakapacker_version_incompatible_for_basic_pack_generation
162162

163163
raise ReactOnRails::Error, msg
164164
end
165-
166-
def self.raise_shakapacker_not_installed
167-
msg = <<~MSG
168-
**ERROR** ReactOnRails: Missing ::Shakapacker gem. Please upgrade to use ::Shakapacker \
169-
#{ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION} or above to use the \
170-
automated bundle generation feature.
171-
MSG
172-
173-
raise ReactOnRails::Error, msg
174-
end
175165
end
176166
end

lib/react_on_rails/packs_generator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class PacksGenerator
1010
COMPONENT_EXTENSIONS = /\.(jsx?|tsx?)$/
1111
MINIMUM_SHAKAPACKER_VERSION = "6.5.1"
1212
# Auto-registration requires nested_entries support which was added in 7.0.0
13-
MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_REGISTRATION = "7.0.0"
13+
MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_BUNDLING = "7.0.0"
1414

1515
def self.instance
1616
@instance ||= PacksGenerator.new
@@ -166,7 +166,7 @@ def generated_server_pack_file_content
166166

167167
def add_generated_pack_to_server_bundle
168168
return if ReactOnRails.configuration.make_generated_server_bundle_the_entrypoint
169-
return if ReactOnRails.configuration.server_bundle_js_file.empty?
169+
return if ReactOnRails.configuration.server_bundle_js_file.blank?
170170

171171
relative_path_to_generated_server_bundle = relative_path(server_bundle_entrypoint,
172172
generated_server_bundle_file_path)

lib/react_on_rails/system_checker.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,10 +622,10 @@ def report_shakapacker_version_with_threshold
622622
Gem::Version.new(version)
623623

624624
if ReactOnRails::PackerUtils.supports_autobundling?
625-
add_success("✅ Shakapacker #{version} (supports React on Rails auto-registration)")
625+
add_success("✅ Shakapacker #{version} (supports React on Rails auto-bundling)")
626626
else
627627
add_warning("⚠️ Shakapacker #{version} - Version 7.0+ with nested_entries support needed " \
628-
"for React on Rails auto-registration")
628+
"for React on Rails auto-bundling")
629629
end
630630
rescue ArgumentError
631631
# Fallback for invalid version strings

spec/react_on_rails/packer_utils_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,23 @@ module ReactOnRails
118118
it "returns true when ::Shakapacker >= 7.0.0 with nested_entries support" do
119119
allow(mock_config).to receive(:respond_to?).with(:nested_entries?).and_return(true)
120120
allow(described_class).to receive(:shakapacker_version_requirement_met?)
121-
.with(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_REGISTRATION).and_return(true)
121+
.with(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_BUNDLING).and_return(true)
122122

123123
expect(described_class.supports_autobundling?).to be(true)
124124
end
125125

126126
it "returns false when ::Shakapacker < 7.0.0" do
127127
allow(mock_config).to receive(:respond_to?).with(:nested_entries?).and_return(true)
128128
allow(described_class).to receive(:shakapacker_version_requirement_met?)
129-
.with(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_REGISTRATION).and_return(false)
129+
.with(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_BUNDLING).and_return(false)
130130

131131
expect(described_class.supports_autobundling?).to be(false)
132132
end
133133

134134
it "returns false when nested_entries method is not available" do
135135
allow(mock_config).to receive(:respond_to?).with(:nested_entries?).and_return(false)
136136
allow(described_class).to receive(:shakapacker_version_requirement_met?)
137-
.with(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_REGISTRATION).and_return(true)
137+
.with(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_BUNDLING).and_return(true)
138138

139139
expect(described_class.supports_autobundling?).to be(false)
140140
end
@@ -144,13 +144,13 @@ module ReactOnRails
144144
describe "version constants validation" do
145145
it "ensures MINIMUM_SHAKAPACKER_VERSION constants are properly defined" do
146146
expect(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION).to eq("6.5.1")
147-
expect(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_REGISTRATION).to eq("7.0.0")
147+
expect(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_BUNDLING).to eq("7.0.0")
148148
end
149149

150150
it "ensures version requirements are logically consistent" do
151151
basic_version = Gem::Version.new(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION)
152152
auto_reg_version = Gem::Version.new(
153-
ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_REGISTRATION
153+
ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_BUNDLING
154154
)
155155

156156
expect(auto_reg_version).to be >= basic_version,

0 commit comments

Comments
 (0)