Skip to content

Commit 4b76b88

Browse files
justin808claudeihabadham
authored
Upgrade React on Rails to 16.0.1.rc.4 with enhanced dev tools (#655)
* Upgrade React on Rails from 14.2.1 to 16.0.1.rc.2 - Update react_on_rails gem: 14.2.1 → 16.0.1.rc.2 - Update react-on-rails npm: 14.2.1 → 16.0.1-rc.2 - Update rescript-react-on-rails: 1.0.1 → 1.1.0 (for React on Rails 16 support) - Add test environment configuration to resolve server bundle path issue - Add .prettierignore rule for ReScript generated files - All 38 tests passing ✅ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Add enhanced development server tools from React on Rails 16 Brought over development improvements from justin-808-test-update-ror-v15: - Enhanced bin/dev script using ReactOnRails::Dev tools - Added bin/dev-static for static asset development mode - Added Procfile.dev-static-assets for webpack watching without HMR - Added Procfile.dev-prod-assets for production asset development - Updated Procfile.dev to use bin/rails instead of bundle exec These improvements provide better development workflows: - bin/dev: Default HMR development (existing) - bin/dev static: Static assets with webpack watching - Multiple Procfile options for different development modes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix trailing newline and RuboCop style in bin/dev-static - Add missing trailing newline - Fix string quote style to use double quotes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix staging deploy by upgrading Shakapacker to 8.2.0 React on Rails 16.0.1.rc.2 requires Shakapacker >= 8.2.0 for proper packer_type detection. Without this, the clean task invocation fails with 'Don't know how to build task :clean' during assets:precompile. This upgrade ensures the correct 'shakapacker:clean' task is invoked instead of the non-existent ':clean' task. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix Docker build failure by upgrading Shakapacker to 8.2.0 React on Rails 16 requires Shakapacker 8.2.0+ for proper packer type detection. With Shakapacker 8.0.0, ReactOnRails::PackerUtils.packer_type returned nil, causing React on Rails to invoke `:clean` instead of `shakapacker:clean` during assets:precompile, which resulted in a "Don't know how to build task ':clean'" error. Changes: - Upgrade shakapacker gem from 8.0.0 to 8.2.0 in Gemfile - Upgrade shakapacker npm package from 8.0.0 to 8.2.0 in package.json This resolves the Docker build failure and ensures React on Rails 16 can properly invoke the shakapacker:clean task during asset compilation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Update React on Rails to 16.0.1.rc.4 - Update react_on_rails gem from 16.0.1.rc.2 to 16.0.1.rc.4 - Update react-on-rails npm package to match version - Run bundle install and yarn install to update lock files 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: ihabadham <ihabadham4p@gmail.com>
1 parent 6e5113f commit 4b76b88

File tree

11 files changed

+1264
-1240
lines changed

11 files changed

+1264
-1240
lines changed

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ spec/support/
77
client/app/libs/i18n/translations.js
88
client/app/libs/i18n/default.js
99
vendor/bundle
10+
11+
# ReScript generated files should not be formatted
12+
**/*.bs.js

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
55

66
ruby "3.3.4"
77

8-
gem "react_on_rails", "14.2.1"
9-
gem "shakapacker", "8.0.0"
8+
gem "react_on_rails", "16.0.1.rc.4"
9+
gem "shakapacker", "8.2.0"
1010

1111
# Bundle edge Rails instead: gem "rails", github: "rails/rails"
1212
gem "listen"

Gemfile.lock

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,13 @@ GEM
298298
rdoc (6.14.2)
299299
erb
300300
psych (>= 4.0.0)
301-
react_on_rails (14.2.1)
301+
react_on_rails (16.0.1.rc.4)
302302
addressable
303303
connection_pool
304304
execjs (~> 2.5)
305305
rails (>= 5.2)
306306
rainbow (~> 3.0)
307+
shakapacker (>= 6.0)
307308
redcarpet (3.6.0)
308309
redis (5.3.0)
309310
redis-client (>= 0.22.0)
@@ -388,7 +389,7 @@ GEM
388389
websocket (~> 1.0)
389390
semantic_range (3.1.0)
390391
sexp_processor (4.17.1)
391-
shakapacker (8.0.0)
392+
shakapacker (8.2.0)
392393
activesupport (>= 5.2)
393394
package_json
394395
rack-proxy (>= 0.6.1)
@@ -484,7 +485,7 @@ DEPENDENCIES
484485
rails-html-sanitizer
485486
rails_best_practices
486487
rainbow
487-
react_on_rails (= 14.2.1)
488+
react_on_rails (= 16.0.1.rc.4)
488489
redcarpet
489490
redis (~> 5.0)
490491
rspec-rails (~> 6.0.0)
@@ -496,7 +497,7 @@ DEPENDENCIES
496497
scss_lint
497498
sdoc
498499
selenium-webdriver (~> 4)
499-
shakapacker (= 8.0.0)
500+
shakapacker (= 8.2.0)
500501
spring
501502
spring-commands-rspec
502503
stimulus-rails (~> 1.3)

Procfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
# You can run these commands in separate shells
33
rescript: yarn res:dev
44
redis: redis-server
5-
rails: bundle exec rails s -p 3000
5+
rails: bin/rails s -p 3000
66
wp-client: HMR=true RAILS_ENV=development NODE_ENV=development bin/shakapacker-dev-server
77
wp-server: bundle exec rake react_on_rails:locale && HMR=true SERVER_BUNDLE_ONLY=yes bin/shakapacker --watch

Procfile.dev-prod-assets

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# You can run these commands in separate shells
2+
web: bin/rails s -p 3001
3+
redis: redis-server
4+
5+
# Next line runs a watch process with webpack to compile the changed files.
6+
# When making frequent changes to client side assets, you will prefer building webpack assets
7+
# upon saving rather than when you refresh your browser page.
8+
# Note, if using React on Rails localization you will need to run
9+
# `bundle exec rake react_on_rails:locale` before you run bin/shakapacker
10+
webpack: sh -c 'bundle exec rake react_on_rails:locale && rm -rf public/packs/* || true && bin/shakapacker -w'

Procfile.dev-static-assets

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# You can run these commands in separate shells
2+
web: bin/rails s -p 3000
3+
redis: redis-server
4+
5+
# Next line runs a watch process with webpack to compile the changed files.
6+
# When making frequent changes to client side assets, you will prefer building webpack assets
7+
# upon saving rather than when you refresh your browser page.
8+
# Note, if using React on Rails localization you will need to run
9+
# `bundle exec rake react_on_rails:locale` before you run bin/shakapacker
10+
webpack: sh -c 'bundle exec rake react_on_rails:locale && rm -rf public/packs/* || true && bin/shakapacker -w'

bin/dev

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
#!/usr/bin/env ruby
22
# frozen_string_literal: true
33

4-
def installed?(process)
5-
IO.popen "#{process} -v"
6-
rescue Errno::ENOENT
7-
false
8-
end
4+
# ReactOnRails Development Server
5+
#
6+
# This script provides a simple interface to the ReactOnRails development
7+
# server management. The core logic is implemented in ReactOnRails::Dev
8+
# classes for better maintainability and testing.
9+
#
10+
# Each command uses a specific Procfile for process management:
11+
# - bin/dev (default/hmr): Uses Procfile.dev
12+
# - bin/dev static: Uses Procfile.dev-static-assets-assets
13+
# - bin/dev prod: Uses Procfile.dev-prod-assets
14+
#
15+
# To customize development environment:
16+
# 1. Edit the appropriate Procfile to modify which processes run
17+
# 2. Modify this script for project-specific command-line behavior
18+
# 3. Extend ReactOnRails::Dev classes in your Rails app for advanced customization
19+
# 4. Use classes directly: ReactOnRails::Dev::ServerManager.start(:development, "Custom.procfile")
920

10-
def run(process)
11-
system "#{process} start -f Procfile.dev"
12-
rescue Errno::ENOENT
13-
warn <<~MSG
14-
ERROR:
15-
Please ensure `Procfile.dev` exists in your project!
16-
MSG
17-
exit!
21+
begin
22+
require "bundler/setup"
23+
require "react_on_rails/dev"
24+
rescue LoadError
25+
# Fallback for when gem is not yet installed
26+
puts "Loading ReactOnRails development tools..."
27+
require_relative "../../lib/react_on_rails/dev"
1828
end
1929

20-
if installed? "overmind"
21-
run "overmind"
22-
elsif installed? "foreman"
23-
run "foreman"
24-
else
25-
warn <<~MSG
26-
NOTICE:
27-
For this script to run, you need either 'overmind' or 'foreman' installed on your machine. Please try this script after installing one of them.
28-
MSG
29-
exit!
30-
end
30+
# Main execution
31+
ReactOnRails::Dev::ServerManager.run_from_command_line(ARGV)

bin/dev-static

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,19 @@
11
#!/usr/bin/env ruby
22
# frozen_string_literal: true
33

4-
def installed?(process)
5-
IO.popen "#{process} -v"
6-
rescue Errno::ENOENT
7-
false
8-
end
4+
# ReactOnRails Development Server - Static Assets Mode
5+
#
6+
# This runs development with static assets instead of HMR.
7+
# Useful when you want faster startup or HMR is causing issues.
98

10-
def run(process)
11-
system "#{process} start -f Procfile.dev-static"
12-
rescue Errno::ENOENT
13-
warn <<~MSG
14-
ERROR:
15-
Please ensure `Procfile.dev-static` exists in your project!
16-
MSG
17-
exit!
9+
begin
10+
require "bundler/setup"
11+
require "react_on_rails/dev"
12+
rescue LoadError
13+
# Fallback for when gem is not yet installed
14+
puts "Loading ReactOnRails development tools..."
15+
require_relative "../../lib/react_on_rails/dev"
1816
end
1917

20-
if installed? "overmind"
21-
run "overmind"
22-
elsif installed? "foreman"
23-
run "foreman"
24-
else
25-
warn <<~MSG
26-
NOTICE:
27-
For this script to run, you need either 'overmind' or 'foreman' installed on your machine. Please try this script after installing one of them.
28-
MSG
29-
exit!
30-
end
18+
# Force static mode by passing 'static' argument
19+
ReactOnRails::Dev::ServerManager.run_from_command_line(["static"])

config/initializers/react_on_rails.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414
# not affect performance.
1515
config.server_bundle_js_file = "server-bundle.js"
1616

17+
# React on Rails 16 compatibility: Workaround for removed error handling
18+
#
19+
# BREAKING CHANGE in v16: React on Rails 14.2.1 had robust error handling that would
20+
# fallback to the Shakapacker output path when bundle lookup failed. This was removed
21+
# in v16.0.1.rc.2, causing it to look in the wrong directory during tests.
22+
#
23+
# This configuration tells React on Rails where to find bundles in test environment.
24+
# Without this, it defaults to public/webpack/test/ instead of public/packs/
25+
config.generated_assets_dir = Rails.public_path.join("packs").to_s if Rails.env.test?
26+
1727
################################################################################
1828
# CLIENT RENDERING OPTIONS
1929
# Below options can be overriden by passing options to the react_on_rails

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"react": "^19.0.0",
7979
"react-dom": "^19.0.0",
8080
"react-intl": "^6.4.4",
81-
"react-on-rails": "14.2.1",
81+
"react-on-rails": "16.0.1-rc.4",
8282
"react-redux": "^8.1.0",
8383
"react-router": "^6.13.0",
8484
"react-router-dom": "^6.13.0",
@@ -87,13 +87,13 @@
8787
"redux": "^4.2.1",
8888
"redux-thunk": "^2.2.0",
8989
"rescript": "^11.1.4",
90-
"rescript-react-on-rails": "^1.0.1",
90+
"rescript-react-on-rails": "1.1.0",
9191
"resolve-url-loader": "^2.2.0",
9292
"sanitize-html": "^2.11.0",
9393
"sass": "^1.58.3",
9494
"sass-loader": "^13.3.2",
9595
"sass-resources-loader": "^2.2.5",
96-
"shakapacker": "8.0.0",
96+
"shakapacker": "8.2.0",
9797
"stimulus": "^3.0.1",
9898
"style-loader": "^3.3.1",
9999
"tailwindcss": "^3.3.3",

0 commit comments

Comments
 (0)