You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rename bundlePath to serverBundleCachePath in node renderer (#2008)
## Summary
This PR renames the `bundlePath` configuration option to
`serverBundleCachePath` in the node renderer to better describe its
purpose and avoid confusion with Shakapacker's public bundle path.
## Changes
- **Config interface**: Added `serverBundleCachePath` as the new
property, deprecated `bundlePath`
- **Deprecation handling**: Added warning messages when the old name is
used (both config and env var)
- **Environment variables**: Support both
`RENDERER_SERVER_BUNDLE_CACHE_PATH` (new) and `RENDERER_BUNDLE_PATH`
(deprecated)
- **Internal code**: Updated all internal code to use
`serverBundleCachePath`
- **Documentation**: Updated all docs and examples to use the new name
- **Tests**: Updated test files and helper functions to use the new name
- **Backwards compatibility**: The old `bundlePath` option continues to
work with deprecation warnings
## Why this change?
The name `bundlePath` was confusing because:
1. It could be confused with Shakapacker's public bundle path (where
client-side assets are served)
2. It didn't clearly indicate that this is a **cache directory** for
**uploaded server bundles**
3. The new name `serverBundleCachePath` makes the purpose explicit
## Migration guide
Users can update their configuration:
**Before:**
```js
const config = {
bundlePath: path.resolve(__dirname, './.node-renderer-bundles'),
};
```
**After:**
```js
const config = {
serverBundleCachePath: path.resolve(__dirname, './.node-renderer-bundles'),
};
```
**Environment variable:**
- Old: `RENDERER_BUNDLE_PATH`
- New: `RENDERER_SERVER_BUNDLE_CACHE_PATH`
Both the old config option and env var will continue to work with
deprecation warnings.
## Test plan
- [x] ESLint passes
- [x] RuboCop passes
- [x] All documentation updated
- [x] Backwards compatibility maintained
🤖 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/2008)
<!-- Reviewable:end -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: react_on_rails_pro/docs/installation.md
+37-22Lines changed: 37 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
1
# Installation
2
+
2
3
Since the repository is private, you will get a **GitHub Personal Access Token** and an account that can access the packages. Substitute that value in the commands below. If you dont' have this, ask [justin@shakacode.com](mailto:justin@shakacode.com) to give you one.
3
4
4
5
Check the [CHANGELOG](https://github.com/shakacode/react_on_rails_pro/blob/master/CHANGELOG.md) to see what version you want.
@@ -8,13 +9,16 @@ Check the [CHANGELOG](https://github.com/shakacode/react_on_rails_pro/blob/maste
8
9
For the below docs, find the desired `<version>` in the CHANGELOG. Note, for pre-release versions, gems have all periods, and node packages uses a dash, like gem `3.0.0.rc.0` and node package `3.0.0-rc.0`.
9
10
10
11
# Ruby
12
+
11
13
## Gem Installation
14
+
12
15
1. Ensure your **Rails** app is using the **react_on_rails** gem, version greater than 11.0.7.
13
-
1. Add the `react_on_rails_pro` gem to your **Gemfile**. Substitute the appropriate version number.
14
-
16
+
1. Add the `react_on_rails_pro` gem to your **Gemfile**. Substitute the appropriate version number.
17
+
15
18
## Gemfile Change
16
19
17
20
Replace the following in the snippet for the Gemfile
21
+
18
22
1.`<account>` for the api key
19
23
2.`<api-key>`
20
24
3.`<version>` desired
@@ -33,6 +37,7 @@ source "https://rubygems.pkg.github.com/shakacode-tools" do
33
37
gem "react_on_rails_pro", "<version>"
34
38
end
35
39
```
40
+
36
41
Or use the `gem install` command:
37
42
38
43
```bash
@@ -46,30 +51,35 @@ bundle config set rubygems.pkg.github.com <username>:<token>
46
51
```
47
52
48
53
## Using a branch in your Gemfile
54
+
49
55
Note, you should probably use an ENV value for the token so that you don't check this into your source code.
If you really want to use yarn, see [Yarn can't find private Github npm registry](https://stackoverflow.com/questions/58316109/yarn-cant-find-private-github-npm-registry)
88
98
89
-
5. You can start the renderer with either the executable `node-renderer` or, preferably, with
99
+
5. You can start the renderer with either the executable `node-renderer` or, preferably, with
90
100
a startup JS file, say called `react-on-rails-pro/react-on-rails-pro-node-renderer.js` with
91
-
these contents. _Note the use of the namespaced **`@shakacode-tools/react-on-rails-pro-node-renderer`**for the package.
101
+
these contents. \_Note the use of the namespaced **`@shakacode-tools/react-on-rails-pro-node-renderer`**for the package.
See [NodeRenderer JavaScript Configuration](./node-renderer/js-configuration.md).
171
182
172
183
#### Webpack Configuration
184
+
173
185
Set your server bundle webpack configuration to use a target of `node` per the [Webpack docs](https://webpack.js.org/concepts/targets/#usage).
174
186
175
187
## Authentication when using Github packages
188
+
176
189
[Auth for the npm package](https://docs.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-npm-for-use-with-github-packages#authenticating-to-github-packages)
177
190
178
191
Create a new ~/.npmrc file if one doesn't exist.
192
+
179
193
```
180
194
//npm.pkg.github.com/:_authToken=TOKEN
181
-
```
195
+
```
182
196
183
197
To configure bundler if you don't want the token in your Gemfile:
**node-renderer** is a standalone Node application to serve React SSR requests from a **Rails** client. You don't need any **Ruby** code to setup and launch it. You can configure with the command line or with a launch file.
9
12
10
13
## Simple Command Line for node-renderer
11
14
12
15
1. ENV values for the default config are (See [JS Configuration](./js-configuration.md) for more details):
4. Configure a JavaScript file that will launch the rendering server per the docs in [Node Renderer JavaScript Configuration](./js-configuration.md). For example, create a file `node-renderer.js`. Here is a simple example that uses all the defaults except for bundlePath:
45
+
4. Configure a JavaScript file that will launch the rendering server per the docs in [Node Renderer JavaScript Configuration](./js-configuration.md). For example, create a file `node-renderer.js`. Here is a simple example that uses all the defaults except for serverBundleCachePath:
5. Now you can launch your renderer server with `node node-renderer.js`. You will probably add a script to your `package.json`.
54
59
6. You can use a command line argument of `-p SOME_PORT` to override any configured or ENV value for the port.
55
60
56
61
# Setup Rails Application
62
+
57
63
Create `config/initializers/react_on_rails_pro.rb` and configure the **renderer server**. See configuration values in [Configuration](../configuration.md). Pay attention to:
58
64
59
65
1. Set `config.server_renderer = "NodeRenderer"`
60
66
2. Leave the default of `config.prerender_caching = true` and ensure your Rails cache is properly configured to handle the additional cache load.
61
67
3. Configure values beginning with `renderer_`
62
68
4. Use ENV values for values like `renderer_url` so that your deployed server is properly configured. If the ENV value is unset, the default for the renderer_url is `localhost:3800`.
63
69
5. Here's a tiny example using mostly defaults:
70
+
64
71
```ruby
65
72
ReactOnRailsPro.configure do |config|
66
73
config.server_renderer ="NodeRenderer"
67
-
68
-
# when this ENV value is not defined, the local server at localhost:3800 is used
69
-
config.renderer_url =ENV["REACT_RENDERER_URL"]
74
+
75
+
# when this ENV value is not defined, the local server at localhost:3800 is used
76
+
config.renderer_url =ENV["REACT_RENDERER_URL"]
70
77
end
71
78
```
72
79
73
80
## Troublshooting
74
81
75
-
* See [JS Memory Leaks](../js-memory-leaks.md).
76
-
82
+
- See [JS Memory Leaks](../js-memory-leaks.md).
83
+
77
84
## Upgrading
78
85
79
86
The NodeRenderer has a protocol version on both the Rails and Node sides. If the Rails server sends a protocol version that does not match the Node side, an error is returned. Ideally, you want to keep both the Rails and Node sides at the same version.
80
87
81
88
## References
82
89
83
-
*[Installation](../installation.md).
84
-
*[Rails Options for node-renderer](../configuration.md)
85
-
*[JS Options for node-renderer](./js-configuration.md)
90
+
-[Installation](../installation.md).
91
+
-[Rails Options for node-renderer](../configuration.md)
92
+
-[JS Options for node-renderer](./js-configuration.md)
0 commit comments