@@ -66,7 +66,7 @@ def self.server_bundle_path_is_http?
6666 server_bundle_js_file_path =~ %r{https?://}
6767 end
6868
69- def self . server_bundle_js_file_path
69+ def self . bundle_js_file_path ( bundle_name )
7070 # Either:
7171 # 1. Using same bundle for both server and client, so server bundle will be hashed in manifest
7272 # 2. Using a different bundle (different Webpack config), so file is not hashed, and
@@ -76,12 +76,9 @@ def self.server_bundle_js_file_path
7676 # a. The webpack manifest plugin would have a race condition where the same manifest.json
7777 # is edited by both the webpack-dev-server
7878 # b. There is no good reason to hash the server bundle name.
79- return @server_bundle_path if @server_bundle_path && !Rails . env . development?
80-
81- bundle_name = ReactOnRails . configuration . server_bundle_js_file
82- @server_bundle_path = if ReactOnRails ::PackerUtils . using_packer?
79+ @server_bundle_path ||= if ReactOnRails ::PackerUtils . using_packer? && bundle_name != "manifest.json"
8380 begin
84- bundle_js_file_path ( bundle_name )
81+ ReactOnRails :: PackerUtils . bundle_js_uri_from_packer ( bundle_name )
8582 rescue Object . const_get (
8683 ReactOnRails ::PackerUtils . packer_type . capitalize
8784 ) ::Manifest ::MissingEntryError
@@ -91,19 +88,35 @@ def self.server_bundle_js_file_path
9188 )
9289 end
9390 else
94- bundle_js_file_path ( bundle_name )
91+ # Default to the non-hashed name in the specified output directory, which, for legacy
92+ # React on Rails, this is the output directory picked up by the asset pipeline.
93+ # For Webpacker, this is the public output path defined in the webpacker.yml file.
94+ File . join ( generated_assets_full_path , bundle_name )
9595 end
9696 end
9797
98- def self . bundle_js_file_path ( bundle_name )
99- if ReactOnRails ::PackerUtils . using_packer? && bundle_name != "manifest.json"
100- ReactOnRails ::PackerUtils . bundle_js_uri_from_packer ( bundle_name )
101- else
102- # Default to the non-hashed name in the specified output directory, which, for legacy
103- # React on Rails, this is the output directory picked up by the asset pipeline.
104- # For Shakapacker, this is the public output path defined in the (shaka/web)packer.yml file.
105- File . join ( generated_assets_full_path , bundle_name )
106- end
98+ def self . server_bundle_js_file_path
99+ # Either:
100+ # 1. Using same bundle for both server and client, so server bundle will be hashed in manifest
101+ # 2. Using a different bundle (different Webpack config), so file is not hashed, and
102+ # bundle_js_path will throw so the default path is used without a hash.
103+ # 3. The third option of having the server bundle hashed and a different configuration than
104+ # the client bundle is not supported for 2 reasons:
105+ # a. The webpack manifest plugin would have a race condition where the same manifest.json
106+ # is edited by both the webpack-dev-server
107+ # b. There is no good reason to hash the server bundle name.
108+ return @server_bundle_path if @server_bundle_path && !Rails . env . development?
109+
110+ bundle_name = ReactOnRails . configuration . server_bundle_js_file
111+ bundle_js_file_path ( bundle_name )
112+ end
113+
114+ def self . rsc_bundle_js_file_path
115+ return @rsc_bundle_path if @rsc_bundle_path && !Rails . env . development?
116+
117+ # TODO: make it configurable
118+ bundle_name = "rsc-bundle.js"
119+ @server_bundle_path = bundle_js_file_path ( bundle_name )
107120 end
108121
109122 def self . running_on_windows?
0 commit comments