Skip to content

Commit e612f66

Browse files
justin808claude
andauthored
Simplify configuration files to improve usability (#2011)
## Summary After PR #1993 introduced sensible defaults for advanced options like `generated_component_packs_loading_strategy` (auto-configured based on Pro license), we can significantly simplify generated configuration files and documentation to make React on Rails easier to use. This PR reduces configuration complexity while maintaining full functionality through smart defaults. ## Key Improvements ### Generator Template Simplification - **Reduced from 67 to 42 lines** (37% reduction) - Removed redundant explanations for options with good defaults - Added clear pointer to docs for advanced configuration - Kept only essential options in generated files - Made file-system component registry commented out (optional feature) ### Documentation Restructuring - Added **"Quick Start" section** showing minimal 2-3 line config - Reorganized into **"Essential" vs "Advanced"** configuration sections - Documented which options **auto-configure based on Pro license** - Added clear defaults and recommendations for each option - Improved searchability with structured sections - Added deprecation section for `immediate_hydration` ### Configuration Categories **Essential Configuration** (in generated files): - `server_bundle_js_file` - Required for SSR - `build_test_command` - Used for testing - `components_subdirectory` - Optional file-based registry - `auto_load_bundle` - Optional auto-loading **Advanced Configuration** (docs only, sensible defaults): - `generated_component_packs_loading_strategy` - Auto: `:async` for Pro, `:defer` for non-Pro - `server_bundle_output_path` - Default: `"ssr-generated"` - `enforce_private_server_bundles` - Default: `false` - All rendering pool, debugging, and customization options ### Dummy App Updates - Updated all dummy app configs with clear comments - Separated essential from test-specific configuration - Maintained same functionality with better organization ## Example: Before and After **Before** (67 lines with lots of inline documentation): ```ruby ReactOnRails.configure do |config| # This configures the script to run to build the production assets by webpack... # [30 lines of comments explaining options] config.server_bundle_js_file = "server-bundle.js" config.server_bundle_output_path = "ssr-generated" config.enforce_private_server_bundles = true # [More options and explanations] end ``` **After** (42 lines, clearer structure): ```ruby ReactOnRails.configure do |config| # Server Rendering config.server_bundle_js_file = "server-bundle.js" # Test Configuration config.build_test_command = "RAILS_ENV=test bin/shakapacker" # File System Based Component Registry (Optional) # config.components_subdirectory = "ror_components" # config.auto_load_bundle = true # Advanced Configuration # See: https://github.com/shakacode/react_on_rails/blob/master/docs/api-reference/configuration.md end ``` ## Benefits 1. **Reduced cognitive load**: New users see only 2-3 required config options 2. **Clear upgrade path**: Easy progression from simple to advanced configuration 3. **Decision fatigue reduction**: Fewer choices to make during setup 4. **Better reflects improvements**: Showcases PR #1993's auto-configuration 5. **Easier onboarding**: Clearer understanding of what needs customization ## Testing - ✅ All configuration specs pass - ✅ RuboCop passes on all modified files - ✅ Pre-commit hooks pass (Prettier, ESLint, trailing newlines) - ✅ Dummy apps load successfully with simplified configs ## Files Changed - `lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt` - Simplified generator template - `docs/api-reference/configuration.md` - Restructured documentation with Essential/Advanced sections - `spec/dummy/config/initializers/react_on_rails.rb` - Updated with better organization - `react_on_rails_pro/spec/dummy/config/initializers/react_on_rails.rb` - Updated Pro dummy - `react_on_rails_pro/spec/execjs-compatible-dummy/config/initializers/react_on_rails.rb` - Updated execjs dummy ## Related - Follow-up to PR #1993 (immediate hydration and loading strategy auto-configuration) - Addresses the goal of making React on Rails easier to use with sensible defaults 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- Reviewable:start --> - - - This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/shakacode/react_on_rails/2011) <!-- Reviewable:end --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Added a reworked main configuration reference with examples, a deprecated/removed options guide, Pro configuration docs, and a new testing-configuration guide. * **New Features** * Added diagnostics that detect inconsistent server-side rendering and test asset compilation setups and surface actionable guidance. * **Tests** * Updated test app configuration examples and defaults to clarify testing behaviors and recommended setups. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent cbee429 commit e612f66

File tree

10 files changed

+1327
-416
lines changed

10 files changed

+1327
-416
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ Changes since the last non-beta release.
5353

5454
- **`generated_component_packs_loading_strategy` now defaults based on Pro license**: When using Shakapacker >= 8.2.0, the default loading strategy is now `:async` for Pro users and `:defer` for non-Pro users. This provides optimal performance for Pro users while maintaining compatibility for non-Pro users. You can still explicitly set the strategy in your configuration. [PR #1993](https://github.com/shakacode/react_on_rails/pull/1993) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
5555

56+
#### Documentation
57+
58+
- **Simplified Configuration Files**: Improved configuration documentation and generator template for better clarity and usability. Reduced generator template from 67 to 42 lines (37% reduction). Added comprehensive testing configuration guide. Reorganized configuration docs into Essential vs Advanced sections. Enhanced Doctor program with diagnostics for server rendering and test compilation consistency. [PR #2011](https://github.com/shakacode/react_on_rails/pull/2011) by [justin808](https://github.com/justin808).
59+
5660
#### Deprecated
5761

5862
- **Node Renderer Configuration**: Renamed `bundlePath` configuration option to `serverBundleCachePath` in the node renderer to better describe its purpose and avoid confusion with Shakapacker's public bundle path. The old `bundlePath` option continues to work with deprecation warnings. Both `RENDERER_SERVER_BUNDLE_CACHE_PATH` (new) and `RENDERER_BUNDLE_PATH` (deprecated) environment variables are supported. [PR #2008](https://github.com/shakacode/react_on_rails/pull/2008) by [justin808](https://github.com/justin808).
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Deprecated Configuration Options
2+
3+
This document lists configuration options that have been deprecated or removed from React on Rails.
4+
5+
For current configuration options, see [configuration.md](configuration.md).
6+
7+
## Removed Options
8+
9+
### immediate_hydration
10+
11+
**Status:** ⚠️ REMOVED in v17.0
12+
13+
This configuration option has been removed. Immediate hydration is now automatically enabled for Pro users and disabled for non-Pro users.
14+
15+
**Migration:** Remove any `config.immediate_hydration` lines from your configuration. Use per-component overrides if needed:
16+
17+
```ruby
18+
# Pro users can disable for specific components:
19+
react_component("MyComponent", immediate_hydration: false)
20+
21+
# Non-Pro users: immediate_hydration is ignored
22+
```
23+
24+
See [CHANGELOG.md](../../CHANGELOG.md) for details.
25+
26+
## Deprecated Options
27+
28+
### defer_generated_component_packs
29+
30+
**Type:** Boolean
31+
**Default:** `false`
32+
**Status:** ⚠️ DEPRECATED
33+
34+
**Renamed to:** `generated_component_packs_loading_strategy = :defer`
35+
36+
**Migration:**
37+
38+
```ruby
39+
# Old (deprecated):
40+
config.defer_generated_component_packs = true
41+
42+
# New:
43+
config.generated_component_packs_loading_strategy = :defer
44+
```
45+
46+
See [CHANGELOG.md](../../CHANGELOG.md) for more details.
47+
48+
## Need Help?
49+
50+
- **Documentation:** [React on Rails Guides](https://www.shakacode.com/react-on-rails/docs/)
51+
- **Support:** [ShakaCode Forum](https://forum.shakacode.com/)
52+
- **Consulting:** [justin@shakacode.com](mailto:justin@shakacode.com)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# React on Rails Pro Configuration Options
2+
3+
This document describes configuration options specific to React on Rails Pro features.
4+
5+
For general React on Rails configuration options, see [configuration.md](configuration.md).
6+
7+
## React Server Components (RSC)
8+
9+
React Server Components and Streaming SSR are React on Rails Pro features.
10+
11+
For detailed configuration of RSC and streaming features, see the Pro package documentation:
12+
[react_on_rails_pro/docs/configuration.md](https://github.com/shakacode/react_on_rails/blob/master/react_on_rails_pro/docs/configuration.md)
13+
14+
> **Note:** The Pro documentation is currently maintained separately in the `react_on_rails_pro` directory. We plan to migrate and consolidate Pro documentation into the main docs structure in a future PR for better discoverability and consistency.
15+
16+
### Key Pro Configurations
17+
18+
These options are configured in the `ReactOnRailsPro.configure` block:
19+
20+
- `rsc_bundle_js_file` - Path to RSC bundle
21+
- `react_client_manifest_file` - Client component manifest for RSC
22+
- `react_server_client_manifest_file` - Server manifest for RSC
23+
- `enable_rsc_support` - Enable React Server Components
24+
25+
### Example Configuration
26+
27+
```ruby
28+
# config/initializers/react_on_rails_pro.rb
29+
ReactOnRailsPro.configure do |config|
30+
config.rsc_bundle_js_file = "rsc-bundle.js"
31+
config.react_client_manifest_file = "client-manifest.json"
32+
config.react_server_client_manifest_file = "server-manifest.json"
33+
config.enable_rsc_support = true
34+
end
35+
```
36+
37+
See the Pro documentation for complete setup instructions.
38+
39+
## Need Help?
40+
41+
- **Pro Features:** [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro/)
42+
- **Consulting:** [justin@shakacode.com](mailto:justin@shakacode.com)

0 commit comments

Comments
 (0)