react_on_rails 16.2.0.beta.13 → 16.2.0.beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6374880707520b755f43e5267321ac4f7d232ecfe277729453bc3e8e11a20b52
4
- data.tar.gz: aeaa5c89ad1bc79261749220d7398bbf6e08e09a4b462a1798b009ee5f28d93b
3
+ metadata.gz: 6b5ca1636dc0b5e46740a1b06b63346068130f3ca9f9d788f1f87446302f3c5b
4
+ data.tar.gz: dcf76fb56a9ddad5805d831be8e84e280970f17540ab405dbba2f2de45b859ea
5
5
  SHA512:
6
- metadata.gz: ed13e625adee250d6fab181e8a681d5823f624fc669df84a551502979c89ee29ac651ef369fc15bfc01c5ac35d999b0db3f792c75c1472c008a7fef151a01627
7
- data.tar.gz: b34cae839160d65ce718962f50b046f0dca24a74d9b8fffc02e2eedab5c5ca246b7b7f9c8ac2da4ffa2dba8f96312f75c0e9d1a28a353c820dca6660677f0e69
6
+ metadata.gz: cf9fe1708024f9708a3e606a1e406b48d029bdced8b4b1b66d0e89966e84f255af96d10c0bc3384c46d71af0abb587b7d5cfd8390f560ff65d84f78dc2f65a8f
7
+ data.tar.gz: ad83343dcf7969cc7cef7213d54c1e96e58f2b6b34776e6882a746a5720ba8cdf409d5580f8463882e2927b338f16849cdc5c697b4d22972855d789e47f3edf6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- react_on_rails (16.2.0.beta.13)
4
+ react_on_rails (16.2.0.beta.16)
5
5
  addressable
6
6
  connection_pool
7
7
  execjs (~> 2.5)
@@ -31,7 +31,8 @@ module ReactOnRails
31
31
 
32
32
  def add_test_related_gems_to_gemfile
33
33
  gem("rspec-rails", group: :test)
34
- gem("chromedriver-helper", group: :test)
34
+ # NOTE: chromedriver-helper was deprecated in 2019. Modern selenium-webdriver (4.x)
35
+ # and GitHub Actions have built-in driver management, so no driver helper is needed.
35
36
  gem("coveralls", require: false)
36
37
  end
37
38
 
@@ -124,4 +124,75 @@ module GeneratorHelper
124
124
  true
125
125
  end
126
126
  end
127
+
128
+ # Check if SWC is configured as the JavaScript transpiler in shakapacker.yml
129
+ #
130
+ # @return [Boolean] true if SWC is configured or should be used by default
131
+ #
132
+ # Detection logic:
133
+ # 1. If shakapacker.yml exists and specifies javascript_transpiler: parse it
134
+ # 2. For Shakapacker 9.3.0+, SWC is the default if not specified
135
+ # 3. Returns true for fresh installations (SWC is recommended default)
136
+ #
137
+ # @note This method is used to determine whether to install SWC dependencies
138
+ # (@swc/core, swc-loader) instead of Babel dependencies during generation.
139
+ #
140
+ # @note Caching: The result is memoized for the lifetime of the generator instance.
141
+ # If shakapacker.yml changes during generator execution (unlikely), the cached
142
+ # value will not update. This is acceptable since generators run quickly.
143
+ def using_swc?
144
+ return @using_swc if defined?(@using_swc)
145
+
146
+ @using_swc = detect_swc_configuration
147
+ end
148
+
149
+ private
150
+
151
+ def detect_swc_configuration
152
+ shakapacker_yml_path = File.join(destination_root, "config/shakapacker.yml")
153
+
154
+ if File.exist?(shakapacker_yml_path)
155
+ config = parse_shakapacker_yml(shakapacker_yml_path)
156
+ transpiler = config.dig("default", "javascript_transpiler")
157
+
158
+ # Explicit configuration takes precedence
159
+ return transpiler == "swc" if transpiler
160
+
161
+ # For Shakapacker 9.3.0+, SWC is the default
162
+ return shakapacker_version_9_3_or_higher?
163
+ end
164
+
165
+ # Fresh install: SWC is recommended default for Shakapacker 9.3.0+
166
+ shakapacker_version_9_3_or_higher?
167
+ end
168
+
169
+ def parse_shakapacker_yml(path)
170
+ require "yaml"
171
+ # Use safe_load_file for security (defense-in-depth, even though this is user's own config)
172
+ # permitted_classes: [Symbol] allows symbol keys which shakapacker.yml may use
173
+ # aliases: true allows YAML anchors (&default, *default) commonly used in Rails configs
174
+ YAML.safe_load_file(path, permitted_classes: [Symbol], aliases: true)
175
+ rescue ArgumentError
176
+ # Older Psych versions don't support all parameters - try without aliases
177
+ begin
178
+ YAML.safe_load_file(path, permitted_classes: [Symbol])
179
+ rescue ArgumentError
180
+ # Very old Psych - fall back to safe_load with File.read
181
+ YAML.safe_load(File.read(path), permitted_classes: [Symbol]) # rubocop:disable Style/YAMLFileRead
182
+ end
183
+ rescue StandardError
184
+ # If we can't parse the file, return empty config
185
+ {}
186
+ end
187
+
188
+ # Check if Shakapacker 9.3.0 or higher is available
189
+ # This version made SWC the default JavaScript transpiler
190
+ def shakapacker_version_9_3_or_higher?
191
+ return true unless defined?(ReactOnRails::PackerUtils)
192
+
193
+ ReactOnRails::PackerUtils.shakapacker_version_requirement_met?("9.3.0")
194
+ rescue StandardError
195
+ # If we can't determine version, assume latest (which uses SWC)
196
+ true
197
+ end
127
198
  end
@@ -99,6 +99,13 @@ module ReactOnRails
99
99
  @types/react-dom
100
100
  ].freeze
101
101
 
102
+ # SWC transpiler dependencies (for Shakapacker 9.3.0+ default transpiler)
103
+ # SWC is ~20x faster than Babel and is the default for new Shakapacker installations
104
+ SWC_DEPENDENCIES = %w[
105
+ @swc/core
106
+ swc-loader
107
+ ].freeze
108
+
102
109
  private
103
110
 
104
111
  def setup_js_dependencies
@@ -118,6 +125,8 @@ module ReactOnRails
118
125
  add_css_dependencies
119
126
  # Rspack dependencies are only added when --rspack flag is used
120
127
  add_rspack_dependencies if respond_to?(:options) && options&.rspack?
128
+ # SWC dependencies are only added when SWC is the configured transpiler
129
+ add_swc_dependencies if using_swc?
121
130
  # Dev dependencies vary based on bundler choice
122
131
  add_dev_dependencies
123
132
  end
@@ -232,6 +241,26 @@ module ReactOnRails
232
241
  MSG
233
242
  end
234
243
 
244
+ def add_swc_dependencies
245
+ puts "Installing SWC transpiler dependencies (20x faster than Babel)..."
246
+ return if add_packages(SWC_DEPENDENCIES, dev: true)
247
+
248
+ GeneratorMessages.add_warning(<<~MSG.strip)
249
+ ⚠️ Failed to add SWC dependencies.
250
+
251
+ SWC is the default JavaScript transpiler for Shakapacker 9.3.0+.
252
+ You can install them manually by running:
253
+ npm install --save-dev #{SWC_DEPENDENCIES.join(' ')}
254
+ MSG
255
+ rescue StandardError => e
256
+ GeneratorMessages.add_warning(<<~MSG.strip)
257
+ ⚠️ Error adding SWC dependencies: #{e.message}
258
+
259
+ You can install them manually by running:
260
+ npm install --save-dev #{SWC_DEPENDENCIES.join(' ')}
261
+ MSG
262
+ end
263
+
235
264
  def add_typescript_dependencies
236
265
  puts "Installing TypeScript dependencies..."
237
266
  return if add_packages(TYPESCRIPT_DEPENDENCIES, dev: true)
@@ -5,7 +5,9 @@ require "English"
5
5
  module ReactOnRails
6
6
  module GitUtils
7
7
  def self.uncommitted_changes?(message_handler, git_installed: true)
8
- return false if ENV["COVERAGE"] == "true"
8
+ # Skip check in CI environments - CI often makes temporary modifications
9
+ # (e.g., script/convert for minimum version testing) before running generators
10
+ return false if ENV["CI"] == "true" || ENV["COVERAGE"] == "true"
9
11
 
10
12
  status = `git status --porcelain`
11
13
  return false if git_installed && status&.empty?
@@ -9,11 +9,10 @@ module ReactOnRails
9
9
  class RubyEmbeddedJavaScript
10
10
  class << self
11
11
  def reset_pool
12
- options = {
12
+ @js_context_pool = ConnectionPool.new(
13
13
  size: ReactOnRails.configuration.server_renderer_pool_size,
14
14
  timeout: ReactOnRails.configuration.server_renderer_timeout
15
- }
16
- @js_context_pool = ConnectionPool.new(options) { create_js_context }
15
+ ) { create_js_context }
17
16
  end
18
17
 
19
18
  def reset_pool_if_server_bundle_was_modified
@@ -98,9 +98,12 @@ module ReactOnRails
98
98
  exitstatus: #{status.exitstatus}#{stdout_msg}#{stderr_msg}
99
99
  MSG
100
100
 
101
- puts wrap_message(msg)
102
- puts ""
103
- puts default_troubleshooting_section
101
+ # Use warn to ensure output is visible in CI logs (goes to stderr)
102
+ # and flush immediately before calling exit!
103
+ warn wrap_message(msg)
104
+ warn ""
105
+ warn default_troubleshooting_section
106
+ $stderr.flush
104
107
 
105
108
  # Rspec catches exit without! in the exit callbacks
106
109
  exit!(1)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReactOnRails
4
- VERSION = "16.2.0.beta.13"
4
+ VERSION = "16.2.0.beta.16"
5
5
  end
@@ -14,12 +14,49 @@ module ReactOnRails
14
14
  @all ||= { shakapacker_examples: [] }
15
15
  end
16
16
 
17
- attr_reader :packer_type, :name, :generator_options
17
+ # Supported React versions for compatibility testing
18
+ # Keys are major version strings, values are specific version to pin to (nil = latest)
19
+ REACT_VERSIONS = {
20
+ "16" => "16.14.0",
21
+ "17" => "17.0.2",
22
+ "18" => "18.0.0",
23
+ "19" => nil # nil means use latest (default)
24
+ }.freeze
25
+
26
+ # Supported React major versions (we test with latest patch of each)
27
+ MINIMUM_SUPPORTED_REACT_MAJOR_VERSION = "16"
28
+ LATEST_REACT_MAJOR_VERSION = "19"
29
+
30
+ # Minimum Shakapacker version for compatibility testing
31
+ MINIMUM_SHAKAPACKER_VERSION = "8.2.0"
32
+
33
+ attr_reader :packer_type, :name, :generator_options, :react_version
34
+
35
+ # Returns true if this example uses a pinned (non-latest) React version
36
+ def pinned_react_version?
37
+ !react_version.nil?
38
+ end
39
+
40
+ # Returns the actual React version string to use
41
+ def react_version_string
42
+ return nil unless react_version
43
+
44
+ REACT_VERSIONS[react_version.to_s] || react_version
45
+ end
18
46
 
19
- def initialize(packer_type: nil, name: nil, generator_options: nil)
47
+ def initialize(packer_type: nil, name: nil, generator_options: nil, react_version: nil)
20
48
  @packer_type = packer_type
21
49
  @name = name
22
50
  @generator_options = generator_options
51
+ @react_version = react_version
52
+
53
+ # Validate react_version is a known version to catch configuration errors early
54
+ if @react_version && !REACT_VERSIONS.key?(@react_version.to_s)
55
+ valid_versions = REACT_VERSIONS.keys.join(", ")
56
+ raise ArgumentError, "Invalid react_version '#{@react_version}' for example '#{name}'. " \
57
+ "Valid versions: #{valid_versions}"
58
+ end
59
+
23
60
  self.class.all[packer_type.to_sym] << self
24
61
  end
25
62
 
@@ -1,4 +1,23 @@
1
+ # Example Type Configuration for React on Rails Generator Tests
2
+ #
3
+ # CI Test Coverage:
4
+ # -----------------
5
+ # - Latest CI (all PRs): Runs shakapacker_examples_latest (React 19, Shakapacker 9.x)
6
+ # Examples: basic, basic-server-rendering, redux, redux-server-rendering
7
+ #
8
+ # - Pinned CI (master): Runs shakapacker_examples_pinned (React 16, 17, 18 with Shakapacker 8.2.0)
9
+ # Examples: basic-react16, basic-server-rendering-react16,
10
+ # basic-react17, basic-server-rendering-react17,
11
+ # basic-react18, basic-server-rendering-react18
12
+ #
13
+ # Terminology:
14
+ # - "Latest" = Current React version (19) with latest Shakapacker (9.x)
15
+ # - "Pinned" = Specific older React versions (16, 17, 18) for backward compatibility testing
16
+ #
17
+ # Note: We support React 16+ but test with latest patch of each major version.
18
+
1
19
  example_type_data:
20
+ # Latest versions (React 19, Shakapacker 9.x)
2
21
  - name: basic
3
22
  generator_options: ''
4
23
  - name: basic-server-rendering
@@ -7,3 +26,27 @@ example_type_data:
7
26
  generator_options: --redux
8
27
  - name: redux-server-rendering
9
28
  generator_options: --redux --example-server-rendering
29
+
30
+ # React 18 compatibility tests (uses Root API introduced in React 18)
31
+ - name: basic-react18
32
+ generator_options: ''
33
+ react_version: '18'
34
+ - name: basic-server-rendering-react18
35
+ generator_options: --example-server-rendering
36
+ react_version: '18'
37
+
38
+ # React 17 compatibility tests (legacy render/hydrate API)
39
+ - name: basic-react17
40
+ generator_options: ''
41
+ react_version: '17'
42
+ - name: basic-server-rendering-react17
43
+ generator_options: --example-server-rendering
44
+ react_version: '17'
45
+
46
+ # React 16 compatibility tests (oldest supported legacy API)
47
+ - name: basic-react16
48
+ generator_options: ''
49
+ react_version: '16'
50
+ - name: basic-server-rendering-react16
51
+ generator_options: --example-server-rendering
52
+ react_version: '16'
@@ -82,7 +82,10 @@ namespace :run_rspec do
82
82
  puts "Creating #{example_type.rspec_task_name} task"
83
83
  desc "Runs RSpec for #{example_type.name_pretty} only"
84
84
  task example_type.rspec_task_name_short => example_type.gen_task_name do
85
- run_tests_in(File.join(examples_dir, example_type.name)) # have to use relative path
85
+ # Use unbundled mode for pinned React version examples to ensure the example app's
86
+ # Gemfile and gem versions are used, not the parent workspace's bundle
87
+ run_tests_in(File.join(examples_dir, example_type.name),
88
+ unbundled: example_type.pinned_react_version?)
86
89
  end
87
90
  end
88
91
 
@@ -91,6 +94,52 @@ namespace :run_rspec do
91
94
  ExampleType.all[:shakapacker_examples].each { |example_type| Rake::Task[example_type.rspec_task_name].invoke }
92
95
  end
93
96
 
97
+ # Helper methods for filtering examples by React version
98
+ def latest_examples
99
+ ExampleType.all[:shakapacker_examples].reject(&:pinned_react_version?)
100
+ end
101
+
102
+ def react18_examples
103
+ ExampleType.all[:shakapacker_examples].select { |e| e.react_version == "18" }
104
+ end
105
+
106
+ def react17_examples
107
+ ExampleType.all[:shakapacker_examples].select { |e| e.react_version == "17" }
108
+ end
109
+
110
+ def react16_examples
111
+ ExampleType.all[:shakapacker_examples].select { |e| e.react_version == "16" }
112
+ end
113
+
114
+ def pinned_version_examples
115
+ ExampleType.all[:shakapacker_examples].select(&:pinned_react_version?)
116
+ end
117
+
118
+ desc "Runs Rspec for latest version example apps only (React 19, Shakapacker 9.x)"
119
+ task shakapacker_examples_latest: latest_examples.map(&:gen_task_name) do
120
+ latest_examples.each { |example_type| Rake::Task[example_type.rspec_task_name].invoke }
121
+ end
122
+
123
+ desc "Runs Rspec for React 18 example apps only (Shakapacker 8.2.0)"
124
+ task shakapacker_examples_react18: react18_examples.map(&:gen_task_name) do
125
+ react18_examples.each { |example_type| Rake::Task[example_type.rspec_task_name].invoke }
126
+ end
127
+
128
+ desc "Runs Rspec for React 17 example apps only (legacy render API)"
129
+ task shakapacker_examples_react17: react17_examples.map(&:gen_task_name) do
130
+ react17_examples.each { |example_type| Rake::Task[example_type.rspec_task_name].invoke }
131
+ end
132
+
133
+ desc "Runs Rspec for React 16 example apps only (oldest supported legacy API)"
134
+ task shakapacker_examples_react16: react16_examples.map(&:gen_task_name) do
135
+ react16_examples.each { |example_type| Rake::Task[example_type.rspec_task_name].invoke }
136
+ end
137
+
138
+ desc "Runs Rspec for all pinned version example apps (React 16, 17, and 18)"
139
+ task shakapacker_examples_pinned: pinned_version_examples.map(&:gen_task_name) do
140
+ pinned_version_examples.each { |example_type| Rake::Task[example_type.rspec_task_name].invoke }
141
+ end
142
+
94
143
  Coveralls::RakeTask.new if ENV["USE_COVERALLS"] == "TRUE"
95
144
 
96
145
  desc "run all tests no examples"
@@ -139,11 +188,23 @@ end
139
188
  # If string is passed and it's not absolute, it's converted relative to root of the gem.
140
189
  # TEST_ENV_COMMAND_NAME is used to make SimpleCov.command_name unique in order to
141
190
  # prevent a name collision. Defaults to the given directory's name.
191
+ # Options:
192
+ # :command_name - name for SimpleCov (default: dir basename)
193
+ # :rspec_args - additional rspec arguments (default: "")
194
+ # :env_vars - additional environment variables (default: "")
195
+ # :unbundled - run with unbundled_sh_in_dir for Bundler isolation (default: false)
196
+ # This is required for pinned version examples because they have different
197
+ # gem versions (e.g., Shakapacker 8.2.0) pinned in their Gemfile than the
198
+ # parent workspace (Shakapacker 9.x). Without bundle isolation, Bundler
199
+ # would inherit the parent's gem resolution and use the wrong versions.
200
+ # Latest version examples don't need this because they use the same versions
201
+ # as the parent workspace.
142
202
  def run_tests_in(dir, options = {})
143
203
  path = calc_path(dir)
144
204
 
145
205
  command_name = options.fetch(:command_name, path.basename)
146
206
  rspec_args = options.fetch(:rspec_args, "")
207
+ unbundled = options.fetch(:unbundled, false)
147
208
 
148
209
  # Build environment variables as an array for proper spacing
149
210
  env_tokens = []
@@ -152,5 +213,11 @@ def run_tests_in(dir, options = {})
152
213
  env_tokens << "COVERAGE=true" if ENV["USE_COVERALLS"]
153
214
 
154
215
  env_vars = env_tokens.join(" ")
155
- sh_in_dir(path.realpath, "#{env_vars} bundle exec rspec #{rspec_args}")
216
+ command = "#{env_vars} bundle exec rspec #{rspec_args}"
217
+
218
+ if unbundled
219
+ unbundled_sh_in_dir(path.realpath, command)
220
+ else
221
+ sh_in_dir(path.realpath, command)
222
+ end
156
223
  end
@@ -8,6 +8,7 @@
8
8
  require "yaml"
9
9
  require "rails/version"
10
10
  require "pathname"
11
+ require "json"
11
12
 
12
13
  require_relative "example_type"
13
14
  require_relative "task_helpers"
@@ -15,8 +16,89 @@ require_relative "task_helpers"
15
16
  namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength
16
17
  include ReactOnRails::TaskHelpers
17
18
 
19
+ # Updates React-related dependencies to a specific version
20
+ def update_react_dependencies(deps, react_version)
21
+ return unless deps
22
+
23
+ deps["react"] = react_version
24
+ deps["react-dom"] = react_version
25
+ end
26
+
27
+ # Updates Shakapacker to minimum supported version in either dependencies or devDependencies
28
+ def update_shakapacker_dependency(deps, dev_deps)
29
+ if dev_deps&.key?("shakapacker")
30
+ dev_deps["shakapacker"] = ExampleType::MINIMUM_SHAKAPACKER_VERSION
31
+ elsif deps&.key?("shakapacker")
32
+ deps["shakapacker"] = ExampleType::MINIMUM_SHAKAPACKER_VERSION
33
+ end
34
+ end
35
+
36
+ # Updates dependencies in package.json to use specific React version
37
+ def update_package_json_for_react_version(package_json_path, react_version)
38
+ return unless File.exist?(package_json_path)
39
+
40
+ begin
41
+ package_json = JSON.parse(File.read(package_json_path))
42
+ rescue JSON::ParserError => e
43
+ puts " ERROR: Failed to parse #{package_json_path}: #{e.message}"
44
+ raise
45
+ end
46
+
47
+ deps = package_json["dependencies"]
48
+ dev_deps = package_json["devDependencies"]
49
+
50
+ update_react_dependencies(deps, react_version)
51
+ # Shakapacker 8.2.0 requires webpack-assets-manifest ^5.x (v6.x uses ESM and breaks)
52
+ # Always add this explicitly since the transitive dependency from shakapacker may be v6.x
53
+ dev_deps["webpack-assets-manifest"] = "^5.0.6" if dev_deps
54
+ # Shakapacker 8.2.0 requires babel-loader to be explicitly installed as a devDependency
55
+ # (in 9.x this requirement was relaxed or the package structure changed)
56
+ dev_deps["babel-loader"] = "^9.1.3" if dev_deps
57
+ # @babel/plugin-transform-runtime is required by the default babel config but not
58
+ # automatically included as a dependency in older Shakapacker versions
59
+ dev_deps["@babel/plugin-transform-runtime"] = "^7.24.0" if dev_deps
60
+ update_shakapacker_dependency(deps, dev_deps)
61
+
62
+ # Add npm overrides to force specific React version, preventing yalc-linked
63
+ # react-on-rails from pulling in React 19 as a transitive dependency
64
+ package_json["overrides"] = {
65
+ "react" => react_version,
66
+ "react-dom" => react_version
67
+ }
68
+
69
+ File.write(package_json_path, "#{JSON.pretty_generate(package_json)}\n")
70
+ end
71
+
72
+ # Updates Gemfile to pin shakapacker to minimum version
73
+ # (must match the npm package version exactly)
74
+ def update_gemfile_versions(gemfile_path)
75
+ return unless File.exist?(gemfile_path)
76
+
77
+ gemfile_content = File.read(gemfile_path)
78
+ # Replace any shakapacker gem line with exact version pin
79
+ # Handle both single-line: gem 'shakapacker', '>= 8.2.0'
80
+ # And multi-line declarations:
81
+ # gem 'shakapacker',
82
+ # '>= 8.2.0'
83
+ gemfile_content = gemfile_content.gsub(
84
+ /gem ['"]shakapacker['"][^\n]*(?:\n\s+[^g\n][^\n]*)*$/m,
85
+ "gem 'shakapacker', '#{ExampleType::MINIMUM_SHAKAPACKER_VERSION}'"
86
+ )
87
+ File.write(gemfile_path, gemfile_content)
88
+ end
89
+
90
+ # Updates package.json and Gemfile to use specific React version for compatibility testing
91
+ def apply_react_version(dir, react_version)
92
+ update_package_json_for_react_version(File.join(dir, "package.json"), react_version)
93
+ update_gemfile_versions(File.join(dir, "Gemfile"))
94
+
95
+ puts " Updated package.json for compatibility testing:"
96
+ puts " React: #{react_version}"
97
+ puts " Shakapacker: #{ExampleType::MINIMUM_SHAKAPACKER_VERSION}"
98
+ end
99
+
18
100
  # Define tasks for each example type
19
- ExampleType.all[:shakapacker_examples].each do |example_type|
101
+ ExampleType.all[:shakapacker_examples].each do |example_type| # rubocop:disable Metrics/BlockLength
20
102
  relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(example_type.dir))
21
103
  # CLOBBER
22
104
  desc "Clobbers (deletes) #{example_type.name_pretty}"
@@ -46,10 +128,31 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength
46
128
  "REACT_ON_RAILS_SKIP_VALIDATION=true #{cmd}"
47
129
  end
48
130
  sh_in_dir(example_type.dir, generator_commands)
49
- sh_in_dir(example_type.dir, "npm install")
131
+ # Re-run bundle install since dev_tests generator adds rspec-rails and coveralls to Gemfile
132
+ bundle_install_in(example_type.dir)
133
+
134
+ # Apply specific React version for compatibility testing examples
135
+ if example_type.pinned_react_version?
136
+ apply_react_version(example_type.dir, example_type.react_version_string)
137
+ # Re-run bundle install since Gemfile was updated with pinned shakapacker version
138
+ bundle_install_in(example_type.dir)
139
+ # Run npm install BEFORE shakapacker:binstubs to ensure the npm shakapacker version
140
+ # matches the gem version. The binstubs task loads the Rails environment which
141
+ # validates version matching between gem and npm package.
142
+ # Use --legacy-peer-deps to avoid peer dependency conflicts when yalc-linked
143
+ # react-on-rails expects newer React versions
144
+ sh_in_dir(example_type.dir, "npm install --legacy-peer-deps")
145
+ # Regenerate Shakapacker binstubs after downgrading from 9.x to 8.2.x
146
+ # The binstub format may differ between major versions
147
+ unbundled_sh_in_dir(example_type.dir, "bundle exec rake shakapacker:binstubs")
148
+ else
149
+ sh_in_dir(example_type.dir, "npm install")
150
+ end
50
151
  # Generate the component packs after running the generator to ensure all
51
- # auto-bundled components have corresponding pack files created
52
- sh_in_dir(example_type.dir, "bundle exec rake react_on_rails:generate_packs")
152
+ # auto-bundled components have corresponding pack files created.
153
+ # Use unbundled_sh_in_dir to ensure we're using the generated app's Gemfile
154
+ # and gem versions, not the parent workspace's bundle context.
155
+ unbundled_sh_in_dir(example_type.dir, "bundle exec rake react_on_rails:generate_packs")
53
156
  end
54
157
  end
55
158
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: react_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 16.2.0.beta.13
4
+ version: 16.2.0.beta.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Gordon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-12-07 00:00:00.000000000 Z
11
+ date: 2025-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable