Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Changes since the last non-beta release.
#### Bug Fixes

- **Doctor rake task**: Fixed LoadError in `rake react_on_rails:doctor` when using packaged gem. The task was trying to require excluded `rakelib/task_helpers` file. [PR 1795](https://github.com/shakacode/react_on_rails/pull/1795)
- **Shakapacker version requirements**: Fixed inconsistent version requirements between basic pack generation (6.5.1+) and advanced auto-registration features (7.0.0+). Added backward compatibility for users on Shakapacker 6.5.1-6.9.x while providing clear upgrade guidance for advanced features. Added new constants `MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_REGISTRATION` and improved version checking performance with caching. [PR 1798](https://github.com/shakacode/react_on_rails/pull/1798)

### [16.0.1-rc.0] - 2025-09-19

Expand Down
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
15 changes: 15 additions & 0 deletions docs/guides/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,19 @@ ReactOnRails.configure do |config|
# `render_component` and `render_component_hash` view helper methods can
# auto-load the bundle for the generated component, to avoid having to specify the
# bundle manually for each view with the component.
#
# SHAKAPACKER VERSION REQUIREMENTS:
# - Basic pack generation: Shakapacker 6.5.1+
# - Advanced auto-registration with nested entries: Shakapacker 7.0.0+
# - Async loading support: Shakapacker 8.2.0+
#
# Feature Compatibility Matrix:
# | Shakapacker Version | Basic Pack Generation | Auto-Registration | Nested Entries | Async Loading |
# |-------------------|----------------------|-------------------|----------------|---------------|
# | 6.5.1 - 6.9.x | ✅ Yes | ❌ No | ❌ No | ❌ No |
# | 7.0.0 - 8.1.x | ✅ Yes | ✅ Yes | ✅ Yes | ❌ No |
# | 8.2.0+ | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
#
################################################################################
# components_subdirectory is the name of the subdirectory matched to detect and register components automatically
# The default is nil. You can enable the feature by updating it in the next line.
Expand All @@ -205,6 +218,8 @@ ReactOnRails.configure do |config|
# Default is false.
# The default can be overridden as an option in calls to view helpers
# `render_component` and `render_component_hash`. You may set to true to change the default to auto loading.
# NOTE: Requires Shakapacker 6.5.1+ for basic functionality, 7.0.0+ for full auto-registration features.
# See version requirements matrix above for complete feature compatibility.
config.auto_load_bundle = false

# Default is false
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
84 changes: 37 additions & 47 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,12 +198,19 @@ 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.raise_nested_entries_disabled unless ReactOnRails::PackerUtils.nested_entries?
# Check basic pack generation support for auto_load_bundle
ReactOnRails::PackerUtils.raise_shakapacker_version_incompatible_for_basic_pack_generation unless
ReactOnRails::PackerUtils.supports_basic_pack_generation?

# Additional checks for advanced features requiring nested entries
if ReactOnRails::PackerUtils.supports_auto_registration?
ReactOnRails::PackerUtils.raise_nested_entries_disabled unless ReactOnRails::PackerUtils.nested_entries?
else
# Warn users about missing advanced features but don't block basic functionality
min_version = ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_REGISTRATION
Rails.logger.warn("React on Rails: Basic pack generation enabled. " \
"Upgrade to Shakapacker #{min_version}+ for advanced auto-registration features.")
end
end

def adjust_precompile_task
Expand All @@ -221,8 +228,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,23 +244,22 @@ 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}
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
value for "generated_assets_dir" from your config/initializers/react_on_rails.rb file.
Configuration mismatch in config/initializers/react_on_rails.rb:

Your generated_assets_dir setting (#{generated_assets_dir}) doesn't match
Shakapacker's public_output_path (#{packer_public_output_path}).

Remove the generated_assets_dir configuration and let Shakapacker manage the output path.
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.

[nitpick] The error message could be more helpful by specifying the exact file paths being compared and suggesting specific configuration steps.

Suggested change
Your generated_assets_dir setting (#{generated_assets_dir}) doesn't match
Shakapacker's public_output_path (#{packer_public_output_path}).
Remove the generated_assets_dir configuration and let Shakapacker manage the output path.
Your generated_assets_dir setting:
#{File.expand_path(generated_assets_dir)}
does not match Shakapacker's public_output_path:
#{packer_public_output_path}
To resolve this:
- Remove or update the `generated_assets_dir` configuration in config/initializers/react_on_rails.rb.
- Let Shakapacker manage the output path via its `public_output_path` setting (see config/webpacker.yml or config/shakapacker.yml).
For more information, see the React on Rails and Shakapacker documentation.

Copilot uses AI. Check for mistakes.
MSG
raise ReactOnRails::Error, msg
end
Expand All @@ -272,36 +278,22 @@ 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}"
# When using Shakapacker, don't set a default generated_assets_dir since
# Shakapacker manages its own public_output_path configuration
# This prevents configuration mismatches between ReactOnRails and Shakapacker
Rails.logger.warn "ReactOnRails: No generated_assets_dir specified, using Shakapacker public_output_path"
end

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

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
packer_public_output_path = ReactOnRails::PackerUtils.packer_public_output_path
Rails.logger.warn "You specified generated_assets_dirs in `config/initializers/react_on_rails.rb` " \
"with Shakapacker. Remove this configuration as the output path is automatically " \
"determined by `public_output_path` in shakapacker.yml " \
"(currently: #{packer_public_output_path})."
end

def ensure_webpack_generated_files_exists
Expand Down Expand Up @@ -333,17 +325,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
68 changes: 35 additions & 33 deletions lib/react_on_rails/packer_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,14 @@

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
@packer ||= begin
require "shakapacker"
::Shakapacker
end
end

def self.dev_server_running?
return false unless using_packer?

packer.dev_server.running?
end

Expand All @@ -38,7 +19,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 @@ -53,7 +33,21 @@ def self.shakapacker_version_as_array
end

def self.shakapacker_version_requirement_met?(required_version)
Gem::Version.new(shakapacker_version) >= Gem::Version.new(required_version)
@version_checks ||= {}
@version_checks[required_version] ||= Gem::Version.new(shakapacker_version) >= Gem::Version.new(required_version)
Comment on lines +31 to +32
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 @version_checks class variable is not thread-safe. In a multi-threaded environment, concurrent access could lead to race conditions. Consider using a thread-safe alternative like Concurrent::Hash or adding proper synchronization.

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 for @version_checks

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

Todo List:

  • Read the packer_utils.rb file to understand the context
  • Analyze the thread safety implications
  • Provide assessment and recommendation

Analysis

The @version_checks instance variable is used as a cache for version comparisons:

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

Assessment

This is NOT a real concern in practice for React on Rails. Here's why:

  1. Rails Context: This code runs during Rails initialization and configuration setup, which happens in a single-threaded context before any request handling begins. The version checks are performed during:

    • Rails boot/initialization
    • Configuration validation
    • Asset precompilation
  2. Immutable Data: The cached values are boolean results of version comparisons. Once a version is checked, the result never changes during the application lifecycle since gem versions don't change at runtime.

  3. Read-heavy Pattern: After initialization, this becomes essentially read-only data. Even if multiple threads read simultaneously after initialization, they would all compute the same boolean result.

  4. Worst Case: In the extremely unlikely event of a race condition during initialization (which shouldn't happen in Rails), the worst outcome would be redundant computation of the same boolean value - not data corruption or incorrect results.

Recommendation

No action needed. The current implementation is safe for its intended use in Rails applications. Adding thread synchronization (like Mutex or Concurrent::Hash) would:

  • Add unnecessary complexity
  • Introduce performance overhead
  • Provide no practical benefit given the initialization-time usage pattern

The code is appropriate as-is for the React on Rails gem's architecture and usage patterns.

end

def self.supports_async_loading?
shakapacker_version_requirement_met?("8.2.0")
end

def self.supports_basic_pack_generation?
shakapacker_version_requirement_met?(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION)
end

def self.supports_auto_registration?
min_version = ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_REGISTRATION
packer.config.respond_to?(:nested_entries?) && shakapacker_version_requirement_met?(min_version)
end

# This returns either a URL for the webpack-dev-server, non-server bundle or
Expand Down Expand Up @@ -93,9 +87,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 +115,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,18 +141,28 @@ 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

raise ReactOnRails::Error, msg
end

def self.raise_shakapacker_version_incompatible_for_autobundling
msg = <<~MSG
**ERROR** ReactOnRails: Please upgrade Shakapacker to version #{ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_REGISTRATION} or \
above to use the automated bundle generation feature (which requires nested_entries support). \
The currently installed version is #{ReactOnRails::PackerUtils.shakapacker_version}. \
Basic pack generation requires Shakapacker #{ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION} or above.
MSG

raise ReactOnRails::Error, msg
end

def self.raise_shakapacker_version_incompatible_for_basic_pack_generation
msg = <<~MSG
**ERROR** ReactOnRails: Please upgrade Shakapacker to version #{ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION} or \
above to use the automated bundle generation feature. The currently installed version is \
#{ReactOnRails::PackerUtils.shakapacker_version}.
above to use basic pack generation features. The currently installed version is #{ReactOnRails::PackerUtils.shakapacker_version}.
MSG

raise ReactOnRails::Error, msg
Expand Down
2 changes: 2 additions & 0 deletions lib/react_on_rails/packs_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class PacksGenerator
CONTAINS_CLIENT_OR_SERVER_REGEX = /\.(server|client)($|\.)/
COMPONENT_EXTENSIONS = /\.(jsx?|tsx?)$/
MINIMUM_SHAKAPACKER_VERSION = "6.5.1"
# Auto-registration requires nested_entries support which was added in 7.0.0
MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_REGISTRATION = "7.0.0"

def self.instance
@instance ||= PacksGenerator.new
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 auto-registration (nested entries)")
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
Loading
Loading