From 38edb3548bebbb679ce4a174f6f09c2a24d724a1 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 18 Nov 2025 21:58:20 -1000 Subject: [PATCH 1/4] Fix: Use respond_to? for Pro-only methods in ensure_webpack_generated_files_exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ensure_webpack_generated_files_exists method was calling rsc_bundle_js_file, react_client_manifest_file, and react_server_client_manifest_file methods that only exist in React on Rails Pro, causing NoMethodError in the open-source version. Solution: Check if methods exist before calling them using respond_to?, allowing the code to work in both open-source (where methods don't exist) and Pro (where they do exist). Fixes compatibility issue where open-source installations would fail when webpack_generated_files is empty and the configuration tries to populate it with default files. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- lib/react_on_rails/configuration.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/react_on_rails/configuration.rb b/lib/react_on_rails/configuration.rb index bff1d20bca..03fd64c237 100644 --- a/lib/react_on_rails/configuration.rb +++ b/lib/react_on_rails/configuration.rb @@ -360,13 +360,12 @@ def configure_generated_assets_dirs_deprecation def ensure_webpack_generated_files_exists return unless webpack_generated_files.empty? - self.webpack_generated_files = [ - "manifest.json", - server_bundle_js_file, - rsc_bundle_js_file, - react_client_manifest_file, - react_server_client_manifest_file - ].compact_blank + files = ["manifest.json", server_bundle_js_file] + files << rsc_bundle_js_file if respond_to?(:rsc_bundle_js_file) + files << react_client_manifest_file if respond_to?(:react_client_manifest_file) + files << react_server_client_manifest_file if respond_to?(:react_server_client_manifest_file) + + self.webpack_generated_files = files.compact_blank end def configure_skip_display_none_deprecation From 664e5142fe90b347af3d2f0961747f5023cc9a15 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 18 Nov 2025 22:31:10 -1000 Subject: [PATCH 2/4] Fix: Properly access Pro configuration methods in ensure_webpack_generated_files_exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous implementation used `respond_to?` to check for Pro-only methods (rsc_bundle_js_file, react_client_manifest_file, react_server_client_manifest_file) on the ReactOnRails::Configuration instance. However, these methods don't exist on the base Configuration class - they only exist on ReactOnRailsPro.configuration. This change follows the established pattern used in lib/react_on_rails/utils.rb:158-161 and lib/react_on_rails/packer_utils.rb:61-62 by: 1. Checking if Pro is available with ReactOnRails::Utils.react_on_rails_pro? 2. Accessing the Pro configuration object (ReactOnRailsPro.configuration) 3. Calling the Pro-specific methods on that object This ensures the code works correctly in both scenarios: - Open-source only: Pro check returns false, Pro files not added - With Pro loaded: Pro files are correctly added to webpack_generated_files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- lib/react_on_rails/configuration.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/react_on_rails/configuration.rb b/lib/react_on_rails/configuration.rb index 03fd64c237..fd66d23de8 100644 --- a/lib/react_on_rails/configuration.rb +++ b/lib/react_on_rails/configuration.rb @@ -361,9 +361,13 @@ def ensure_webpack_generated_files_exists return unless webpack_generated_files.empty? files = ["manifest.json", server_bundle_js_file] - files << rsc_bundle_js_file if respond_to?(:rsc_bundle_js_file) - files << react_client_manifest_file if respond_to?(:react_client_manifest_file) - files << react_server_client_manifest_file if respond_to?(:react_server_client_manifest_file) + + if ReactOnRails::Utils.react_on_rails_pro? + pro_config = ReactOnRailsPro.configuration + files << pro_config.rsc_bundle_js_file + files << pro_config.react_client_manifest_file + files << pro_config.react_server_client_manifest_file + end self.webpack_generated_files = files.compact_blank end From 0dc07acf356540e6088d21218fdfa6e886ad3ed3 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Wed, 19 Nov 2025 11:17:26 -1000 Subject: [PATCH 3/4] Add missing require for compact_blank in configuration.rb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds the missing `require "active_support/core_ext/enumerable"` statement that was mentioned in the PR description but was not included in the previous commit. Without this require statement, the code would fail on Rails 5.2-6.0 because compact_blank was only introduced in Rails 6.1. This gem supports Rails >= 5.2 (per react_on_rails.gemspec), so the require is necessary to ensure the method is available on older Rails versions. The compact_blank method is needed (rather than just compact) because: - server_bundle_js_file defaults to "" (empty string) - Pro config files could potentially be set to empty strings - compact_blank filters out both nil and empty/blank values 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- lib/react_on_rails/configuration.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/react_on_rails/configuration.rb b/lib/react_on_rails/configuration.rb index fd66d23de8..ef761052a0 100644 --- a/lib/react_on_rails/configuration.rb +++ b/lib/react_on_rails/configuration.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "active_support/core_ext/enumerable" + # rubocop:disable Metrics/ClassLength module ReactOnRails From 6334ed3d87afa89c4dcf6798a2def94441f08f26 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Wed, 19 Nov 2025 16:55:08 -1000 Subject: [PATCH 4/4] Add compact_blank polyfill for Rails 5.2-6.0 compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous commit added `require "active_support/core_ext/enumerable"` but this doesn't provide `compact_blank` on Rails < 6.1 because that method was only introduced in Rails 6.1. This commit adds a proper polyfill that: 1. Checks if compact_blank already exists (Rails 6.1+) 2. If not, defines it on both Enumerable and Array using reject(&:blank?) 3. Also requires "active_support/core_ext/object/blank" for the blank? method The polyfill correctly mirrors Rails 6.1+ behavior: - Removes nil, empty strings (""), whitespace strings (" ") - Removes false (since false.blank? == true in ActiveSupport) - Keeps truthy values like non-empty strings, true, numbers This ensures the gem works correctly on all supported Rails versions (>= 5.2). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- lib/react_on_rails/configuration.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/react_on_rails/configuration.rb b/lib/react_on_rails/configuration.rb index ef761052a0..506e54c31d 100644 --- a/lib/react_on_rails/configuration.rb +++ b/lib/react_on_rails/configuration.rb @@ -1,6 +1,22 @@ # frozen_string_literal: true require "active_support/core_ext/enumerable" +require "active_support/core_ext/object/blank" + +# Polyfill for compact_blank (added in Rails 6.1) to support Rails 5.2-6.0 +unless [].respond_to?(:compact_blank) + module Enumerable + def compact_blank + reject(&:blank?) + end + end + + class Array + def compact_blank + reject(&:blank?) + end + end +end # rubocop:disable Metrics/ClassLength