Skip to content

Commit a377cac

Browse files
Refactor: Simplify asset path resolution for Pro RSC manifests in WebpackAssetsStatusChecker
1 parent 198eb0b commit a377cac

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

lib/react_on_rails/packer_utils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def self.bundle_js_uri_from_packer(bundle_name)
5858
is_bundle_running_on_server = bundle_name == ReactOnRails.configuration.server_bundle_js_file
5959

6060
# Check Pro RSC bundle if Pro is available
61-
if ReactOnRails::Utils.react_on_rails_pro? && defined?(ReactOnRailsPro)
61+
if ReactOnRails::Utils.react_on_rails_pro?
6262
is_bundle_running_on_server ||= (bundle_name == ReactOnRailsPro.configuration.rsc_bundle_js_file)
6363
end
6464

lib/react_on_rails/test_helper/webpack_assets_status_checker.rb

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,21 @@ def stale_generated_files(files)
4747

4848
private
4949

50+
def resolve_asset_path(bundle_name)
51+
# Check if this is a Pro RSC manifest file
52+
if ReactOnRails::Utils.react_on_rails_pro?
53+
pro_config = ReactOnRailsPro.configuration
54+
return ReactOnRailsPro::Utils.react_client_manifest_file_path if bundle_name == pro_config.react_client_manifest_file
55+
return ReactOnRailsPro::Utils.react_server_client_manifest_file_path if bundle_name == pro_config.react_server_client_manifest_file
56+
end
57+
58+
ReactOnRails::Utils.bundle_js_file_path(bundle_name)
59+
end
60+
5061
def all_compiled_assets
5162
@all_compiled_assets ||= begin
5263
webpack_generated_files = @webpack_generated_files.map do |bundle_name|
53-
# Check if this is a Pro RSC manifest file
54-
if ReactOnRails::Utils.react_on_rails_pro?
55-
pro_config = ReactOnRailsPro.configuration
56-
if bundle_name == pro_config.react_client_manifest_file
57-
ReactOnRailsPro::Utils.react_client_manifest_file_path
58-
elsif bundle_name == pro_config.react_server_client_manifest_file
59-
ReactOnRailsPro::Utils.react_server_client_manifest_file_path
60-
else
61-
ReactOnRails::Utils.bundle_js_file_path(bundle_name)
62-
end
63-
else
64-
ReactOnRails::Utils.bundle_js_file_path(bundle_name)
65-
end
64+
resolve_asset_path(bundle_name)
6665
end
6766

6867
if webpack_generated_files.present?

0 commit comments

Comments
 (0)