Skip to content

Commit ae29eaf

Browse files
JudahmeekAbanoubGhadban
authored andcommitted
deprecate instead of replace
1 parent 99c8f66 commit ae29eaf

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Changes since the last non-beta release.
2929

3030
### Removed (Breaking Changes)
3131

32-
- 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).
32+
- 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).
3333

3434
### [15.0.0-alpha.2] - 2025-03-07
3535

docs/release-notes/15.0.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ 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).

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)