Skip to content

Commit 233d9a6

Browse files
committed
deprecate instead of replace
1 parent 4037425 commit 233d9a6

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Please follow the recommendations outlined at [keepachangelog.com](http://keepac
2626

2727
### Removed (Breaking Changes)
2828

29-
- Removed `defer_generated_component_packs` configuration option. You can use `generated_component_packs_loading_strategy` instead. [PR 1712](https://github.com/shakacode/react_on_rails/pull/1712) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
29+
- Deprecated `defer_generated_component_packs` configuration option. You should use `generated_component_packs_loading_strategy` instead. [PR 1712](https://github.com/shakacode/react_on_rails/pull/1712) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
3030

3131
### [15.0.0-alpha.2] - 2025-03-07
3232

docs/release-notes/15.0.0.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ Major improvements to component and store hydration:
3434

3535
### Component Hydration Changes
3636

37-
- The `defer_generated_component_packs` configuration has been removed. Use `generated_component_packs_loading_strategy` instead.
37+
- The `defer_generated_component_packs` configuration has been deprecated. Use `generated_component_packs_loading_strategy` instead.
3838
- The `generated_component_packs_loading_strategy` defaults to `:async` for Shakapacker ≥ 8.2.0 and `:sync` for Shakapacker < 8.2.0.
3939
- The `force_load` configuration now defaults to `true`.
4040
- The new default values of `generated_component_packs_loading_strategy: :async` and `force_load: true` work together to optimize component hydration. Components now hydrate as soon as their code and server-rendered HTML are available, without waiting for the full page to load. This parallel processing significantly improves time-to-interactive by eliminating the traditional waterfall of waiting for page load before beginning hydration (It's critical for streamed HTML).
4141

4242
- The previous need for deferring scripts to prevent race conditions has been eliminated due to improved hydration handling. Making scripts not defer is critical to execute the hydration scripts early before the page is fully loaded.
43-
- The `force_load` configuration make `react-on-rails` hydrate components immediately as soon as their server-rendered HTML reaches the client, without waiting for the full page load.
43+
- The `force_load` configuration makes `react-on-rails` hydrate components immediately as soon as their server-rendered HTML reaches the client, without waiting for the full page load.
4444
- If you want to keep the previous behavior, you can set `generated_component_packs_loading_strategy: :defer` or `force_load: false` in your `config/initializers/react_on_rails.rb` file.
4545
- If we want to keep the original behavior of `force_load` for only one or more components, you can set `force_load: false` in the `react_component` helper or `force_load` configuration.
4646
- Redux store support `force_load` option now and it uses `config.force_load` value as the default value. Which means that the redux store will hydrate immediately as soon as its server-side data reaches the client. You can override this behavior for individual redux stores by setting `force_load: false` in the `redux_store` helper.

lib/react_on_rails/configuration.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def self.configuration
4343
i18n_output_format: nil,
4444
components_subdirectory: nil,
4545
make_generated_server_bundle_the_entrypoint: false,
46+
defer_generated_component_packs: false,
4647
# forces the loading of React components
4748
force_load: true,
4849
# Maximum time in milliseconds to wait for client-side component registration after page load.
@@ -60,7 +61,7 @@ class Configuration
6061
:generated_assets_dirs, :generated_assets_dir, :components_subdirectory,
6162
:webpack_generated_files, :rendering_extension, :build_test_command,
6263
:build_production_command, :i18n_dir, :i18n_yml_dir, :i18n_output_format,
63-
:i18n_yml_safe_load_options,
64+
:i18n_yml_safe_load_options, :defer_generated_component_packs,
6465
:server_render_method, :random_dom_id, :auto_load_bundle,
6566
:same_bundle_for_client_and_server, :rendering_props_extension,
6667
:make_generated_server_bundle_the_entrypoint,
@@ -70,7 +71,7 @@ class Configuration
7071
# rubocop:disable Metrics/AbcSize
7172
def initialize(node_modules_location: nil, server_bundle_js_file: nil, prerender: nil,
7273
replay_console: nil, make_generated_server_bundle_the_entrypoint: nil,
73-
trace: nil, development_mode: nil,
74+
trace: nil, development_mode: nil, defer_generated_component_packs: nil,
7475
logging_on_server: nil, server_renderer_pool_size: nil,
7576
server_renderer_timeout: nil, raise_on_prerender_error: true,
7677
skip_display_none: nil, generated_assets_dirs: nil,
@@ -122,6 +123,7 @@ def initialize(node_modules_location: nil, server_bundle_js_file: nil, prerender
122123
self.components_subdirectory = components_subdirectory
123124
self.auto_load_bundle = auto_load_bundle
124125
self.make_generated_server_bundle_the_entrypoint = make_generated_server_bundle_the_entrypoint
126+
self.defer_generated_component_packs = defer_generated_component_packs
125127
self.force_load = force_load
126128
self.generated_component_packs_loading_strategy = generated_component_packs_loading_strategy
127129
end
@@ -152,9 +154,16 @@ def check_component_registry_timeout
152154
raise ReactOnRails::Error, "component_registry_timeout must be a positive integer"
153155
end
154156

157+
# rubocop:disable Metrics/CyclomaticComplexity
155158
def validate_generated_component_packs_loading_strategy
159+
# rubocop:enable Metrics/CyclomaticComplexity
156160
if PackerUtils.shakapacker_version_requirement_met?([8, 2, 0])
157161
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"
158167
elsif generated_component_packs_loading_strategy.nil?
159168
msg = <<~MSG
160169
**WARNING** ReactOnRails: Your current version of #{ReactOnRails::PackerUtils.packer_type.upcase_first} \

0 commit comments

Comments
 (0)