Skip to content

Commit

Permalink
make rsc get the right rsc bundle path
Browse files Browse the repository at this point in the history
  • Loading branch information
AbanoubGhadban committed Jul 30, 2024
1 parent 62f19cb commit 40c89e4
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions lib/react_on_rails/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,23 @@ def self.bundle_js_file_path(bundle_name)
# a. The webpack manifest plugin would have a race condition where the same manifest.json
# is edited by both the webpack-dev-server
# b. There is no good reason to hash the server bundle name.
@server_bundle_path ||= if ReactOnRails::PackerUtils.using_packer? && bundle_name != "manifest.json"
begin
ReactOnRails::PackerUtils.bundle_js_uri_from_packer(bundle_name)
rescue Object.const_get(
ReactOnRails::PackerUtils.packer_type.capitalize
)::Manifest::MissingEntryError
File.expand_path(
File.join(ReactOnRails::PackerUtils.packer_public_output_path,
bundle_name)
)
end
else
# Default to the non-hashed name in the specified output directory, which, for legacy
# React on Rails, this is the output directory picked up by the asset pipeline.
# For Webpacker, this is the public output path defined in the webpacker.yml file.
File.join(generated_assets_full_path, bundle_name)
end
if ReactOnRails::PackerUtils.using_packer? && bundle_name != "manifest.json"
begin
ReactOnRails::PackerUtils.bundle_js_uri_from_packer(bundle_name)
rescue Object.const_get(
ReactOnRails::PackerUtils.packer_type.capitalize
)::Manifest::MissingEntryError
File.expand_path(
File.join(ReactOnRails::PackerUtils.packer_public_output_path,
bundle_name)
)
end
else
# Default to the non-hashed name in the specified output directory, which, for legacy
# React on Rails, this is the output directory picked up by the asset pipeline.
# For Webpacker, this is the public output path defined in the webpacker.yml file.
File.join(generated_assets_full_path, bundle_name)
end
end

def self.server_bundle_js_file_path
Expand All @@ -108,15 +108,15 @@ def self.server_bundle_js_file_path
return @server_bundle_path if @server_bundle_path && !Rails.env.development?

bundle_name = ReactOnRails.configuration.server_bundle_js_file
bundle_js_file_path(bundle_name)
@server_bundle_path = bundle_js_file_path(bundle_name)
end

def self.rsc_bundle_js_file_path
return @rsc_bundle_path if @rsc_bundle_path && !Rails.env.development?

# TODO: make it configurable
bundle_name = "rsc-bundle.js"
@server_bundle_path = bundle_js_file_path(bundle_name)
@rsc_bundle_path = bundle_js_file_path(bundle_name)
end

def self.running_on_windows?
Expand Down

0 comments on commit 40c89e4

Please sign in to comment.