Skip to content

Commit 6409951

Browse files
committed
Simplify v16.1.x upgrade documentation
- Use exact versions in examples (not ~>) - Remove package manager-specific commands (support all) - Reduce verbosity for minor/patch release upgrade - Focus on essential information
1 parent d9a6e91 commit 6409951

File tree

2 files changed

+27
-236
lines changed

2 files changed

+27
-236
lines changed

docs/upgrading/release-notes/16.1.0.md

Lines changed: 25 additions & 190 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,16 @@
22

33
## Upgrading from 16.0.x to 16.1.x
44

5-
This guide covers upgrading from React on Rails v16.0.x to v16.1.1.
6-
7-
### Step 1: Update Dependencies
8-
9-
**Gemfile:**
5+
Update your gem and npm package versions:
106

117
```ruby
12-
gem "react_on_rails", "~> 16.1.1"
13-
gem "shakapacker", "~> 8.2.0" # Recommended for compatibility
8+
# Gemfile
9+
gem "react_on_rails", "16.1.1"
10+
gem "shakapacker", "8.2.0"
1411
```
1512

16-
**package.json:**
17-
1813
```json
14+
// package.json
1915
{
2016
"dependencies": {
2117
"react-on-rails": "16.1.1",
@@ -24,67 +20,21 @@ gem "shakapacker", "~> 8.2.0" # Recommended for compatibility
2420
}
2521
```
2622

27-
**Important:** The shakapacker gem and npm package versions MUST match exactly.
28-
29-
### Step 2: Install Updates
30-
31-
```bash
32-
bundle update react_on_rails shakapacker
33-
yarn install # or npm install
34-
```
35-
36-
### Step 3: Run the Generator (Optional)
23+
Then run `bundle install` and your package manager's install command.
3724

38-
Run the generator to get the latest improvements:
25+
**Important:** The shakapacker gem and npm package versions must match exactly.
3926

40-
```bash
41-
rails generate react_on_rails:install
42-
```
43-
44-
**Note:** The generator will prompt to overwrite files. Review each change carefully, especially if you have customizations. Key files that may be updated:
45-
46-
- `bin/dev` - Enhanced development workflow
47-
- Webpack configurations
48-
- `shakapacker.yml` settings
49-
- TypeScript configuration
27+
## New Features in v16.1.0
5028

51-
### Step 4: Use the New Doctor Command
29+
### Doctor Rake Task
5230

53-
v16.1.0 introduces a diagnostic rake task to validate your setup:
31+
New diagnostic command for troubleshooting setup issues:
5432

5533
```bash
5634
rake react_on_rails:doctor
35+
VERBOSE=true rake react_on_rails:doctor # For detailed output
5736
```
5837

59-
For detailed output:
60-
61-
```bash
62-
VERBOSE=true rake react_on_rails:doctor
63-
```
64-
65-
The doctor command checks:
66-
67-
- Environment prerequisites
68-
- Dependencies and version compatibility
69-
- Rails integration
70-
- Webpack configuration
71-
- Shakapacker setup
72-
73-
### Step 5: Test Your Application
74-
75-
```bash
76-
# Test asset compilation
77-
bundle exec rails assets:precompile
78-
79-
# Test development server
80-
bin/dev
81-
82-
# Run your test suite
83-
bundle exec rspec # or your test command
84-
```
85-
86-
## New Features in v16.1.0
87-
8838
### Server Bundle Security
8939

9040
New configuration options for enhanced server bundle security:
@@ -93,153 +43,38 @@ New configuration options for enhanced server bundle security:
9343
# config/initializers/react_on_rails.rb
9444
ReactOnRails.configure do |config|
9545
# Directory for server bundle output (default: "ssr-generated")
96-
# Set to nil to load from public directory (legacy behavior)
9746
config.server_bundle_output_path = "ssr-generated"
9847

9948
# When enabled, server bundles only load from private directories
100-
# (default: false for backward compatibility)
10149
config.enforce_private_server_bundles = true
10250
end
10351
```
10452

105-
**Bundle Path Resolution Logic:**
106-
107-
1. If `server_bundle_output_path` is set, server bundles load from that directory
108-
2. If not set, falls back to client bundle directory (public output path)
109-
3. When `enforce_private_server_bundles` is enabled:
110-
- Server bundles only load from the private directory
111-
- No fallback to public directory (improved security)
112-
113-
### Doctor Rake Task
114-
115-
New diagnostic command for troubleshooting:
116-
117-
```bash
118-
rake react_on_rails:doctor
119-
```
120-
121-
Provides comprehensive checks for:
122-
123-
- Environment prerequisites
124-
- Dependency versions
125-
- Rails integration
126-
- Webpack configuration
127-
- Common setup issues
128-
12953
### Generator Improvements
13054

131-
- **Modern TypeScript patterns**: Better type inference instead of explicit annotations
132-
- **Optimized tsconfig.json**: Uses `"moduleResolution": "bundler"` for bundler compatibility
133-
- **Enhanced Redux TypeScript**: Improved type safety with modern React patterns (useMemo, type-only imports)
134-
- **Smart bin/dev defaults**: Auto-navigates to `/hello_world` route for immediate component visibility
135-
- **Cleaner generated code**: Follows modern React and TypeScript best practices
136-
137-
## Deprecations
138-
139-
### `generated_assets_dirs` Configuration
140-
141-
The `config.generated_assets_dirs` option is deprecated. Remove it from `config/initializers/react_on_rails.rb`.
142-
143-
**Why:** Since Shakapacker is now required, asset paths are automatically determined from `shakapacker.yml`.
144-
145-
**Migration:** Use `public_output_path` in `config/shakapacker.yml` to customize asset output location.
146-
147-
### `generated_assets_full_path` Method
148-
149-
Use `public_bundles_full_path` instead for clarity about webpack bundles in public directories.
150-
151-
## Bug Fixes in v16.1.1
55+
- Modern TypeScript patterns with better type inference
56+
- Optimized tsconfig.json with `"moduleResolution": "bundler"`
57+
- Enhanced Redux TypeScript integration
58+
- Smart `bin/dev` defaults
15259

153-
- **React Server Components**: Fixed bug in resolving `react-server-client-manifest.json` file path. The manifest file path is now correctly resolved using `bundle_js_file_path` for improved configuration flexibility. [PR 1818](https://github.com/shakacode/react_on_rails/pull/1818)
60+
## Bug Fixes
15461

155-
## Bug Fixes in v16.1.0
62+
### v16.1.1
15663

157-
- **Doctor rake task**: Fixed LoadError when using packaged gem
158-
- **Packs generator**: Fixed error when `server_bundle_js_file` is empty
159-
- **Non-Packer compatibility**: Fixed NoMethodError in environments without Shakapacker
160-
- **Shakapacker version requirements**: Fixed inconsistent version requirements between basic pack generation (6.5.1+) and advanced auto-bundling (7.0.0+)
64+
- Fixed RSC manifest file path resolution ([PR 1818](https://github.com/shakacode/react_on_rails/pull/1818))
16165

162-
## Security Enhancements
66+
### v16.1.0
16367

164-
- **Private Server Bundle Enforcement**: Server bundles bypass public directory fallbacks when `enforce_private_server_bundles` is enabled
165-
- **Path Validation**: Validates `server_bundle_output_path` points to private directories when enforcement is enabled
166-
- **Command injection fixes**: Replaced unsafe string interpolation with secure array-based system calls
167-
- **Input validation**: Enhanced package manager validation and argument sanitization
168-
- **Hardened DOM selectors**: Using `CSS.escape()` and proper JavaScript escaping for XSS protection
169-
170-
## Version Compatibility
171-
172-
| react_on_rails | shakapacker (gem) | shakapacker (npm) | Rails | Ruby |
173-
| -------------- | ----------------- | ----------------- | ----- | ---- |
174-
| 16.1.x | 8.2.0+ | 8.2.0+ | 6.0+ | 3.2+ |
175-
| 16.0.x | 6.0.0+ | 6.0.0+ | 6.0+ | 3.2+ |
176-
177-
**Recommended versions:**
178-
179-
- Shakapacker 8.2.0 (gem and npm versions must match)
180-
- React 18+
181-
- Node.js 20+
182-
- Ruby 3.2+
183-
184-
## Common Upgrade Issues
185-
186-
### Generator Prerequisites Error
187-
188-
```
189-
ERROR: You have uncommitted changes
190-
```
68+
- Fixed LoadError in `rake react_on_rails:doctor` when using packaged gem
69+
- Fixed packs generator error when `server_bundle_js_file` is empty
70+
- Fixed NoMethodError in environments without Shakapacker
71+
- Fixed inconsistent Shakapacker version requirements
19172

192-
**Solution:** Commit or stash your changes before running the generator.
193-
194-
### Shakapacker Version Mismatch
195-
196-
```
197-
Shakapacker gem and node package versions do not match
198-
```
199-
200-
**Solution:** Ensure both gem and npm package are the same version:
201-
202-
```bash
203-
# Check versions
204-
bundle show shakapacker
205-
yarn list shakapacker # or npm ls shakapacker
206-
207-
# Update to match
208-
bundle update shakapacker
209-
yarn upgrade shakapacker@8.2.0
210-
```
211-
212-
### Test Failures After Upgrade
213-
214-
1. **Rebuild ReScript files** (if using ReScript):
215-
216-
```bash
217-
yarn res:build
218-
```
219-
220-
2. **Clear webpack cache**:
221-
222-
```bash
223-
rm -rf node_modules/.cache
224-
rm -rf public/packs*
225-
```
226-
227-
3. **Precompile assets**:
228-
```bash
229-
rails assets:precompile
230-
```
231-
232-
### Server Bundle Not Found
233-
234-
If you're using server-side rendering and the server bundle isn't found:
73+
## Deprecations
23574

236-
1. Check `config.server_bundle_output_path` is correctly set
237-
2. Run `rake react_on_rails:doctor` to diagnose issues
238-
3. Verify webpack builds both client and server bundles
75+
Remove `config.generated_assets_dirs` from your configuration - asset paths are now automatically determined from `shakapacker.yml`.
23976

24077
## Related Resources
24178

24279
- [Changelog](https://github.com/shakacode/react_on_rails/blob/master/CHANGELOG.md)
24380
- [Configuration Reference](../../api-reference/configuration.md)
244-
- [Troubleshooting Guide](../../deployment/troubleshooting.md)
245-
- [Example upgrade PR: react-webpack-rails-tutorial#654](https://github.com/shakacode/react-webpack-rails-tutorial/pull/654)

docs/upgrading/upgrading-react-on-rails.md

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -23,53 +23,9 @@ rails generate react_on_rails:install
2323

2424
## Upgrading to v16.1.x (from v16.0.x)
2525

26-
For detailed upgrade instructions, see the [v16.1.x Release Notes](release-notes/16.1.0.md).
26+
This is a minor release - update your gem and npm package versions, then run `bundle install` and your package manager's install command. See the [v16.1.x Release Notes](release-notes/16.1.0.md) for new features and bug fixes.
2727

28-
### Quick Summary
29-
30-
v16.1.x is a minor release with new features and bug fixes:
31-
32-
- **New `rake react_on_rails:doctor` command** for diagnosing setup issues
33-
- **Server bundle security enhancements** with `server_bundle_output_path` and `enforce_private_server_bundles` options
34-
- **Generator improvements** with modern TypeScript patterns and better defaults
35-
- **Bug fix (v16.1.1)**: Fixed RSC manifest file path resolution
36-
37-
### Upgrade Steps
38-
39-
1. Update dependencies:
40-
41-
```ruby
42-
# Gemfile
43-
gem "react_on_rails", "~> 16.1.1"
44-
gem "shakapacker", "~> 8.2.0"
45-
```
46-
47-
```json
48-
// package.json - versions must match exactly
49-
{
50-
"dependencies": {
51-
"react-on-rails": "16.1.1",
52-
"shakapacker": "8.2.0"
53-
}
54-
}
55-
```
56-
57-
2. Install and verify:
58-
59-
```bash
60-
bundle update react_on_rails shakapacker
61-
yarn install
62-
rake react_on_rails:doctor # New diagnostic command
63-
```
64-
65-
3. Optionally run generator for latest improvements:
66-
```bash
67-
rails generate react_on_rails:install
68-
```
69-
70-
### Deprecation Notice
71-
72-
Remove `config.generated_assets_dirs` from your configuration - asset paths are now automatically determined from `shakapacker.yml`.
28+
**Deprecation:** Remove `config.generated_assets_dirs` from your configuration if present.
7329

7430
## Upgrading to v16 (from v14/v15)
7531

0 commit comments

Comments
 (0)