Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a3c3391
Fix Shakapacker version requirement from 8.2.0 to 8.0.0 for basic com…
justin808 Sep 21, 2025
233b789
Simplify PackerUtils by removing legacy Webpacker compatibility code
justin808 Sep 21, 2025
339451a
Apply auto-fix corrections from RuboCop
justin808 Sep 21, 2025
0a566cd
Remove unnecessary packer_type template variable
justin808 Sep 21, 2025
759e360
Simplify autobundling requirements check using feature-based method
justin808 Sep 21, 2025
07e68db
Remove unused packer_name variable
justin808 Sep 21, 2025
7fdc7b4
Remove unnecessary Packer alias
justin808 Sep 21, 2025
30e0e6d
Fix mock objects in packer_utils_spec
justin808 Sep 21, 2025
37e54a1
Fix failing configuration tests by adding packer mocks
justin808 Sep 21, 2025
68f4baf
Fix CI failure by not setting default generated_assets_dir with Shaka…
justin808 Sep 22, 2025
1e2f03c
Fix failing tests by properly mocking Shakapacker initialization
justin808 Sep 22, 2025
c5ae0f9
Remove legacy 'without packer' test scenarios and using_packer? refer…
justin808 Sep 23, 2025
35784e9
Trigger CI to test fixes
justin808 Sep 23, 2025
bc73e88
Trigger CI after RuboCop fixes
justin808 Sep 23, 2025
a575302
Address version requirement review comments
justin808 Sep 23, 2025
943b843
Final fix for CI: String constants and RuboCop disables
justin808 Sep 23, 2025
00d2670
Add comprehensive improvements based on feedback
justin808 Sep 23, 2025
b672d92
Improve warning message clarity and remove unnecessary variable
justin808 Sep 23, 2025
27eda87
Add memoization for performance optimization
justin808 Sep 23, 2025
70b4c7d
Remove redundant shakapacker_gem_available? checks
justin808 Sep 23, 2025
5b3e5ff
Simplify supports_auto_registration? method
justin808 Sep 23, 2025
9db5190
Add performance optimizations and validation tests
justin808 Sep 23, 2025
67210ef
Fix thread safety and simplify Shakapacker packer memoization
justin808 Sep 23, 2025
da9420e
Fix error message to match test expectation
justin808 Sep 23, 2025
e038121
Improve method naming and warning message clarity
justin808 Sep 23, 2025
8d03cc6
Remove PackerUtils.packer method entirely and use Shakapacker directly
justin808 Sep 23, 2025
5d865c0
Fix remaining test failures after removing PackerUtils.packer method
justin808 Sep 23, 2025
437cec8
Trigger CI re-run after RuboCop auto-fix
justin808 Sep 23, 2025
4b932ad
Fix documentation to use bundle exec rubocop consistently
justin808 Sep 23, 2025
9ca52d1
Update CHANGELOG.md for PackerUtils.packer abstraction removal
justin808 Sep 23, 2025
8a33f7d
Add author attribution to CHANGELOG.md entry
justin808 Sep 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
react_on_rails (16.0.1.rc.0)
react_on_rails (16.0.1.rc.2)
addressable
connection_pool
execjs (~> 2.5)
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/react_on_rails/base_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def copy_base_files
base_templates = %w[config/initializers/react_on_rails.rb]
base_files.each { |file| copy_file("#{base_path}#{file}", file) }
base_templates.each do |file|
template("#{base_path}/#{file}.tt", file, { packer_type: ReactOnRails::PackerUtils.packer_type })
template("#{base_path}/#{file}.tt", file)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ ReactOnRails.configure do |config|
# to automatically refresh your webpack assets on every test run.
#
# Alternately, you can remove the `ReactOnRails::TestHelper.configure_rspec_to_compile_assets`
# and set the config/<%= config[:packer_type] %>.yml option for test to true.
config.build_test_command = "RAILS_ENV=test bin/<%= config[:packer_type] %>"
# and set the config/shakapacker.yml option for test to true.
config.build_test_command = "RAILS_ENV=test bin/shakapacker"

################################################################################
################################################################################
Expand Down
58 changes: 19 additions & 39 deletions lib/react_on_rails/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def validate_generated_component_packs_loading_strategy
1. Use :sync or :defer loading strategy instead of :async
2. Upgrade to Shakapacker v8.2.0 or above to enable async script loading
MSG
if PackerUtils.shakapacker_version_requirement_met?("8.2.0")
if PackerUtils.supports_async_loading?
self.generated_component_packs_loading_strategy ||= :async
elsif generated_component_packs_loading_strategy.nil?
Rails.logger.warn("**WARNING** #{msg}")
Expand All @@ -198,11 +198,8 @@ def check_autobundling_requirements
raise_missing_components_subdirectory if auto_load_bundle && !components_subdirectory.present?
return unless components_subdirectory.present?

ReactOnRails::PackerUtils.raise_shakapacker_not_installed unless ReactOnRails::PackerUtils.using_packer?
ReactOnRails::PackerUtils.raise_shakapacker_version_incompatible_for_autobundling unless
ReactOnRails::PackerUtils.shakapacker_version_requirement_met?(
ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION
)
ReactOnRails::PackerUtils.supports_auto_registration?
ReactOnRails::PackerUtils.raise_nested_entries_disabled unless ReactOnRails::PackerUtils.nested_entries?
end

Expand All @@ -221,8 +218,8 @@ def adjust_precompile_task
# We set it very big so that it is not used, and then clean just
# removes files older than 1 hour.
versions = 100_000
puts "Invoking task #{ReactOnRails::PackerUtils.packer_type}:clean from React on Rails"
Rake::Task["#{ReactOnRails::PackerUtils.packer_type}:clean"].invoke(versions)
puts "Invoking task shakapacker:clean from React on Rails"
Rake::Task["shakapacker:clean"].invoke(versions)
}

if Rake::Task.task_defined?("assets:precompile")
Expand All @@ -237,22 +234,20 @@ def adjust_precompile_task
end

def error_if_using_packer_and_generated_assets_dir_not_match_public_output_path
return unless ReactOnRails::PackerUtils.using_packer?

return if generated_assets_dir.blank?

packer_public_output_path = ReactOnRails::PackerUtils.packer_public_output_path

if File.expand_path(generated_assets_dir) == packer_public_output_path.to_s
Rails.logger.warn("You specified generated_assets_dir in `config/initializers/react_on_rails.rb` " \
"with #{ReactOnRails::PackerUtils.packer_type}. " \
"with shakapacker. " \
"Remove this line from your configuration file.")
else
msg = <<~MSG
Error configuring /config/initializers/react_on_rails.rb: You are using #{ReactOnRails::PackerUtils.packer_type}
Error configuring /config/initializers/react_on_rails.rb: You are using shakapacker
and your specified value for generated_assets_dir = #{generated_assets_dir}
that does not match the value for public_output_path specified in
#{ReactOnRails::PackerUtils.packer_type}.yml = #{packer_public_output_path}. You should remove the configuration
shakapacker.yml = #{packer_public_output_path}. You should remove the configuration
value for "generated_assets_dir" from your config/initializers/react_on_rails.rb file.
MSG
raise ReactOnRails::Error, msg
Expand All @@ -272,7 +267,7 @@ def check_server_render_method_is_only_execjs
end

def ensure_generated_assets_dir_present
return if generated_assets_dir.present? || ReactOnRails::PackerUtils.using_packer?
return if generated_assets_dir.present?

self.generated_assets_dir = DEFAULT_GENERATED_ASSETS_DIR
Rails.logger.warn "ReactOnRails: Set generated_assets_dir to default: #{DEFAULT_GENERATED_ASSETS_DIR}"
Expand All @@ -281,27 +276,14 @@ def ensure_generated_assets_dir_present
def configure_generated_assets_dirs_deprecation
return if generated_assets_dirs.blank?

if ReactOnRails::PackerUtils.using_packer?
packer_public_output_path = ReactOnRails::PackerUtils.packer_public_output_path
# rubocop:disable Layout/LineLength
packer_name = ReactOnRails::PackerUtils.packer_type&.upcase_first

Rails.logger.warn "Error configuring config/initializers/react_on_rails. Define neither the generated_assets_dirs nor " \
"the generated_assets_dir when using #{packer_name}. This is defined by " \
"public_output_path specified in #{ReactOnRails::PackerUtils.packer_type}.yml = #{packer_public_output_path}."
# rubocop:enable Layout/LineLength
return
end
packer_public_output_path = ReactOnRails::PackerUtils.packer_public_output_path
# rubocop:disable Layout/LineLength
packer_name = "Shakapacker"

Rails.logger.warn "[DEPRECATION] ReactOnRails: Use config.generated_assets_dir rather than " \
"generated_assets_dirs"
if generated_assets_dir.blank?
self.generated_assets_dir = generated_assets_dirs
else
Rails.logger.warn "[DEPRECATION] ReactOnRails. You have both generated_assets_dirs and " \
"generated_assets_dir defined. Define ONLY generated_assets_dir if NOT using Shakapacker " \
"and define neither if using Webpacker"
end
Rails.logger.warn "Error configuring config/initializers/react_on_rails. Define neither the generated_assets_dirs nor " \
"the generated_assets_dir when using #{packer_name}. This is defined by " \
"public_output_path specified in shakapacker.yml = #{packer_public_output_path}."
# rubocop:enable Layout/LineLength
end

def ensure_webpack_generated_files_exists
Expand Down Expand Up @@ -333,17 +315,15 @@ def raise_missing_components_subdirectory
end

def compile_command_conflict_message
packer_name = ReactOnRails::PackerUtils.packer_type.upcase_first
packer_type = ReactOnRails::PackerUtils.packer_type
<<~MSG

React on Rails and #{packer_name} error in configuration!
React on Rails and Shakapacker error in configuration!
In order to use config/react_on_rails.rb config.build_production_command,
you must edit config/#{packer_type}.yml to include this value in the default configuration:
'#{packer_type}_precompile: false'
you must edit config/shakapacker.yml to include this value in the default configuration:
'shakapacker_precompile: false'

Alternatively, remove the config/react_on_rails.rb config.build_production_command and the
default bin/#{packer_type} script will be used for assets:precompile.
default bin/shakapacker script will be used for assets:precompile.

MSG
end
Expand Down
41 changes: 13 additions & 28 deletions lib/react_on_rails/packer_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,12 @@

module ReactOnRails
module PackerUtils
def self.using_packer?
using_shakapacker_const?
end

def self.using_shakapacker_const?
return @using_shakapacker_const if defined?(@using_shakapacker_const)

@using_shakapacker_const = ReactOnRails::Utils.gem_available?("shakapacker") &&
shakapacker_version_requirement_met?("8.2.0")
end

def self.packer_type
return "shakapacker" if using_shakapacker_const?

nil
end

def self.packer
return nil unless using_packer?

require "shakapacker"
::Shakapacker
end

def self.dev_server_running?
return false unless using_packer?

packer.dev_server.running?
end

Expand All @@ -38,7 +17,6 @@ def self.dev_server_url

def self.shakapacker_version
return @shakapacker_version if defined?(@shakapacker_version)
return nil unless ReactOnRails::Utils.gem_available?("shakapacker")

@shakapacker_version = Gem.loaded_specs["shakapacker"].version.to_s
Comment on lines 16 to 18
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can now be simplified to

Suggested change
return @shakapacker_version if defined?(@shakapacker_version)
return nil unless ReactOnRails::Utils.gem_available?("shakapacker")
@shakapacker_version = Gem.loaded_specs["shakapacker"].version.to_s
@shakapacker_version ||= Gem.loaded_specs["shakapacker"].version.to_s

Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will raise a NoMethodError if the 'shakapacker' gem is not loaded, since Gem.loaded_specs['shakapacker'] will return nil. Should check if the gem is loaded before accessing .version.

Suggested change
@shakapacker_version = Gem.loaded_specs["shakapacker"].version.to_s
spec = Gem.loaded_specs["shakapacker"]
unless spec
raise ReactOnRails::Error, "Shakapacker gem is required but not loaded. Please add 'shakapacker' to your Gemfile and run bundle install."
end
@shakapacker_version = spec.version.to_s

Copilot uses AI. Check for mistakes.
end
Expand All @@ -56,6 +34,15 @@ def self.shakapacker_version_requirement_met?(required_version)
Gem::Version.new(shakapacker_version) >= Gem::Version.new(required_version)
end

def self.supports_async_loading?
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method doesn't check if Shakapacker is available before calling shakapacker_version_requirement_met?. If Shakapacker is not installed, this could cause issues. Consider adding a check for Shakapacker availability.

Suggested change
def self.supports_async_loading?
def self.shakapacker_available?
Gem.loaded_specs.key?("shakapacker")
end
def self.supports_async_loading?
return false unless shakapacker_available?

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

@claude claude bot Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude finished @justin808's task —— View job


Thread Safety Analysis of @version_checks in PackerUtils

I've reviewed the concern raised about the thread safety of @version_checks on line 37 of lib/react_on_rails/packer_utils.rb.

Analysis

The @version_checks variable is indeed an instance variable at the module level (not a class variable as mentioned in the review comment). Here's what's happening:

def self.shakapacker_version_requirement_met?(required_version)
  @version_checks ||= {}
  @version_checks[required_version] ||= Gem::Version.new(shakapacker_version) >= Gem::Version.new(required_version)
end

Is This a Real Concern?

In practice, this is not a significant issue for React on Rails for the following reasons:

  1. Rails initialization context: This method is primarily called during Rails initialization and configuration setup, which happens in a single-threaded context before the application starts handling requests.

  2. Immutable results: The version check results are deterministic and immutable - the same version comparison will always yield the same result within a single Ruby process.

  3. Read-heavy pattern: After initialization, these values are only read, not written. The worst-case scenario in a race condition would be duplicate computation of the same result, not data corruption.

  4. No state mutation: The values stored are simple booleans that don't change once computed.

Potential Issues (Theoretical)

While unlikely to cause problems in practice, theoretically there could be:

  • Memory visibility issues: Without proper synchronization, one thread might not see updates made by another thread
  • Duplicate computation: Multiple threads could compute the same version check simultaneously (minor performance impact)

Recommendation

Given the usage pattern of this code (initialization-time checks), I don't believe this needs immediate fixing. However, if you want to be absolutely correct about thread safety, you have a few options:

  1. Option 1: Use a mutex (overly cautious for this use case):
MUTEX = Mutex.new
def self.shakapacker_version_requirement_met?(required_version)
  MUTEX.synchronize do
    @version_checks ||= {}
    @version_checks[required_version] ||= Gem::Version.new(shakapacker_version) >= Gem::Version.new(required_version)
  end
end
  1. Option 2: Use Concurrent::Hash (adds a dependency):
require 'concurrent-ruby'
@version_checks = Concurrent::Hash.new
  1. Option 3: Leave as-is (recommended) - The current implementation is pragmatic and sufficient for the actual usage patterns in Rails applications.

Verdict

This is a valid observation from a strict thread-safety perspective, but it's not a practical concern for this codebase. The code is safe in its actual usage context (Rails initialization). I would recommend leaving it as-is unless you're building a highly concurrent system that needs to check versions dynamically at runtime (which doesn't appear to be the case).

Todo List:

  • Read packer_utils.rb to understand the context
  • Analyze the thread safety concern about @version_checks
  • Provide review feedback on whether this needs fixing

shakapacker_version_requirement_met?("8.2.0")
end

def self.supports_auto_registration?
packer.config.respond_to?(:nested_entries?) &&
shakapacker_version_requirement_met?("7.0.0")
end
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method calls packer.config.respond_to?(:nested_entries?) but packer could return nil if Shakapacker is not available, causing a NoMethodError. Add a nil check for packer before accessing its config.

Copilot uses AI. Check for mistakes.

# This returns either a URL for the webpack-dev-server, non-server bundle or
# the hashed server bundle if using the same bundle for the client.
# Otherwise returns a file path.
Expand Down Expand Up @@ -93,9 +80,7 @@ def self.asset_uri_from_packer(asset_name)
end

def self.precompile?
return ::Shakapacker.config.shakapacker_precompile? if using_shakapacker_const?

false
::Shakapacker.config.shakapacker_precompile?
end

def self.packer_source_path
Expand Down Expand Up @@ -123,12 +108,12 @@ def self.packer_source_path_explicit?
end

def self.check_manifest_not_cached
return unless using_packer? && packer.config.cache_manifest?
return unless packer.config.cache_manifest?

msg = <<-MSG.strip_heredoc
ERROR: you have enabled cache_manifest in the #{Rails.env} env when using the
ReactOnRails::TestHelper.configure_rspec_to_compile_assets helper
To fix this: edit your config/#{packer_type}.yml file and set cache_manifest to false for test.
To fix this: edit your config/shakapacker.yml file and set cache_manifest to false for test.
MSG
puts wrap_message(msg)
exit!
Expand All @@ -149,7 +134,7 @@ def self.webpack_assets_status_checker
def self.raise_nested_entries_disabled
msg = <<~MSG
**ERROR** ReactOnRails: `nested_entries` is configured to be disabled in shakapacker. Please update \
config/#{packer_type}.yml to enable nested entries. for more information read
config/shakapacker.yml to enable nested entries. for more information read
https://www.shakacode.com/react-on-rails/docs/guides/file-system-based-automated-bundle-generation.md#enable-nested_entries-for-shakapacker
MSG

Expand Down
9 changes: 4 additions & 5 deletions lib/react_on_rails/system_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -618,14 +618,13 @@ def report_shakapacker_version_with_threshold
version = shakapacker_match[1].strip

begin
# Use proper semantic version comparison
version_obj = Gem::Version.new(version)
threshold_version = Gem::Version.new("8.2")
# Validate version string format
Gem::Version.new(version)

if version_obj >= threshold_version
if ReactOnRails::PackerUtils.supports_auto_registration?
add_success("✅ Shakapacker #{version} (supports React on Rails auto-registration)")
else
add_warning("⚠️ Shakapacker #{version} - Version 8.2+ needed for React on Rails auto-registration")
add_warning("⚠️ Shakapacker #{version} - Version 7.0+ needed for React on Rails auto-registration")
end
rescue ArgumentError
# Fallback for invalid version strings
Expand Down
5 changes: 2 additions & 3 deletions lib/react_on_rails/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ def self.ensure_assets_compiled(webpack_assets_status_checker: nil,
puts
@printed_once = true

if ReactOnRails::PackerUtils.using_packer? &&
ReactOnRails::Utils.using_packer_source_path_is_not_defined_and_custom_node_modules?
if ReactOnRails::Utils.using_packer_source_path_is_not_defined_and_custom_node_modules?
msg = <<-MSG.strip_heredoc
WARNING: Define config/#{ReactOnRails::PackerUtils.packer_type}.yml to include sourcePath to configure
WARNING: Define config/shakapacker.yml to include sourcePath to configure
the location of your JavaScript source for React on Rails.
Default location of #{source_path} is used.
MSG
Expand Down
2 changes: 1 addition & 1 deletion lib/react_on_rails/test_helper/webpack_assets_compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def compile_assets

React on Rails is aborting your test run

If you wish to use the config/#{ReactOnRails::PackerUtils.packer_type}.yml compile option for tests
If you wish to use the config/shakapacker.yml compile option for tests
them remove your call to the ReactOnRails test helper.
MSG
puts Rainbow(msg).red
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ def stale_generated_webpack_files
end

def stale_generated_files(files)
manifest_needed = ReactOnRails::PackerUtils.using_packer? &&
!ReactOnRails::PackerUtils.manifest_exists?
manifest_needed = !ReactOnRails::PackerUtils.manifest_exists?

return ["manifest.json"] if manifest_needed

Expand Down
38 changes: 11 additions & 27 deletions lib/react_on_rails/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require "active_support/core_ext/string"

module ReactOnRails
module Utils # rubocop:disable Metrics/ModuleLength
module Utils
TRUNCATION_FILLER = "\n... TRUNCATED #{
Rainbow('To see the full output, set FULL_TEXT_ERRORS=true.').red
} ...\n".freeze
Expand Down Expand Up @@ -78,22 +78,20 @@ 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.
if ReactOnRails::PackerUtils.using_packer? && bundle_name != "manifest.json"
if bundle_name == "manifest.json"
# 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 Shakapacker, this is the public output path defined in the (shaka/web)packer.yml file.
Comment on lines +82 to +84
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic flow has been inverted but the comment still references legacy React on Rails behavior. Since Shakapacker is now required, the comment should be updated to reflect the current reality.

Suggested change
# 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 Shakapacker, this is the public output path defined in the (shaka/web)packer.yml file.
# Default to the non-hashed name in the output directory as defined by Shakapacker's
# public output path in the (shaka/web)packer.yml file.
# Legacy React on Rails behavior is no longer supported; Shakapacker is now required.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

@claude claude bot Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude finished @justin808's task —— View job


I'll analyze this and get back to you.

File.join(generated_assets_full_path, bundle_name)
else
begin
ReactOnRails::PackerUtils.bundle_js_uri_from_packer(bundle_name)
rescue Object.const_get(
ReactOnRails::PackerUtils.packer_type.capitalize
)::Manifest::MissingEntryError
rescue Shakapacker::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 Shakapacker, this is the public output path defined in the (shaka/web)packer.yml file.
File.join(generated_assets_full_path, bundle_name)
end
end

Expand All @@ -115,11 +113,7 @@ def self.react_client_manifest_file_path
return @react_client_manifest_path if @react_client_manifest_path && !Rails.env.development?

file_name = ReactOnRails.configuration.react_client_manifest_file
@react_client_manifest_path = if ReactOnRails::PackerUtils.using_packer?
ReactOnRails::PackerUtils.asset_uri_from_packer(file_name)
else
File.join(generated_assets_full_path, file_name)
end
@react_client_manifest_path = ReactOnRails::PackerUtils.asset_uri_from_packer(file_name)
end

# React Server Manifest is generated by the server bundle.
Expand Down Expand Up @@ -161,26 +155,16 @@ def self.prepend_cd_node_modules_directory(cmd)
end

def self.source_path
if ReactOnRails::PackerUtils.using_packer?
ReactOnRails::PackerUtils.packer_source_path
else
ReactOnRails.configuration.node_modules_location
end
ReactOnRails::PackerUtils.packer_source_path
end

def self.using_packer_source_path_is_not_defined_and_custom_node_modules?
return false unless ReactOnRails::PackerUtils.using_packer?

!ReactOnRails::PackerUtils.packer_source_path_explicit? &&
ReactOnRails.configuration.node_modules_location.present?
end

def self.generated_assets_full_path
if ReactOnRails::PackerUtils.using_packer?
ReactOnRails::PackerUtils.packer_public_output_path
else
File.expand_path(ReactOnRails.configuration.generated_assets_dir)
end
ReactOnRails::PackerUtils.packer_public_output_path
end

def self.gem_available?(name)
Expand Down
4 changes: 1 addition & 3 deletions spec/dummy/spec/helpers/react_on_rails_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
require "rails_helper"
require "support/script_tag_utils"

Packer = Object.const_get(ReactOnRails::PackerUtils.packer_type.capitalize)

class PlainReactOnRailsHelper
include ReactOnRailsHelper
include ActionView::Helpers::TagHelper
end

# rubocop:disable Metrics/BlockLength
describe ReactOnRailsHelper do
include Packer::Helper
include Shakapacker::Helper

before do
allow(self).to receive(:request) {
Expand Down
Loading
Loading