-
Notifications
You must be signed in to change notification settings - Fork 380
Upgrade React on Rails to 16.0.1.rc.4 with enhanced dev tools #655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade React on Rails to 16.0.1.rc.4 with enhanced dev tools #655
Conversation
WalkthroughBumps Ruby and JS dependencies for ReactOnRails and Shakapacker, adds Prettier ignore for ReScript-generated JS, replaces ad-hoc bin/dev logic with ReactOnRails::Dev::ServerManager entry point (including static mode), adds new Procfiles for asset workflows, and sets test generated_assets_dir to public/packs/. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Developer
participant CLI as bin/dev
participant RORD as ReactOnRails::Dev::ServerManager
participant Proc as Procfile Runner
participant Rails as Rails (bin/rails)
participant Redis as Redis
participant WP as Shakapacker
Dev->>CLI: run
CLI->>RORD: run_from_command_line(ARGV)
RORD->>Proc: select Procfile (dev / dev-prod-assets / dev-static-assets)
Proc->>Rails: start web (bin/rails s -p 3000/3001)
Proc->>Redis: start redis-server
Proc->>WP: run locale task && rm -rf public/packs/* || true && bin/shakapacker -w
note right of WP: webpack watch + locale task
sequenceDiagram
autonumber
actor Dev as Developer
participant CLIstatic as bin/dev-static
participant RORD as ReactOnRails::Dev::ServerManager
participant Proc as Procfile Runner (static)
Dev->>CLIstatic: run
CLIstatic->>RORD: run_from_command_line(["static"])
RORD->>Proc: use static-assets Procfile
Proc->>Rails: start web (static mode)
Proc->>WP: start webpack watch for static assets
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🚀 Quick Review App CommandsWelcome! Here are the commands you can use in this PR:
|
- 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>
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>
5061349
to
d088c2e
Compare
- 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>
✅ Updated with Merged RuboCop FixesThis PR has been successfully rebased to incorporate the merged RuboCop fixes from PR #653. 🔄 Changes Applied
📊 Current CI Status
🚀 Ready for MergeThis PR now contains:
Production-ready! 🎉 |
/deploy-review-app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (5)
.prettierignore (1)
11-12
: Ignore ReScript outputs: good; consider broader patterns.Consider also ignoring potential ESM/CJS outputs and build dirs generated by ReScript to avoid future churn.
# ReScript generated files should not be formatted -**/*.bs.js +**/*.bs.js +**/*.bs.mjs +**/*.bs.cjs +lib/bs/** +lib/js/**Gemfile (1)
48-52
: Outdated workaround likely no longer needed; clean up net-pop pin.Comment says “remove when Ruby 3.3.4 is released,” and this Gemfile already targets ruby "3.3.4". Drop the temporary net-pop override if CI passes without it.
-# Needed until Ruby 3.3.4 is released https://github.com/ruby/ruby/pull/11006 -# Related issue: https://github.com/ruby/net-pop/issues/26 -# TODO: When Ruby 3.3.4 is released, upgrade Ruby and remove this line -gem "net-pop", github: "ruby/net-pop"Procfile.dev-static-assets (1)
1-10
: Good baseline; make env explicit for reliability.Make the webpack watch step explicit about envs to avoid inheriting unintended values when launched via different process managers.
-webpack: sh -c 'bundle exec rake react_on_rails:locale && rm -rf public/packs/* || true && bin/shakapacker -w' +webpack: sh -c 'RAILS_ENV=development NODE_ENV=development bundle exec rake react_on_rails:locale && rm -rf public/packs/* || true && RAILS_ENV=development NODE_ENV=development bin/shakapacker -w'bin/dev (2)
4-20
: Fix Procfile name typo and clarify invocation docs.
- Line 12 typo: "Procfile.dev-static-assets-assets" → "Procfile.dev-static-assets".
- PR mentions bin/dev-static; current docs only show "bin/dev static". Suggest documenting both.
Apply:
-# Each command uses a specific Procfile for process management: -# - bin/dev (default/hmr): Uses Procfile.dev -# - bin/dev static: Uses Procfile.dev-static-assets-assets -# - bin/dev prod: Uses Procfile.dev-prod-assets +# Each command uses a specific Procfile for process management: +# - bin/dev (default/HMR): Procfile.dev +# - bin/dev static (or bin/dev-static): Procfile.dev-static-assets +# - bin/dev prod: Procfile.dev-prod-assets
30-31
: Propagate exit status to the shell (optional).If run_from_command_line returns an exit code, forward it.
-# Main execution -ReactOnRails::Dev::ServerManager.run_from_command_line(ARGV) +# Main execution +status = ReactOnRails::Dev::ServerManager.run_from_command_line(ARGV) +exit(status) if status.is_a?(Integer)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
Gemfile.lock
is excluded by!**/*.lock
yarn.lock
is excluded by!**/yarn.lock
,!**/*.lock
📒 Files selected for processing (9)
.prettierignore
(1 hunks)Gemfile
(1 hunks)Procfile.dev
(1 hunks)Procfile.dev-prod-assets
(1 hunks)Procfile.dev-static-assets
(1 hunks)bin/dev
(1 hunks)bin/dev-static
(1 hunks)config/initializers/react_on_rails.rb
(1 hunks)package.json
(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
config/initializers/react_on_rails.rb (1)
config/application.rb (1)
config
(12-29)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: test (22.x, 3.3.4)
🔇 Additional comments (6)
Procfile.dev (1)
5-5
: Switch to bin/rails is sane — bin/rails present & executable.
bin/rails picks up Spring/Bundler and aligns with other Procfiles; verification script returned "bin/rails is executable". Approving change.config/initializers/react_on_rails.rb (1)
17-25
: Wrap test-only bundle-path override in an explicit if block — config.generated_assets_dir is valid in ReactOnRails v16.
ReactOnRails v16 supports config.generated_assets_dir; the block form improves readability.- config.generated_assets_dir = Rails.public_path.join("packs").to_s if Rails.env.test? + if Rails.env.test? + config.generated_assets_dir = Rails.public_path.join("packs").to_s + endpackage.json (2)
90-90
: Fix: package.json depends on nonexistent rescript-react-on-rails@1.1.0 — update to a valid source.No 1.1.0 release is published (npm & GitHub show latest v1.0.1), so there are no output-extension/dir changes to verify; change the dependency to v1.0.1 or the intended git/tag so installs succeed and .prettierignore assumptions remain correct.
Location: package.json (line 90)Likely an incorrect or invalid review comment.
81-81
: Upgrade to react-on-rails 16.0.1-rc.2 — verify peer deps and bundler migration
- react / react-dom: peerDeps ">=16" — React 19.x is satisfied.
- Node: tested/supported on Node 20–22 — Node 22 is supported.
- Webpacker removed: migration to Shakapacker is required (Shakapacker >=6 required; 8+ recommended). Update bin scripts (bin/webpacker → bin/shakapacker), config, and npm scripts.
- webpack-dev-server: confirm devDependencies match Shakapacker’s supported webpack/webpack-dev-server versions and adjust CI.
- Action: check package.json for shakapacker, inspect bin/* and CI configs (e.g., .github workflows, .nvmrc); migrate and run local/CI validation before merging.
Gemfile (1)
8-8
: RC gem pin is available on rubygems — confirm package.json and changelog. rubygems shows react_on_rails 16.0.1.rc.2 and npm registry shows react-on-rails 16.0.1-rc.2; I could not verify the repo's package.json entry — confirm package.json's react-on-rails matches the Gemfile (Gemfile: line 8) and capture any breaking changes in the gem/npm changelogs.bin/dev (1)
19-19
: Document supported API: replace ServerManager.start example with run_from_command_linebin/dev:19 currently documents
ReactOnRails::Dev::ServerManager.start(:development, "Custom.procfile")
, but the repo only callsServerManager.run_from_command_line
(bin/dev:31, bin/dev-static:19) and nodef self.start
was found — replace the example with the CLI invocation or confirm thatstart
is a public API in ReactOnRails v16.0.1.rc.2 before documenting it.
begin | ||
require "bundler/setup" | ||
require "react_on_rails/dev" | ||
rescue LoadError | ||
# Fallback for when gem is not yet installed | ||
puts "Loading ReactOnRails development tools..." | ||
require_relative "../../lib/react_on_rails/dev" | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect require_relative path; fallback won’t find local dev code.
From bin/dev, "../../lib/…" is one directory too high. Also prefer stderr for the notice and a single rescue covering only the gem require.
Apply:
-begin
- require "bundler/setup"
- require "react_on_rails/dev"
-rescue LoadError
- # Fallback for when gem is not yet installed
- puts "Loading ReactOnRails development tools..."
- require_relative "../../lib/react_on_rails/dev"
-end
+begin
+ require "bundler/setup"
+ require "react_on_rails/dev"
+rescue LoadError
+ # Fallback when gem not installed
+ warn "Loading ReactOnRails development tools from local lib..."
+ require_relative File.expand_path("../lib/react_on_rails/dev", __dir__)
+end
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In bin/dev around lines 21-28, the fallback require_relative points one
directory too high and the rescue currently covers the bundler setup as well;
change the rescue to only wrap the gem require "react_on_rails/dev", update the
fallback require_relative path to "../lib/react_on_rails/dev" so it finds the
local lib, and write the notice to stderr (use warn or STDERR.puts) instead of
puts.
begin | ||
require "bundler/setup" | ||
require "react_on_rails/dev" | ||
rescue LoadError | ||
# Fallback for when gem is not yet installed | ||
puts "Loading ReactOnRails development tools..." | ||
require_relative "../../lib/react_on_rails/dev" | ||
end | ||
|
||
if installed? "overmind" | ||
run "overmind" | ||
elsif installed? "foreman" | ||
run "foreman" | ||
else | ||
warn <<~MSG | ||
NOTICE: | ||
For this script to run, you need either 'overmind' or 'foreman' installed on your machine. Please try this script after installing one of them. | ||
MSG | ||
exit! | ||
end | ||
# Force static mode by passing 'static' argument | ||
ReactOnRails::Dev::ServerManager.run_from_command_line(["static"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Fallback require path is wrong; breaks when gem isn’t installed.
bin/dev-static lives in project/bin, so require_relative should go up one, not two.
-rescue LoadError
- # Fallback for when gem is not yet installed
- puts "Loading ReactOnRails development tools..."
- require_relative "../../lib/react_on_rails/dev"
+rescue LoadError
+ # Fallback for when gem is not yet installed
+ puts "Loading ReactOnRails development tools..."
+ require_relative "../lib/react_on_rails/dev"
Also ensure this file has +x perms and is referenced in docs.
🏁 Script executed:
#!/bin/bash
set -euo pipefail
test -x bin/dev-static && echo "bin/dev-static is executable" || { echo "chmod +x bin/dev-static"; exit 1; }
Length of output: 28
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "PWD: $(pwd -P)"
echo
echo "Root listing:"
ls -la | sed -n '1,200p' || true
echo
echo "---- bin/dev-static (first 200 lines) ----"
if [ -f bin/dev-static ]; then
sed -n '1,200p' bin/dev-static
else
echo "bin/dev-static not found"
exit 0
fi
echo
echo "---- require_relative lines in repo ----"
if command -v rg >/dev/null 2>&1; then
rg -n "require_relative" --hidden --no-ignore || true
else
grep -RIn --exclude-dir=.git "require_relative" . || true
fi
echo
echo "---- File existence checks ----"
if [ -f lib/react_on_rails/dev.rb ]; then
echo "FOUND: lib/react_on_rails/dev.rb"
else
echo "MISSING: lib/react_on_rails/dev.rb"
fi
if [ -f bin/../lib/react_on_rails/dev.rb ]; then
echo "FOUND: bin/../lib/react_on_rails/dev.rb"
else
echo "MISSING: bin/../lib/react_on_rails/dev.rb"
fi
if [ -f bin/../../lib/react_on_rails/dev.rb ]; then
echo "FOUND: bin/../../lib/react_on_rails/dev.rb"
else
echo "MISSING: bin/../../lib/react_on_rails/dev.rb"
fi
echo
echo "---- Search repo for references to 'dev-static' ----"
if command -v rg >/dev/null 2>&1; then
rg -n --hidden --no-ignore 'dev-static' || true
else
grep -RIn --exclude-dir=.git 'dev-static' . || true
fi
Length of output: 4710
Fix fallback require_relative path and restore missing fallback file
- In bin/dev-static (lines 9–19) update the fallback require_relative to one level up. Apply this exact change:
-rescue LoadError
- # Fallback for when gem is not yet installed
- puts "Loading ReactOnRails development tools..."
- require_relative "../../lib/react_on_rails/dev"
+rescue LoadError
+ # Fallback for when gem is not yet installed
+ puts "Loading ReactOnRails development tools..."
+ require_relative "../lib/react_on_rails/dev"
- Also apply the same require_relative fix in bin/dev (around line 27).
- lib/react_on_rails/dev.rb is missing from the repo — add/restore that file or update the fallback to the correct path/gem so the rescue path works.
- bin/dev-static is already executable (no chmod needed).
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
begin | |
require "bundler/setup" | |
require "react_on_rails/dev" | |
rescue LoadError | |
# Fallback for when gem is not yet installed | |
puts "Loading ReactOnRails development tools..." | |
require_relative "../../lib/react_on_rails/dev" | |
end | |
if installed? "overmind" | |
run "overmind" | |
elsif installed? "foreman" | |
run "foreman" | |
else | |
warn <<~MSG | |
NOTICE: | |
For this script to run, you need either 'overmind' or 'foreman' installed on your machine. Please try this script after installing one of them. | |
MSG | |
exit! | |
end | |
# Force static mode by passing 'static' argument | |
ReactOnRails::Dev::ServerManager.run_from_command_line(["static"]) | |
begin | |
require "bundler/setup" | |
require "react_on_rails/dev" | |
rescue LoadError | |
# Fallback for when gem is not yet installed | |
puts "Loading ReactOnRails development tools..." | |
require_relative "../lib/react_on_rails/dev" | |
end | |
# Force static mode by passing 'static' argument | |
ReactOnRails::Dev::ServerManager.run_from_command_line(["static"]) |
🤖 Prompt for AI Agents
In bin/dev-static around lines 9 to 19, the fallback require_relative path is
one directory too deep and should be changed to require_relative
"../lib/react_on_rails/dev" (apply the identical require_relative fix in bin/dev
around line 27); additionally, restore or add the missing file
lib/react_on_rails/dev.rb (or update the fallback to point to the correct gem
path) so the rescue path can actually load the development helper; make these
exact path fixes and add the missing lib file to the repo (no chmod changes
required).
# You can run these commands in separate shells | ||
web: bin/rails s -p 3001 | ||
redis: redis-server | ||
|
||
# Next line runs a watch process with webpack to compile the changed files. | ||
# When making frequent changes to client side assets, you will prefer building webpack assets | ||
# upon saving rather than when you refresh your browser page. | ||
# Note, if using React on Rails localization you will need to run | ||
# `bundle exec rake react_on_rails:locale` before you run bin/shakapacker | ||
webpack: sh -c 'bundle exec rake react_on_rails:locale && rm -rf public/packs/* || true && bin/shakapacker -w' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Prod assets" file currently builds dev watch; align with production mode.
This Procfile claims production assets but uses a watch and no production env. Switch to a one-time production build and run Rails with production env (and static files).
-web: bin/rails s -p 3001
+web: RAILS_ENV=production RAILS_SERVE_STATIC_FILES=true bin/rails s -p 3001
@@
-webpack: sh -c 'bundle exec rake react_on_rails:locale && rm -rf public/packs/* || true && bin/shakapacker -w'
+webpack: sh -c 'RAILS_ENV=production NODE_ENV=production bundle exec rake react_on_rails:locale && rm -rf public/packs/* || true && RAILS_ENV=production NODE_ENV=production bin/shakapacker'
Optionally export SECRET_KEY_BASE/RAILS_MASTER_KEY via your process manager if required.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
# You can run these commands in separate shells | |
web: bin/rails s -p 3001 | |
redis: redis-server | |
# Next line runs a watch process with webpack to compile the changed files. | |
# When making frequent changes to client side assets, you will prefer building webpack assets | |
# upon saving rather than when you refresh your browser page. | |
# Note, if using React on Rails localization you will need to run | |
# `bundle exec rake react_on_rails:locale` before you run bin/shakapacker | |
webpack: sh -c 'bundle exec rake react_on_rails:locale && rm -rf public/packs/* || true && bin/shakapacker -w' | |
# You can run these commands in separate shells | |
web: RAILS_ENV=production RAILS_SERVE_STATIC_FILES=true bin/rails s -p 3001 | |
redis: redis-server | |
# Next line runs a watch process with webpack to compile the changed files. | |
# When making frequent changes to client side assets, you will prefer building webpack assets | |
# upon saving rather than when you refresh your browser page. | |
# Note, if using React on Rails localization you will need to run | |
# `bundle exec rake react_on_rails:locale` before you run bin/shakapacker | |
webpack: sh -c 'RAILS_ENV=production NODE_ENV=production bundle exec rake react_on_rails:locale && rm -rf public/packs/* || true && RAILS_ENV=production NODE_ENV=production bin/shakapacker' |
🤖 Prompt for AI Agents
In Procfile.dev-prod-assets around lines 1 to 10, the "webpack" entry runs a
development watch and doesn't build production assets nor start Rails in
production; change it to perform a one-time production asset build and start
Rails with RAILS_ENV=production and static files enabled. Replace the watch
command with a production precompile (e.g. run bundle exec rake
react_on_rails:locale && RAILS_ENV=production bin/shakapacker && bin/rails
assets:precompile or equivalent single-run build), ensure the web entry runs
bin/rails s -e production -p 3001 and serves static files
(RAILS_SERVE_STATIC_FILES=1), and note that SECRET_KEY_BASE/RAILS_MASTER_KEY
should be provided by your process manager if required.
/deploy-review-app |
@AbanoubGhadban @ihabadham the prior staging deploy didn't work. This tool is very valuable. |
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>
✅ Deployment complete for PR #655, commit c3bbc27 |
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>
✅ Deployment complete for PR #655, commit 8427012 |
- 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>
✅ Deployment complete for PR #655, commit d56639e |
✅ Review app for PR #655 was successfully deleted |
Summary
Clean upgrade of React on Rails from version 14.2.1 to 16.0.1.rc.4 with full ReScript compatibility, proper configuration, and enhanced development tools.
🚀 Core Upgrade Changes
14.2.1
→16.0.1.rc.4
14.2.1
→16.0.1-rc.4
1.0.1
→1.1.0
(includes React on Rails 16 support)8.2.0
for Docker build compatibility.bs.js
files✨ Enhanced Development Tools
Brought over development improvements from
justin-808-test-update-ror-v15
:New Development Scripts
bin/dev
: Enhanced with ReactOnRails::Dev tools for better workflow managementbin/dev-static
: Static asset development mode (faster startup, no HMR)Multiple Development Modes
Procfile.dev
: Default HMR development (enhanced)Procfile.dev-static-assets
: Webpack watching without HMRProcfile.dev-prod-assets
: Production asset development modeImproved Workflows
🔧 Technical Details
Bundle Path Resolution Fix
React on Rails 16 introduced a breaking change where the fallback error handling for bundle path resolution was removed. This configuration ensures compatibility:
ReScript Compatibility
Updated
rescript-react-on-rails
to version 1.1.0 which includes peer dependency support for React on Rails 16.✅ Validation
📋 Dependencies
🌟 Benefits
Production-ready with enhanced developer experience! 🚀
🤖 Generated with Claude Code
This change is