-
-
Notifications
You must be signed in to change notification settings - Fork 638
Add React on Rails Quick Start Example Application #1761
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
base: master
Are you sure you want to change the base?
Changes from all commits
4ca1e9f
b8044f3
15bd1aa
ae80f43
031cc6f
da4481d
02dcaec
81dd3bf
43326ba
06f52f5
dc4a7f3
5b9f0f8
5e48745
3cef885
5bd5d20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"permissions": { | ||
"allow": [ | ||
"Bash(find:*)", | ||
"Bash(git add:*)", | ||
"Bash(git push:*)", | ||
"Bash(rails new:*)", | ||
"Bash(bundle:*)", | ||
"Bash(rails:*)", | ||
"Bash(git init:*)", | ||
"Bash(git commit:*)", | ||
"Bash(npm install:*)", | ||
"Bash(bin/shakapacker:*)", | ||
"Bash(git checkout:*)", | ||
"WebFetch(domain:github.com)", | ||
"Bash(yarn run lint)", | ||
"Bash(yarn run prettier:*)", | ||
"Bash(test:*)", | ||
"Bash(rake lint)", | ||
"Bash(yarn run:*)", | ||
"WebFetch(domain:vite-ruby.netlify.app)", | ||
"WebSearch", | ||
"Bash(gem install:*)", | ||
"Bash(gem search:*)", | ||
"Bash(git reset:*)", | ||
"Read(//Users/justin/shakacode/react-on-rails/**)", | ||
"Bash(./bin/dev)", | ||
"Bash(node:*)" | ||
], | ||
"deny": [], | ||
"ask": [] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,3 +60,6 @@ yalc.lock | |
|
||
# Generated by ROR FS-based Registry | ||
generated | ||
|
||
# Test applications directory | ||
/test-apps/ |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,231 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||
# π€ AI Agent Instructions: React on Rails Setup | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
*Super concise, copy-paste instructions for AI agents to set up React on Rails in common scenarios.* | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
## π **Before Starting: Check Current Versions** | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||||||||||||||||
# Get latest available versions (recommended approach) | ||||||||||||||||||||||||||||||||||||||||||||||||
gem search react_on_rails --remote | ||||||||||||||||||||||||||||||||||||||||||||||||
gem search shakapacker --remote | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# Or use specific versions from these commands in your Gemfile: | ||||||||||||||||||||||||||||||||||||||||||||||||
# Latest stable versions as of Jan 2025: | ||||||||||||||||||||||||||||||||||||||||||||||||
# react_on_rails ~> 15.0 | ||||||||||||||||||||||||||||||||||||||||||||||||
# shakapacker ~> 8.3 | ||||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
**β οΈ Version Flexibility:** These instructions use `~> X.Y` which allows patch updates. Always check for latest versions before starting a new project. | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
## π¨ **CRITICAL: Installation Order Matters** | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
**ALWAYS install Shakapacker FIRST, then React on Rails. Here's why:** | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
1. **React on Rails generator requires `package.json`** to add JavaScript dependencies | ||||||||||||||||||||||||||||||||||||||||||||||||
2. **Rails with `--skip-javascript` doesn't create `package.json`** | ||||||||||||||||||||||||||||||||||||||||||||||||
3. **Shakapacker creates `package.json`** and JavaScript tooling foundation | ||||||||||||||||||||||||||||||||||||||||||||||||
4. **Wrong order = "package.json not found" error** | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
**β Correct Order:** | ||||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||||
Shakapacker β package.json created β React on Rails β success | ||||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
**β Wrong Order:** | ||||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||||
React on Rails β no package.json β ERROR: package.json not found | ||||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
--- | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
## π Scenario 1: New Rails App with React on Rails | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||||||||||||||||
# Create new Rails app | ||||||||||||||||||||||||||||||||||||||||||||||||
rails new myapp --skip-javascript --database=postgresql | ||||||||||||||||||||||||||||||||||||||||||||||||
cd myapp | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# STEP 1: Add Shakapacker first (creates package.json) | ||||||||||||||||||||||||||||||||||||||||||||||||
echo 'gem "shakapacker", "~> 8.3"' >> Gemfile | ||||||||||||||||||||||||||||||||||||||||||||||||
bundle install | ||||||||||||||||||||||||||||||||||||||||||||||||
bundle exec rails shakapacker:install | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# STEP 2: Add React on Rails (requires package.json to exist) | ||||||||||||||||||||||||||||||||||||||||||||||||
echo 'gem "react_on_rails", "~> 15.0"' >> Gemfile | ||||||||||||||||||||||||||||||||||||||||||||||||
bundle install | ||||||||||||||||||||||||||||||||||||||||||||||||
rails generate react_on_rails:install | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# Start development servers | ||||||||||||||||||||||||||||||||||||||||||||||||
bin/dev | ||||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+43
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion Include npm/yarn install before starting dev servers. Generators add JS deps; without install, bin/dev often fails on a clean machine. rails generate react_on_rails:install
# Start development servers
-bin/dev
+npm install # or: yarn install
+bin/dev π Committable suggestion
Suggested change
π€ Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
**β Success Check:** Visit `http://localhost:3000/hello_world` β Should see "Hello World" from React | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
**π Generated Files:** | ||||||||||||||||||||||||||||||||||||||||||||||||
- `app/javascript/bundles/HelloWorld/components/HelloWorld.jsx` | ||||||||||||||||||||||||||||||||||||||||||||||||
- `app/controllers/hello_world_controller.rb` | ||||||||||||||||||||||||||||||||||||||||||||||||
- `app/views/hello_world/index.html.erb` | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
--- | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
## π Scenario 2: Add React on Rails to Existing Rails App | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||||||||||||||||
# Navigate to existing Rails app root | ||||||||||||||||||||||||||||||||||||||||||||||||
cd /path/to/existing/app | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# STEP 1: Add Shakapacker first (creates package.json if missing) | ||||||||||||||||||||||||||||||||||||||||||||||||
echo 'gem "shakapacker", "~> 8.3"' >> Gemfile | ||||||||||||||||||||||||||||||||||||||||||||||||
bundle install | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# Check if package.json exists, create if missing | ||||||||||||||||||||||||||||||||||||||||||||||||
if [ ! -f "package.json" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||
bundle exec rails shakapacker:install | ||||||||||||||||||||||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+77
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion Always run Shakapacker install; donβt gate it solely on package.json. Having package.json doesnβt guarantee Shakapacker configs/scripts were installed. -# Check if package.json exists, create if missing
-if [ ! -f "package.json" ]; then
- bundle exec rails shakapacker:install
-fi
+# Ensure Shakapacker is fully installed (idempotent)
+bundle exec rails shakapacker:install π Committable suggestion
Suggested change
π€ Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||
# STEP 2: Add React on Rails (requires package.json to exist) | ||||||||||||||||||||||||||||||||||||||||||||||||
echo 'gem "react_on_rails", "~> 15.0"' >> Gemfile | ||||||||||||||||||||||||||||||||||||||||||||||||
bundle install | ||||||||||||||||||||||||||||||||||||||||||||||||
rails generate react_on_rails:install --ignore-existing-files | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+86
to
+90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π‘ Verification agent π§© Analysis chainVerify generator flag support ( Iβm not sure this flag exists for Run a quick check or update to a supported flag, e.g., remove it if unnecessary: -rails generate react_on_rails:install --ignore-existing-files
+rails generate react_on_rails:install π Web query:
π‘ Result: Supported generator options (rails generate react_on_rails:install) in React on Rails 15.x:
Sources: React on Rails generator docs and package docs. [1] [2] References Citations:
Drop unsupported -rails generate react_on_rails:install --ignore-existing-files
+rails generate react_on_rails:install π Committable suggestion
Suggested change
π€ Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||
# Add React component to existing view | ||||||||||||||||||||||||||||||||||||||||||||||||
# Replace <view-name> with your actual view file | ||||||||||||||||||||||||||||||||||||||||||||||||
cat >> app/views/<view-name>/<action>.html.erb << 'EOF' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
<%= react_component("HelloWorld", props: { name: "World" }) %> | ||||||||||||||||||||||||||||||||||||||||||||||||
EOF | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# Start development | ||||||||||||||||||||||||||||||||||||||||||||||||
bin/dev | ||||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
**β οΈ Pre-flight Checks:** | ||||||||||||||||||||||||||||||||||||||||||||||||
- Rails app has `bin/dev` or similar dev script | ||||||||||||||||||||||||||||||||||||||||||||||||
- Shakapacker will create `package.json` if it doesn't exist | ||||||||||||||||||||||||||||||||||||||||||||||||
- No existing React setup conflicts | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
**β Success Check:** React component renders in your chosen view | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
--- | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
## β‘ Scenario 3: Convert Vite-Ruby to React on Rails | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||||||||||||||||
# Navigate to app root | ||||||||||||||||||||||||||||||||||||||||||||||||
cd /path/to/vite/ruby/app | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# Remove Vite-Ruby gems from Gemfile | ||||||||||||||||||||||||||||||||||||||||||||||||
sed -i.bak '/gem.*vite_rails/d' Gemfile | ||||||||||||||||||||||||||||||||||||||||||||||||
sed -i.bak '/gem.*vite_ruby/d' Gemfile | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# Backup existing Vite config | ||||||||||||||||||||||||||||||||||||||||||||||||
mv vite.config.* vite.config.backup 2>/dev/null || true | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# Remove Vite-specific files | ||||||||||||||||||||||||||||||||||||||||||||||||
rm -rf config/vite.json | ||||||||||||||||||||||||||||||||||||||||||||||||
rm -rf bin/vite* | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# STEP 1: Add Shakapacker first (creates package.json) | ||||||||||||||||||||||||||||||||||||||||||||||||
echo 'gem "shakapacker", "~> 8.3"' >> Gemfile | ||||||||||||||||||||||||||||||||||||||||||||||||
bundle install | ||||||||||||||||||||||||||||||||||||||||||||||||
bundle exec rails shakapacker:install --force | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# STEP 2: Add React on Rails (requires package.json to exist) | ||||||||||||||||||||||||||||||||||||||||||||||||
echo 'gem "react_on_rails", "~> 15.0"' >> Gemfile | ||||||||||||||||||||||||||||||||||||||||||||||||
bundle install | ||||||||||||||||||||||||||||||||||||||||||||||||
rails generate react_on_rails:install --force | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# Migrate existing React components | ||||||||||||||||||||||||||||||||||||||||||||||||
# Move components from app/frontend/entrypoints/ to app/javascript/bundles/ | ||||||||||||||||||||||||||||||||||||||||||||||||
mkdir -p app/javascript/bundles/Components | ||||||||||||||||||||||||||||||||||||||||||||||||
find app/frontend -name "*.jsx" -o -name "*.tsx" | while read file; do | ||||||||||||||||||||||||||||||||||||||||||||||||
basename=$(basename "$file") | ||||||||||||||||||||||||||||||||||||||||||||||||
cp "$file" "app/javascript/bundles/Components/$basename" | ||||||||||||||||||||||||||||||||||||||||||||||||
done | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# Update component registrations in app/javascript/packs/hello-world-bundle.js | ||||||||||||||||||||||||||||||||||||||||||||||||
echo "// Register your existing components here" | ||||||||||||||||||||||||||||||||||||||||||||||||
echo "// import YourComponent from '../bundles/Components/YourComponent';" | ||||||||||||||||||||||||||||||||||||||||||||||||
echo "// ReactOnRails.register({ YourComponent });" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# Clean up old Vite files | ||||||||||||||||||||||||||||||||||||||||||||||||
rm -rf app/frontend | ||||||||||||||||||||||||||||||||||||||||||||||||
rm -rf public/vite* | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# Update views to use React on Rails helpers | ||||||||||||||||||||||||||||||||||||||||||||||||
# Replace vite_javascript_tag with javascript_pack_tag | ||||||||||||||||||||||||||||||||||||||||||||||||
# Replace vite_stylesheet_tag with stylesheet_pack_tag | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# Install dependencies | ||||||||||||||||||||||||||||||||||||||||||||||||
yarn install | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# Start development | ||||||||||||||||||||||||||||||||||||||||||||||||
bin/dev | ||||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+111
to
+164
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion Fix find(1) OR precedence and restrict to files; standardize package install. The find expression needs grouping; otherwise matches can be inconsistent. Also, prefer npm (or explicitly note yarn alternative) for consistency with the rest of the doc. -find app/frontend -name "*.jsx" -o -name "*.tsx" | while read file; do
+find app/frontend \( -name "*.jsx" -o -name "*.tsx" \) -type f | while read file; do
basename=$(basename "$file")
cp "$file" "app/javascript/bundles/Components/$basename"
done
@@
-# Install dependencies
-yarn install
+# Install dependencies
+npm install # or: yarn install π€ Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
**π§ Manual Steps Required:** | ||||||||||||||||||||||||||||||||||||||||||||||||
1. **Update views**: Replace `vite_javascript_tag` with `javascript_pack_tag "hello-world-bundle"` | ||||||||||||||||||||||||||||||||||||||||||||||||
2. **Register components**: Add your components to `app/javascript/packs/hello-world-bundle.js` | ||||||||||||||||||||||||||||||||||||||||||||||||
3. **Update imports**: Change relative paths if needed | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
**β Success Check:** | ||||||||||||||||||||||||||||||||||||||||||||||||
- `bin/dev` starts without Vite errors | ||||||||||||||||||||||||||||||||||||||||||||||||
- React components render using `<%= react_component("YourComponent") %>` | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
--- | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
## π οΈ Common Troubleshooting Commands | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||||||||||||||||
# Check current versions and compatibility | ||||||||||||||||||||||||||||||||||||||||||||||||
bundle info react_on_rails shakapacker | ||||||||||||||||||||||||||||||||||||||||||||||||
rails --version | ||||||||||||||||||||||||||||||||||||||||||||||||
ruby --version | ||||||||||||||||||||||||||||||||||||||||||||||||
node --version | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# Check React on Rails installation | ||||||||||||||||||||||||||||||||||||||||||||||||
rails runner "puts ReactOnRails::VERSION" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# Verify Shakapacker setup | ||||||||||||||||||||||||||||||||||||||||||||||||
bin/shakapacker --version | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# Clear cache if components not updating | ||||||||||||||||||||||||||||||||||||||||||||||||
rm -rf tmp/cache public/packs | ||||||||||||||||||||||||||||||||||||||||||||||||
rails assets:clobber | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# Check component registration | ||||||||||||||||||||||||||||||||||||||||||||||||
rails runner "puts ReactOnRails.configuration.components_subdirectory" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
# Restart with clean build | ||||||||||||||||||||||||||||||||||||||||||||||||
pkill -f "bin/shakapacker-dev-server" | ||||||||||||||||||||||||||||||||||||||||||||||||
rm -rf public/packs-test | ||||||||||||||||||||||||||||||||||||||||||||||||
bin/dev | ||||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
--- | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
## π Quick Reference | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
### Essential Files Structure | ||||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||||
app/ | ||||||||||||||||||||||||||||||||||||||||||||||||
βββ controllers/hello_world_controller.rb | ||||||||||||||||||||||||||||||||||||||||||||||||
βββ views/hello_world/index.html.erb | ||||||||||||||||||||||||||||||||||||||||||||||||
βββ javascript/ | ||||||||||||||||||||||||||||||||||||||||||||||||
βββ bundles/HelloWorld/components/HelloWorld.jsx | ||||||||||||||||||||||||||||||||||||||||||||||||
βββ packs/hello-world-bundle.js | ||||||||||||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
### Key Commands | ||||||||||||||||||||||||||||||||||||||||||||||||
- **Development**: `bin/dev` (starts Rails + Shakapacker) | ||||||||||||||||||||||||||||||||||||||||||||||||
- **Generate**: `rails generate react_on_rails:install` | ||||||||||||||||||||||||||||||||||||||||||||||||
- **Component**: `<%= react_component("ComponentName", props: {}) %>` | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
### Version Requirements | ||||||||||||||||||||||||||||||||||||||||||||||||
- Rails 7+ (Rails 8 supported), Ruby 3.0+ (Ruby 3.2+ for Rails 8), Node 20+ LTS, Yarn | ||||||||||||||||||||||||||||||||||||||||||||||||
- react_on_rails ~> 15.0+, shakapacker ~> 8.3+ | ||||||||||||||||||||||||||||||||||||||||||||||||
- **Note**: Use `bundle info react_on_rails` to check latest available version | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
--- | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
*π‘ **Pro Tip for AI Agents**: Always run `bin/dev` to test setup, and check browser console for any JavaScript errors.* |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,64 +23,53 @@ After a release, please make sure to run `bundle exec rake update_changelog`. Th | |
|
||
Changes since the last non-beta release. | ||
|
||
#### Fixed | ||
|
||
- Enable support for ReactRefreshWebpackPlugin v0.6.0 by adding conditional logic regarding configuration. [PR 1748](https://github.com/shakacode/react_on_rails/pull/1748) by [judahmeek](https://github.com/judahmeek). | ||
### [15.0.0] - 2025-08-28 | ||
|
||
- Replace RenderOptions.renderRequestId and use local trackers instead. This change should only be relevant to ReactOnRails Pro users. [PR 1745](https://github.com/shakacode/react_on_rails/pull/1745) by [AbanoubGhadban](https://github.com/AbanoubGhadban). | ||
See [Release Notes](docs/release-notes/15.0.0.md) for full details. | ||
|
||
- Fixed invalid warnings about non-exact versions when using a pre-release version of React on Rails, as well as missing warnings when using different pre-release versions of the gem and the Node package. [PR 1742](https://github.com/shakacode/react_on_rails/pull/1742) by [alexeyr-ci2](https://github.com/alexeyr-ci2). | ||
### Removed (Breaking Changes) | ||
|
||
### [15.0.0-rc.1] - 2025-06-18 | ||
- Deprecated `defer_generated_component_packs` configuration option. You should use `generated_component_packs_loading_strategy` instead. | ||
- Migration: | ||
- `defer_generated_component_packs: true` β `generated_component_packs_loading_strategy: :defer` | ||
- `defer_generated_component_packs: false` β `generated_component_packs_loading_strategy: :sync` | ||
- For best performance, use `generated_component_packs_loading_strategy: :async` | ||
- [PR 1712](https://github.com/shakacode/react_on_rails/pull/1712) by [AbanoubGhadban](https://github.com/AbanoubGhadban). | ||
- The package is ESM-only now. Migration: | ||
- If using `require('react-on-rails')`, upgrade to Node v20.19.0+ or change to `import`. | ||
- For TypeScript errors, upgrade to TypeScript 5.8+ and set `module` to `nodenext`. | ||
- `ReactOnRails.reactOnRailsPageLoaded` is now an async function. Migration: | ||
- Add `await` when calling this function: `await ReactOnRails.reactOnRailsPageLoaded()`. | ||
- `force_load` configuration now defaults to `true`. Migration: | ||
- Set `force_load: false` in your config if you want the previous behavior. | ||
Comment on lines
+38
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π‘ Verification agent π§© Analysis chainDouble-check minimum Node and TypeScript versions before publishing The stated floors (Node v20.19.0+, TypeScript 5.8+) may drift; ensure they match the package engines and actual build constraints. π Script executed: #!/usr/bin/env bash
set -euo pipefail
echo "Check Node engines in node package:"
fd package.json node_package -d 2 | xargs -I{} jq -r '.engines // {}' {}
echo "Scan for use of 'nodenext' and TS min version hints:"
rg -n --type=ts --type=json -C2 'nodenext|typescript' node_package
echo "Verify reactOnRailsPageLoaded is async in the Node package:"
rg -nP -C2 'export\s+async\s+function\s+reactOnRailsPageLoaded|\basync function reactOnRailsPageLoaded' node_package
echo "Verify force_load default is true on the Ruby side:"
rg -nP -C3 '\bforce_load\b.*=\s*true|attr_(reader|accessor).*force_load' lib
echo "Release notes file present:"
fd '15.0.0.md' docs | sed -n '1p' Length of output: 5569 π Script executed: #!/usr/bin/env bash
set -euo pipefail
# List all package.json files and inspect their engines field
echo "===== Engines in package.json files ====="
fd package.json -x sh -c 'echo "File: {}"; jq .engines {} 2>/dev/null || echo " (no engines field)"'
# Check TypeScript devDependency versions in each package.json
echo
echo "===== TypeScript versions in devDependencies ====="
fd package.json -x sh -c 'echo "File: {}"; jq ".devDependencies.typescript" {} 2>/dev/null || echo " (no typescript devDependency)"'
# Inspect tsconfig.json compilerOptions for module and moduleResolution settings
echo
echo "===== tsconfig.json module settings ====="
fd tsconfig.json -x sh -c 'echo "File: {}"; jq "{module: .compilerOptions.module, moduleResolution: .compilerOptions.moduleResolution}" {} 2>/dev/null' Length of output: 2130 π Script executed: #!/usr/bin/env bash
set -euo pipefail
echo "===== tsconfig.json compilerOptions ====="
jq .compilerOptions tsconfig.json 2>/dev/null || echo "(failed to parse tsconfig.json)"
echo
echo "===== CI Node versions in GitHub Actions ====="
grep -R "node-version" -n .github/workflows || echo "(none found)"
echo
echo "===== .nvmrc or .node-version files ====="
fd .nvmrc -x sh -c 'echo "File: {}"; cat {}' || echo "(none found)"
fd .node-version -x sh -c 'echo "File: {}"; cat {}' || echo "(none found)" Length of output: 1035 Align Node version in CHANGELOG with package.json engines CHANGELOG.md specifies Node v20.19.0+ but package.json has no "engines": { "node": ">=20.19.0" } to package.json or update the CHANGELOG to βNode v20+β to match CI. TypeScriptβs devDependency ( π€ Prompt for AI Agents
|
||
|
||
#### Improved | ||
For detailed migration instructions, see the [15.0.0 Release Notes](docs/release-notes/15.0.0.md). | ||
|
||
- Ensured that the RSC payload is injected after the component's HTML markup to improve the performance of the RSC payload injection. [PR 1738](https://github.com/shakacode/react_on_rails/pull/1738) by [AbanoubGhadban](https://github.com/AbanoubGhadban). | ||
#### Fixed | ||
|
||
### [15.0.0-rc.0] - 2025-06-16 | ||
- Enable support for ReactRefreshWebpackPlugin v0.6.0 by adding conditional logic regarding configuration. [PR 1748](https://github.com/shakacode/react_on_rails/pull/1748) by [judahmeek](https://github.com/judahmeek). | ||
- Replace RenderOptions.renderRequestId and use local trackers instead. This change should only be relevant to ReactOnRails Pro users. [PR 1745](https://github.com/shakacode/react_on_rails/pull/1745) by [AbanoubGhadban](https://github.com/AbanoubGhadban). | ||
- Fixed invalid warnings about non-exact versions when using a pre-release version of React on Rails, as well as missing warnings when using different pre-release versions of the gem and the Node package. [PR 1742](https://github.com/shakacode/react_on_rails/pull/1742) by [alexeyr-ci2](https://github.com/alexeyr-ci2). | ||
|
||
#### Improved | ||
|
||
- Ensured that the RSC payload is injected after the component's HTML markup to improve the performance of the RSC payload injection. [PR 1738](https://github.com/shakacode/react_on_rails/pull/1738) by [AbanoubGhadban](https://github.com/AbanoubGhadban). | ||
- Improved RSC rendering flow by eliminating double rendering of server components and reducing the number of HTTP requests. | ||
- Updated communication protocol between Node Renderer and Rails to version 2.0.0 which supports the ability to upload multiple bundles at once. | ||
- Added `RSCRoute` component to enable seamless server-side rendering of React Server Components. This component automatically handles RSC payload injection and hydration, allowing server components to be rendered directly within client components while maintaining optimal performance. | ||
|
||
[PR 1696](https://github.com/shakacode/react_on_rails/pull/1696) by [AbanoubGhadban](https://github.com/AbanoubGhadban). | ||
|
||
#### Added | ||
|
||
- Configuration option `generated_component_packs_loading_strategy` to control how generated component packs are loaded. It supports `sync`, `async`, and `defer` strategies. [PR 1712](https://github.com/shakacode/react_on_rails/pull/1712) by [AbanoubGhadban](https://github.com/AbanoubGhadban). | ||
|
||
- Support for returning React component from async render-function. [PR 1720](https://github.com/shakacode/react_on_rails/pull/1720) by [AbanoubGhadban](https://github.com/AbanoubGhadban). | ||
|
||
### Removed (Breaking Changes) | ||
|
||
- Deprecated `defer_generated_component_packs` configuration option. You should use `generated_component_packs_loading_strategy` instead. [PR 1712](https://github.com/shakacode/react_on_rails/pull/1712) by [AbanoubGhadban](https://github.com/AbanoubGhadban). | ||
|
||
### Changed | ||
|
||
- **Breaking change**: The package is ESM-only now. Please see [Release Notes](docs/release-notes/15.0.0.md#esm-only-package) for more details. | ||
- Added `RSCRoute` component to enable seamless server-side rendering of React Server Components. This component automatically handles RSC payload injection and hydration, allowing server components to be rendered directly within client components while maintaining optimal performance. [PR 1696](https://github.com/shakacode/react_on_rails/pull/1696) by [AbanoubGhadban](https://github.com/AbanoubGhadban). | ||
- The global context is now accessed using `globalThis`. [PR 1727](https://github.com/shakacode/react_on_rails/pull/1727) by [alexeyr-ci2](https://github.com/alexeyr-ci2). | ||
- Generated client packs now import from `react-on-rails/client` instead of `react-on-rails`. [PR 1706](https://github.com/shakacode/react_on_rails/pull/1706) by [alexeyr-ci](https://github.com/alexeyr-ci). | ||
- The "optimization opportunity" message when importing the server-side `react-on-rails` instead of `react-on-rails/client` in browsers is now a warning for two reasons: | ||
- Make it more prominent | ||
- Include a stack trace when clicked | ||
|
||
### [15.0.0-alpha.2] - 2025-03-07 | ||
|
||
See [Release Notes](docs/release-notes/15.0.0.md) for full details. | ||
|
||
#### Added | ||
|
||
- Configuration option `generated_component_packs_loading_strategy` to control how generated component packs are loaded. It supports `sync`, `async`, and `defer` strategies. [PR 1712](https://github.com/shakacode/react_on_rails/pull/1712) by [AbanoubGhadban](https://github.com/AbanoubGhadban). | ||
- Support for returning React component from async render-function. [PR 1720](https://github.com/shakacode/react_on_rails/pull/1720) by [AbanoubGhadban](https://github.com/AbanoubGhadban). | ||
- React Server Components Support (Pro Feature) [PR 1644](https://github.com/shakacode/react_on_rails/pull/1644) by [AbanoubGhadban](https://github.com/AbanoubGhadban). | ||
- Improved component and store hydration performance [PR 1656](https://github.com/shakacode/react_on_rails/pull/1656) by [AbanoubGhadban](https://github.com/AbanoubGhadban). | ||
|
||
#### Breaking Changes | ||
|
||
- `ReactOnRails.reactOnRailsPageLoaded` is now an async function | ||
- `force_load` configuration now defaults to `true` | ||
- `defer_generated_component_packs` configuration now defaults to `false` | ||
|
||
### [14.2.0] - 2025-03-03 | ||
|
||
#### Added | ||
|
@@ -1577,8 +1566,8 @@ such as: | |
|
||
- Fix several generator-related issues. | ||
|
||
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/15.0.0-alpha.2...master | ||
[15.0.0-alpha.2]: https://github.com/shakacode/react_on_rails/compare/14.2.0...15.0.0-alpha.2 | ||
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/15.0.0...master | ||
[15.0.0]: https://github.com/shakacode/react_on_rails/compare/14.2.0...15.0.0 | ||
[14.2.0]: https://github.com/shakacode/react_on_rails/compare/14.1.1...14.2.0 | ||
[14.1.1]: https://github.com/shakacode/react_on_rails/compare/14.1.0...14.1.1 | ||
[14.1.0]: https://github.com/shakacode/react_on_rails/compare/14.0.5...14.1.0 | ||
|
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.
this file should not be in the repo. I'll remove in a separate commit.