react_on_rails_pro 16.2.0.test.6 → 16.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.prettierignore +3 -0
- data/.rubocop.yml +7 -90
- data/CHANGELOG.md +16 -7
- data/CONTRIBUTING.md +64 -43
- data/Gemfile.development_dependencies +4 -4
- data/Gemfile.loader +11 -8
- data/Gemfile.lock +147 -124
- data/README.md +1 -1
- data/docs/bundle-caching.md +22 -8
- data/docs/caching.md +39 -27
- data/docs/code-splitting-loadable-components.md +71 -55
- data/docs/code-splitting.md +74 -70
- data/docs/configuration.md +6 -6
- data/docs/contributors-info/onboarding-customers.md +2 -1
- data/docs/contributors-info/releasing.md +1 -0
- data/docs/contributors-info/style.md +23 -15
- data/docs/home-pro.md +33 -15
- data/docs/installation.md +57 -9
- data/docs/js-memory-leaks.md +2 -3
- data/docs/node-renderer/debugging.md +5 -1
- data/docs/node-renderer/error-reporting-and-tracing.md +27 -15
- data/docs/node-renderer/heroku.md +4 -5
- data/docs/profiling-server-side-rendering-code.md +43 -42
- data/docs/react-server-components/add-streaming-and-interactivity.md +1 -1
- data/docs/react-server-components/create-without-ssr.md +18 -18
- data/docs/react-server-components/glossary.md +22 -3
- data/docs/react-server-components/how-react-server-components-work.md +25 -18
- data/docs/react-server-components/inside-client-components.md +19 -18
- data/docs/react-server-components/purpose-and-benefits.md +24 -14
- data/docs/react-server-components/rendering-flow.md +7 -3
- data/docs/react-server-components/server-side-rendering.md +23 -22
- data/docs/release-notes/4.0.md +103 -94
- data/docs/release-notes/v4-react-server-components.md +16 -16
- data/docs/streaming-server-rendering.md +2 -4
- data/docs/troubleshooting.md +5 -2
- data/docs/updating.md +55 -20
- data/lib/react_on_rails_pro/request.rb +18 -3
- data/lib/react_on_rails_pro/version.rb +1 -1
- data/rakelib/dummy_apps.rake +4 -4
- data/rakelib/lint.rake +1 -1
- data/rakelib/run_rspec.rake +3 -3
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aa36f2c2ebdd0fd2c8b42a44ea5809bf6b406ad5dfefe82f3f87643fd361368c
|
|
4
|
+
data.tar.gz: 6d0c478dea603606fe530d2e6dcec612240263dc9bc32e001d166c38f86932be
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 33992470f693ecdb68975cbc2bec28c2ae04f059c9e4af5e9b6debdad0a9d64894df6642baf80bd765be4d46f8e526084ab516541c26ba6c5b0bb6281d570d49
|
|
7
|
+
data.tar.gz: '08c66853fd310d4d961e2c8045a701404c67fb6f361c6d3a7c00b887c3c619c88bf3b563604aacf79bd1850f596d25a9c74403c0a7337dc788df60ef19c0aa3f'
|
data/.prettierignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,111 +1,31 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
require:
|
|
4
|
-
- rubocop-performance
|
|
5
|
-
- rubocop-rspec
|
|
1
|
+
# Inherits from root config
|
|
2
|
+
inherit_from: ../.rubocop.yml
|
|
6
3
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Include:
|
|
13
|
-
- '**/Rakefile'
|
|
14
|
-
- '**/config.ru'
|
|
15
|
-
- 'Gemfile'
|
|
16
|
-
- '**/*.rb'
|
|
17
|
-
- '**/*.rake'
|
|
4
|
+
# Merge Exclude arrays with parent instead of replacing them
|
|
5
|
+
inherit_mode:
|
|
6
|
+
merge:
|
|
7
|
+
- Exclude
|
|
18
8
|
|
|
9
|
+
AllCops:
|
|
19
10
|
Exclude:
|
|
20
11
|
<% `git status --ignored --porcelain`.lines.grep(/^!! /).each do |path| %>
|
|
21
12
|
- <%= path.sub(/^!! /, '') %>
|
|
22
13
|
<% end %>
|
|
23
|
-
- '**/node_modules/**/*'
|
|
24
14
|
- 'db/schema.rb'
|
|
25
15
|
- 'db/seeds.rb'
|
|
26
|
-
- 'spec/fixtures/**/*'
|
|
27
16
|
- 'spec/dummy/db/schema.rb'
|
|
28
17
|
- 'spec/dummy/bin/**/*'
|
|
29
|
-
- 'node_modules/**/*'
|
|
30
|
-
- 'coverage/**/*'
|
|
31
18
|
- 'bin/**/*'
|
|
32
|
-
- 'vendor/**/*'
|
|
33
|
-
|
|
34
|
-
Naming/FileName:
|
|
35
|
-
Exclude:
|
|
36
|
-
- '**/Gemfile'
|
|
37
|
-
- '**/Rakefile'
|
|
38
|
-
|
|
39
|
-
Layout/LineLength:
|
|
40
|
-
Max: 120
|
|
41
|
-
|
|
42
|
-
Style/StringLiterals:
|
|
43
|
-
EnforcedStyle: double_quotes
|
|
44
|
-
|
|
45
|
-
Style/Documentation:
|
|
46
|
-
Enabled: false
|
|
47
|
-
|
|
48
|
-
Style/HashEachMethods:
|
|
49
|
-
Enabled: true
|
|
50
|
-
|
|
51
|
-
Style/HashTransformKeys:
|
|
52
|
-
Enabled: true
|
|
53
|
-
|
|
54
|
-
Style/HashTransformValues:
|
|
55
|
-
Enabled: true
|
|
56
|
-
|
|
57
|
-
Metrics/AbcSize:
|
|
58
|
-
Max: 28
|
|
59
|
-
|
|
60
|
-
Metrics/CyclomaticComplexity:
|
|
61
|
-
Max: 8
|
|
62
|
-
|
|
63
|
-
Metrics/PerceivedComplexity:
|
|
64
|
-
Max: 10
|
|
65
|
-
|
|
66
|
-
Metrics/ClassLength:
|
|
67
|
-
Max: 140
|
|
68
|
-
|
|
69
|
-
Metrics/ParameterLists:
|
|
70
|
-
Max: 5
|
|
71
|
-
CountKeywordArgs: false
|
|
72
|
-
|
|
73
|
-
Metrics/MethodLength:
|
|
74
|
-
Max: 41
|
|
75
|
-
|
|
76
|
-
Metrics/ModuleLength:
|
|
77
|
-
Max: 180
|
|
78
|
-
|
|
79
|
-
RSpec/DescribeClass:
|
|
80
|
-
Enabled: false
|
|
81
|
-
|
|
82
|
-
RSpec/ExampleLength:
|
|
83
|
-
Enabled: false
|
|
84
|
-
|
|
85
|
-
RSpec/MessageSpies:
|
|
86
|
-
Enabled: false
|
|
87
|
-
|
|
88
|
-
RSpec/NestedGroups:
|
|
89
|
-
Max: 5
|
|
90
19
|
|
|
91
20
|
RSpec/BeforeAfterAll:
|
|
92
21
|
Exclude:
|
|
93
22
|
- 'spec/react_on_rails/generators/dev_tests_generator_spec.rb'
|
|
94
23
|
- 'spec/react_on_rails/generators/install_generator_spec.rb'
|
|
95
24
|
|
|
96
|
-
RSpec/MessageChain:
|
|
97
|
-
Enabled: false
|
|
98
|
-
|
|
99
|
-
RSpec/MultipleExpectations:
|
|
100
|
-
Enabled: false
|
|
101
|
-
|
|
102
25
|
RSpec/MultipleDescribes:
|
|
103
26
|
Exclude:
|
|
104
27
|
- 'spec/dummy/spec/system/integration_spec.rb'
|
|
105
28
|
|
|
106
|
-
RSpec/MultipleMemoizedHelpers:
|
|
107
|
-
Max: 12
|
|
108
|
-
|
|
109
29
|
RSpec:
|
|
110
30
|
Language:
|
|
111
31
|
Expectations:
|
|
@@ -115,6 +35,3 @@ RSpec:
|
|
|
115
35
|
Style/GlobalVars:
|
|
116
36
|
Exclude:
|
|
117
37
|
- 'spec/dummy/config/environments/development.rb'
|
|
118
|
-
|
|
119
|
-
Style/FrozenStringLiteralComment:
|
|
120
|
-
EnforcedStyle: always
|
data/CHANGELOG.md
CHANGED
|
@@ -17,7 +17,11 @@ You can find the **package** version numbers from this repo's tags and below in
|
|
|
17
17
|
|
|
18
18
|
## [Unreleased]
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
Changes since the last non-beta release.
|
|
21
|
+
|
|
22
|
+
### [v16.2.0.rc.0] - 2025-12-29
|
|
23
|
+
|
|
24
|
+
Changes since the last non-beta release.
|
|
21
25
|
|
|
22
26
|
### Improved
|
|
23
27
|
|
|
@@ -30,7 +34,6 @@ _Add changes in master not yet tagged._
|
|
|
30
34
|
- Added `cached_stream_react_component` helper method, similar to `cached_react_component` but for streamed components.
|
|
31
35
|
- **License Validation System**: Implemented comprehensive JWT-based license validation with offline verification using RSA-256 signatures. License validation occurs at startup in both Ruby and Node.js environments. Supports required fields (`sub`, `iat`, `exp`) and optional fields (`plan`, `organization`, `iss`). FREE evaluation licenses are available for 3 months at [shakacode.com/react-on-rails-pro](https://shakacode.com/react-on-rails-pro). [PR #1857](https://github.com/shakacode/react_on_rails/pull/1857) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
|
|
32
36
|
- **Pro-Specific Configurations Moved from Open-Source**: The following React Server Components (RSC) configurations are now exclusively in the Pro gem and should be configured in `ReactOnRailsPro.configure`:
|
|
33
|
-
|
|
34
37
|
- `rsc_bundle_js_file` - Path to the RSC bundle file
|
|
35
38
|
- `react_server_client_manifest_file` - Path to the React server client manifest
|
|
36
39
|
- `react_client_manifest_file` - Path to the React client manifest
|
|
@@ -38,7 +41,6 @@ _Add changes in master not yet tagged._
|
|
|
38
41
|
These configurations were previously available in the open-source `ReactOnRails.configure` block but have been moved to Pro where they belong since RSC is a Pro-only feature.
|
|
39
42
|
|
|
40
43
|
- **Streaming View Helpers Now Pro-Exclusive**: The following view helpers are now defined exclusively in the Pro gem:
|
|
41
|
-
|
|
42
44
|
- `stream_react_component` - Progressive SSR using React 18+ streaming
|
|
43
45
|
- `rsc_payload_react_component` - RSC payload rendering
|
|
44
46
|
|
|
@@ -48,8 +50,16 @@ _Add changes in master not yet tagged._
|
|
|
48
50
|
|
|
49
51
|
### Fixed
|
|
50
52
|
|
|
53
|
+
- **Thread-Safe Connection Management**: Fixed race conditions in `ReactOnRailsPro::Request` connection management. The lazy initialization (`@connection ||= create_connection`) was not atomic, allowing multiple threads to create duplicate connections at startup. Now uses a mutex with double-checked locking pattern for thread-safe initialization while maintaining lock-free reads for optimal performance. [PR 2259](https://github.com/shakacode/react_on_rails/pull/2259) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
|
|
54
|
+
|
|
55
|
+
- **Legacy Module Resolver Compatibility**: Added `main` field to `react-on-rails-pro` and `react-on-rails-pro-node-renderer` package.json files for compatibility with legacy module resolvers like `eslint-import-resolver-node` that don't support Node.js conditional exports. [PR 2256](https://github.com/shakacode/react_on_rails/pull/2256) by [ihabadham](https://github.com/ihabadham).
|
|
56
|
+
|
|
57
|
+
- **SECURITY: CVE-2025-55182 - React Server Components RCE Vulnerability**: by updating `react-on-rails-rsc` peer dependency to `v19.0.3` which mitigates that vulnerability. Also, users should update `react` and `react-dom` package versions to `v19.0.1` to ensure complete mitigation. [PR 2175](https://github.com/shakacode/react_on_rails/pull/2175) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
|
|
58
|
+
|
|
51
59
|
- Fixed compatibility issue with httpx 1.6.x by explicitly requiring http-2 >= 1.1.1. [PR 2141](https://github.com/shakacode/react_on_rails/pull/2141) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
|
|
52
60
|
|
|
61
|
+
- **Client Disconnect Handling for Streaming**: Added error handling for client disconnects during streaming. When a client disconnects mid-stream (browser closed, network drop), the system now catches `IOError`/`Errno::EPIPE`, sets a `client_disconnected` flag, stops the barrier to cancel producer tasks, and logs the disconnect for debugging. Prevents wasted CPU from producers continuing after the writer fails. [PR 2137](https://github.com/shakacode/react_on_rails/pull/2137) by [justin808](https://github.com/justin808).
|
|
62
|
+
|
|
53
63
|
- **Node Renderer Worker Restart**: Fixed "descriptor closed" error that occurred when the node renderer restarts while handling an in-progress request (especially streaming requests). Workers now perform graceful shutdowns: they disconnect from the cluster to stop receiving new requests, wait for active requests to complete, then shut down cleanly. A configurable `gracefulWorkerRestartTimeout` ensures workers are forcibly killed if they don't shut down in time. [PR 1970](https://github.com/shakacode/react_on_rails/pull/1970) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
|
|
54
64
|
|
|
55
65
|
- **Body Duplication Bug On Streaming**: Fixed a bug that happens while streaming if the node renderer connection closed after streaming some chunks to the client. [PR 1995](https://github.com/shakacode/react_on_rails/pull/1995) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
|
|
@@ -96,7 +106,7 @@ _Add changes in master not yet tagged._
|
|
|
96
106
|
- Seamlessly use React Server Components in your Rails apps
|
|
97
107
|
- Reduce client bundle sizes
|
|
98
108
|
- Enable powerful new patterns for data fetching
|
|
99
|
-
- [See the full tutorial](https://www.shakacode.com/react-on-rails-pro/docs/react-server-components
|
|
109
|
+
- [See the full tutorial](https://www.shakacode.com/react-on-rails-pro/docs/react-server-components/tutorial)
|
|
100
110
|
|
|
101
111
|
[PR 422](https://github.com/shakacode/react_on_rails_pro/pull/422) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
|
|
102
112
|
|
|
@@ -109,7 +119,6 @@ _Add changes in master not yet tagged._
|
|
|
109
119
|
### Changed
|
|
110
120
|
|
|
111
121
|
- [PR 511](https://github.com/shakacode/react_on_rails_pro/pull/511) by [Romex91](https://github.com/Romex91)
|
|
112
|
-
|
|
113
122
|
- Set `bodyLimit` to 100 MB by default to fix error 413.
|
|
114
123
|
- Add `fastifyServerOptions` to the config
|
|
115
124
|
|
|
@@ -256,7 +265,6 @@ React 18 is now supported! Check the [React on Rails CHANGELOG.md](https://githu
|
|
|
256
265
|
### Added
|
|
257
266
|
|
|
258
267
|
- [PR 220](https://github.com/shakacode/react_on_rails_pro/pull/220) by [justin808](https://github.com/justin808).
|
|
259
|
-
|
|
260
268
|
- **Add `ssr_timeout` configuration** so the Rails server will not wait more than this many seconds for a SSR request to return once issued.
|
|
261
269
|
- Change default for `renderer_use_fallback_exec_js` to `false`.
|
|
262
270
|
- Change default log level to info.
|
|
@@ -536,7 +544,8 @@ Above changes in [PR 52](https://github.com/shakacode/react_on_rails_pro/pull/52
|
|
|
536
544
|
- advanced error handling
|
|
537
545
|
|
|
538
546
|
[HEAD compared to 3.2.1]: https://github.com/shakacode/react_on_rails_pro/compare/3.3.1...HEAD
|
|
539
|
-
[Unreleased]: https://github.com/shakacode/
|
|
547
|
+
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/v16.2.0.rc.0...master
|
|
548
|
+
[v16.2.0.rc.0]: https://github.com/shakacode/react_on_rails/compare/16.1.1...v16.2.0.rc.0
|
|
540
549
|
[4.0.0-rc.15]: https://github.com/shakacode/react_on_rails_pro/compare/4.0.0-rc.14...4.0.0-rc.15
|
|
541
550
|
[4.0.0.rc.11]: https://github.com/shakacode/react_on_rails_pro/compare/4.0.0-rc.9...4.0.0-rc.11
|
|
542
551
|
[4.0.0.rc.9]: https://github.com/shakacode/react_on_rails_pro/compare/4.0.0-rc.6...4.0.0-rc.9
|
data/CONTRIBUTING.md
CHANGED
|
@@ -4,34 +4,36 @@
|
|
|
4
4
|
|
|
5
5
|
Install [yalc](https://github.com/wclr/yalc).
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
```sh
|
|
8
|
+
pnpm install -r
|
|
9
9
|
cd react_on_rails_pro
|
|
10
|
-
bundle &&
|
|
10
|
+
bundle && cd spec/dummy && bundle && pnpm install
|
|
11
11
|
```
|
|
12
|
+
|
|
12
13
|
To use the `React 18 Apollo with GraphQL` example you need to seed the testing database inside `spec/dummy` directory.
|
|
14
|
+
|
|
13
15
|
```sh
|
|
14
16
|
rake db:seed
|
|
15
17
|
```
|
|
16
18
|
|
|
17
|
-
|
|
18
19
|
See the example apps under `/spec`
|
|
19
20
|
|
|
20
21
|
## Summary
|
|
21
22
|
|
|
22
23
|
For non-doc fixes:
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
- Provide changelog entry in the [unreleased section of the CHANGELOG.md](https://github.com/shakacode/react_on_rails_pro/blob/master/CHANGELOG.md#unreleased).
|
|
26
|
+
- Ensure CI passes and that you added a test that passes with the fix and fails without the fix.
|
|
27
|
+
- Squash all commits down to one with a nice commit message _ONLY_ once final review is given. Make sure this single commit is rebased on top of master.
|
|
28
|
+
- Please address all code review comments.
|
|
29
|
+
- Ensure that docs are updated accordingly if a feature is added.
|
|
29
30
|
|
|
30
31
|
## Commit Messages
|
|
31
32
|
|
|
32
33
|
From [How to Write a Git Commit Message](http://chris.beams.io/posts/git-commit/)
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
### The seven rules of a great git commit message
|
|
36
|
+
|
|
35
37
|
> Keep in mind: This has all been said before.
|
|
36
38
|
|
|
37
39
|
1. Separate subject from body with a blank line
|
|
@@ -42,21 +44,21 @@ From [How to Write a Git Commit Message](http://chris.beams.io/posts/git-commit/
|
|
|
42
44
|
1. Wrap the body at 72 characters
|
|
43
45
|
1. Use the body to explain what and why vs. how
|
|
44
46
|
|
|
45
|
-
|
|
46
47
|
## Doc Changes
|
|
47
48
|
|
|
48
|
-
When making doc changes, we want the change to work on both https://www.shakacode.com/react-on-rails-pro/docs/ and when browsing the GitHub repo.
|
|
49
|
+
When making doc changes, we want the change to work on both [the ShakaCode docs site](https://www.shakacode.com/react-on-rails-pro/docs/) and when browsing the GitHub repo.
|
|
49
50
|
The issue is that the Shakacode site is generated only from files in [`docs`](./docs), so any references from them to non-doc files must use the full GitHub URL.
|
|
50
51
|
|
|
51
52
|
### Links to other docs:
|
|
52
|
-
* When making references to doc files, use a relative URL path like:
|
|
53
|
-
`[Installation Overview](docs/basics/installation-overview.md)`
|
|
54
53
|
|
|
55
|
-
|
|
56
|
-
`[
|
|
54
|
+
- When making references to doc files, use a relative URL path like:
|
|
55
|
+
`[Installation Overview](docs/basics/installation-overview.md)`
|
|
57
56
|
|
|
57
|
+
- When making references to source code files, use a full url path like:
|
|
58
|
+
`[spec/dummy/config/initializers/react_on_rails.rb](https://github.com/shakacode/react_on_rails_pro/tree/master/spec/dummy/config/initializers/react_on_rails.rb)`
|
|
58
59
|
|
|
59
60
|
## To run tests:
|
|
61
|
+
|
|
60
62
|
See [Run NPM JS tests](#run-npm-js-tests) for the JS tests and [RSpec Testing](#rspec-testing) for the Ruby tests.
|
|
61
63
|
|
|
62
64
|
See [Dev Initial Setup](#dev-initial-setup) below for, well... initial setup.
|
|
@@ -107,30 +109,33 @@ script/ci-changes-detector origin/master
|
|
|
107
109
|
### CI Best Practices for Pro
|
|
108
110
|
|
|
109
111
|
✅ **DO:**
|
|
112
|
+
|
|
110
113
|
- Run `bin/ci-local` from repository root before pushing
|
|
111
114
|
- Test Pro changes alongside main gem changes if modifying both
|
|
112
115
|
- Use `bin/ci-local --fast` during rapid iteration
|
|
113
116
|
|
|
114
117
|
❌ **DON'T:**
|
|
118
|
+
|
|
115
119
|
- Push Pro changes without testing locally first
|
|
116
120
|
- Modify both Pro and main gem without running full tests
|
|
117
121
|
|
|
118
122
|
For comprehensive CI documentation, see [`../docs/CI_OPTIMIZATION.md`](../docs/CI_OPTIMIZATION.md) in the repository root.
|
|
119
123
|
|
|
120
124
|
# IDE/Editor Setup
|
|
121
|
-
It's critical to configure your IDE/editor to ignore certain directories. Otherwise your IDE might slow to a crawl!
|
|
122
125
|
|
|
123
|
-
|
|
124
|
-
* /tmp
|
|
125
|
-
* /node_modules
|
|
126
|
-
* /spec/dummy/app/assets/webpack
|
|
127
|
-
* /spec/dummy/log
|
|
128
|
-
* /spec/dummy/node_modules
|
|
129
|
-
* /spec/dummy/client/node_modules
|
|
130
|
-
* /spec/dummy/tmp
|
|
126
|
+
It's critical to configure your IDE/editor to ignore certain directories. Otherwise your IDE might slow to a crawl!
|
|
131
127
|
|
|
128
|
+
- /coverage
|
|
129
|
+
- /tmp
|
|
130
|
+
- /node_modules
|
|
131
|
+
- /spec/dummy/app/assets/webpack
|
|
132
|
+
- /spec/dummy/log
|
|
133
|
+
- /spec/dummy/node_modules
|
|
134
|
+
- /spec/dummy/client/node_modules
|
|
135
|
+
- /spec/dummy/tmp
|
|
132
136
|
|
|
133
137
|
# Configuring your test app to use your local fork
|
|
138
|
+
|
|
134
139
|
You can test the `react_on_rails_pro` gem using your own external test_app or the gem's internal `spec/dummy` app. The `spec/dummy` app is an example of the various setup techniques you can use with the gem.
|
|
135
140
|
As of 2018-04-28, this directory mirrors the test app spec/dummy on https://github.com/shakacode/react_on_rails plus a few additional tests.
|
|
136
141
|
|
|
@@ -143,15 +148,17 @@ As of 2018-04-28, this directory mirrors the test app spec/dummy on https://gith
|
|
|
143
148
|
```
|
|
144
149
|
|
|
145
150
|
## Testing the Ruby Gem
|
|
151
|
+
|
|
146
152
|
If you want to test the ruby parts of the gem with an application before you release a new version of the gem, you can specify the path to your local version via your test app's Gemfile:
|
|
147
153
|
|
|
148
154
|
```ruby
|
|
149
155
|
gem "react_on_rails_pro", path: "../path-to-react_on_rails_pro"
|
|
150
156
|
gem "react_on_rails"
|
|
151
157
|
```
|
|
158
|
+
|
|
152
159
|
================================================================================
|
|
153
160
|
|
|
154
|
-
Set `config.server_renderer = "NodeRenderer"` in your
|
|
161
|
+
Set `config.server_renderer = "NodeRenderer"` in your `ReactOnRailsPro.configure` block in the initializer.
|
|
155
162
|
|
|
156
163
|
After making this change, run `bundle install`.
|
|
157
164
|
|
|
@@ -159,6 +166,7 @@ After making this change, run `bundle install`.
|
|
|
159
166
|
> You will need to restart your Rails application if you make any changes to the gem.
|
|
160
167
|
|
|
161
168
|
## Testing the Node package for react_on_rails_pro
|
|
169
|
+
|
|
162
170
|
In addition to testing the Ruby parts out, you can also test the node package parts of the gem with an external application.
|
|
163
171
|
|
|
164
172
|
To do this, follow the instructions in the
|
|
@@ -166,19 +174,21 @@ To do this, follow the instructions in the
|
|
|
166
174
|
|
|
167
175
|
### Example: Testing NPM changes with the dummy app
|
|
168
176
|
|
|
169
|
-
1. Add `console.log('Hello!')` [here](https://github.com/shakacode/react_on_rails_pro/blob/
|
|
170
|
-
2. The `preinstall` script of `spec/dummy` builds the NPM package and sets up `yalc` to use it for the renderer.
|
|
171
|
-
It's run automatically when you run `
|
|
177
|
+
1. Add `console.log('Hello!')` [here](https://github.com/shakacode/react_on_rails_pro/blob/master/packages/node-renderer/src/ReactOnRailsProNodeRenderer.ts#L6) in `packages/node-renderer/src/ReactOnRailsProNodeRenderer.ts` to confirm we're getting an update to the node package.
|
|
178
|
+
2. The `preinstall` script of `spec/dummy` builds the NPM package and sets up `yalc` to use it for the renderer.
|
|
179
|
+
It's run automatically when you run `pnpm install`.
|
|
172
180
|
3. Refresh the browser if the server is already running or start the server using `foreman start -f Procfile.dev` from `spec/dummy` and navigate to `http://localhost:3000/`. You will now see the `Hello!` message printed in the browser's console.
|
|
173
181
|
|
|
182
|
+
<!-- prettier-ignore -->
|
|
174
183
|
> [!NOTE]
|
|
175
184
|
> `yalc` makes the NPM package available globally on the machine.
|
|
176
185
|
> So, if you have the repo checked out more than once to compare behavior between branches,
|
|
177
|
-
> make sure to run `
|
|
186
|
+
> make sure to run `pnpm install` every time you switch to a new copy.
|
|
178
187
|
|
|
179
188
|
# Development Setup for Gem and Node Package Contributors
|
|
180
189
|
|
|
181
190
|
## Checklist before Committing
|
|
191
|
+
|
|
182
192
|
1. Run all JS tests, dummy app tests and linters.
|
|
183
193
|
2. Did you need any more tests for your change?
|
|
184
194
|
3. Did you document your change? Update the README.md?
|
|
@@ -186,12 +196,13 @@ To do this, follow the instructions in the
|
|
|
186
196
|
## Dev Initial Setup
|
|
187
197
|
|
|
188
198
|
### Prereqs
|
|
189
|
-
After checking out the repo, making sure you have rvm and nvm setup (setup ruby and node), cd to `spec/dummy` and run `bin/setup` to install ruby dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
190
199
|
|
|
200
|
+
After checking out the repo, making sure you have rvm and nvm setup (setup ruby and node), cd to `spec/dummy` and run `bin/setup` to install ruby dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
191
201
|
|
|
192
202
|
### Building the Node Package for Development
|
|
193
203
|
|
|
194
204
|
At the root:
|
|
205
|
+
|
|
195
206
|
```
|
|
196
207
|
nps build
|
|
197
208
|
```
|
|
@@ -207,6 +218,7 @@ This is a possible update to package.json to debug the lockfile. Notice the `NOD
|
|
|
207
218
|
See https://nodejs.org/api/util.html#util_util_debuglog_section for details on `debuglog`.
|
|
208
219
|
|
|
209
220
|
### Local Node Package
|
|
221
|
+
|
|
210
222
|
Because the example and dummy apps rely on the `react_on_rails_pro` node package, they should link directly to your local version to pick up any changes you may have made to that package.
|
|
211
223
|
To achieve this, you can use `yalc`.
|
|
212
224
|
The easy way to do this is to run the command below in the dummy app root directory.
|
|
@@ -215,11 +227,11 @@ For more information check the script section of the
|
|
|
215
227
|
|
|
216
228
|
```sh
|
|
217
229
|
cd spec/dummy
|
|
218
|
-
|
|
230
|
+
pnpm install -r
|
|
219
231
|
```
|
|
220
232
|
|
|
221
233
|
> [!NOTE]
|
|
222
|
-
> This
|
|
234
|
+
> This uses yalc under the hood as explained in the **Example: Testing NPM changes with the dummy app** section above.
|
|
223
235
|
|
|
224
236
|
From now on, the example and dummy apps will use your local packages/node-renderer folder as the `react_on_rails_pro` node package.
|
|
225
237
|
|
|
@@ -227,51 +239,55 @@ From now on, the example and dummy apps will use your local packages/node-render
|
|
|
227
239
|
|
|
228
240
|
```sh
|
|
229
241
|
cd react_on_rails_pro
|
|
230
|
-
|
|
242
|
+
pnpm install -r
|
|
231
243
|
```
|
|
232
244
|
|
|
233
|
-
Or run this, which builds the
|
|
245
|
+
Or run this, which builds the pnpm package, then the webpack files for spec/dummy, and finally runs tests in
|
|
234
246
|
spec/dummy.
|
|
235
247
|
|
|
236
|
-
|
|
237
248
|
```sh
|
|
238
249
|
# Optionally change default selenium_firefox driver
|
|
239
250
|
# export DRIVER=poltergeist
|
|
240
251
|
cd react_on_rails_pro
|
|
241
|
-
|
|
252
|
+
pnpm run dummy:spec
|
|
242
253
|
```
|
|
243
254
|
|
|
244
255
|
### Run NPM JS tests
|
|
245
256
|
|
|
246
257
|
```sh
|
|
247
258
|
cd react_on_rails_pro
|
|
248
|
-
|
|
259
|
+
pnpm test
|
|
249
260
|
```
|
|
250
261
|
|
|
251
262
|
### Debugging NPM JS tests
|
|
252
263
|
|
|
253
264
|
Example of using ndb to debug a test
|
|
265
|
+
|
|
254
266
|
```bash
|
|
255
|
-
ndb $(
|
|
267
|
+
ndb $(pnpm bin)/jest --runInBand packages/node-renderer/tests/**/*.test.[jt]s -t 'FriendsAndGuests bundle for commit 1a7fe417'
|
|
256
268
|
```
|
|
269
|
+
|
|
257
270
|
Hit F8 and then a debugger statement within the test will get hit.
|
|
258
271
|
|
|
259
272
|
### Creating new VM tests
|
|
273
|
+
|
|
260
274
|
1. copy a server bundle to `packages/node-renderer/tests/fixtures/projects/<project-name>/<commit>`
|
|
261
275
|
2. create a directory with a hash representing the commit of the project
|
|
262
276
|
|
|
263
277
|
### Async issues with Jest
|
|
278
|
+
|
|
264
279
|
Beware that Jest runs multiple test files synchronously, so you can't use the same temporary directory
|
|
265
|
-
between tests. See the file [`packages/node-renderer/tests/helper.ts`](packages/node-renderer/tests/helper.ts) for how we handle this.
|
|
280
|
+
between tests. See the file [`packages/node-renderer/tests/helper.ts`](https://github.com/shakacode/react_on_rails_pro/blob/master/packages/node-renderer/tests/helper.ts) for how we handle this.
|
|
266
281
|
|
|
267
282
|
### Run most tests and linting
|
|
268
283
|
|
|
269
284
|
```sh
|
|
270
285
|
cd react_on_rails_pro
|
|
271
|
-
|
|
286
|
+
pnpm run check
|
|
272
287
|
```
|
|
273
288
|
|
|
274
289
|
### Starting the Dummy App
|
|
290
|
+
|
|
275
291
|
Before running the dummy app,
|
|
276
292
|
you need to generate JavaScript packs in the dummy app project.
|
|
277
293
|
To do this,
|
|
@@ -298,15 +314,17 @@ Before running Ruby tests ensure you have done the following steps in `spec/dumm
|
|
|
298
314
|
|
|
299
315
|
```sh
|
|
300
316
|
# in the root directory
|
|
317
|
+
pnpm install -r
|
|
318
|
+
|
|
319
|
+
cd react_on_rails
|
|
301
320
|
bundle install
|
|
302
|
-
yarn install
|
|
303
321
|
|
|
304
322
|
cd spec/dummy
|
|
305
323
|
|
|
306
324
|
bundle install
|
|
307
325
|
bundle exec rake react_on_rails:generate_packs
|
|
308
326
|
|
|
309
|
-
|
|
327
|
+
pnpm install -r
|
|
310
328
|
|
|
311
329
|
RAILS_ENV=test bin/shakapacker # to generate assets for test environment
|
|
312
330
|
```
|
|
@@ -315,7 +333,7 @@ Then in a separate terminal, run the following to run the Node renderer and the
|
|
|
315
333
|
|
|
316
334
|
```sh
|
|
317
335
|
# in spec/dummy directory
|
|
318
|
-
|
|
336
|
+
pnpm run node-renderer
|
|
319
337
|
RAILS_ENV=test bin/dev&
|
|
320
338
|
```
|
|
321
339
|
|
|
@@ -330,6 +348,7 @@ If you run `rspec` at the top level, you'll see this message: `require': cannot
|
|
|
330
348
|
After running a test, you can view the coverage results in SimpleCov reports by opening `coverage/index.html`.
|
|
331
349
|
|
|
332
350
|
### Debugging
|
|
351
|
+
|
|
333
352
|
Start the sample app like this for some debug printing:
|
|
334
353
|
|
|
335
354
|
```sh
|
|
@@ -350,6 +369,7 @@ Contact Justin Gordon, [justin@shakacode.com](mailto:justin@shakacode.com) for r
|
|
|
350
369
|
You need authentication for public package registries:
|
|
351
370
|
|
|
352
371
|
**Public packages (npmjs.org + rubygems.org):**
|
|
372
|
+
|
|
353
373
|
- NPM: Run `npm login`
|
|
354
374
|
- RubyGems: Standard credentials via `gem push`
|
|
355
375
|
|
|
@@ -372,5 +392,6 @@ rake release[17.0.0,false,verdaccio]
|
|
|
372
392
|
```
|
|
373
393
|
|
|
374
394
|
For complete documentation, see:
|
|
395
|
+
|
|
375
396
|
- [Root Release Documentation](../docs/contributor-info/releasing.md)
|
|
376
397
|
- Run `rake -D release` for inline help
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
# Keep in sync with https://github.com/shakacode/react_on_rails/blob/master/Gemfile.development_dependencies
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
+
# Shared dev dependencies (rubocop, etc.)
|
|
5
|
+
eval_gemfile File.expand_path("../Gemfile.shared_dev_dependencies", __dir__)
|
|
6
|
+
|
|
4
7
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
5
8
|
|
|
6
9
|
ruby '3.3.7'
|
|
7
10
|
|
|
8
11
|
gem "react_on_rails", path: "../"
|
|
9
12
|
|
|
10
|
-
gem "shakapacker", "9.
|
|
13
|
+
gem "shakapacker", "9.4.0"
|
|
11
14
|
gem "bootsnap", require: false
|
|
12
15
|
gem "rails", "~> 7.1"
|
|
13
16
|
gem "puma", "~> 6"
|
|
@@ -51,9 +54,6 @@ group :development, :test do
|
|
|
51
54
|
gem 'pry-theme' # An easy way to customize Pry colors via theme files
|
|
52
55
|
|
|
53
56
|
gem "rbs", require: false
|
|
54
|
-
gem "rubocop", "1.36.0", require: false
|
|
55
|
-
gem 'rubocop-performance', "1.15.0", require: false
|
|
56
|
-
gem 'rubocop-rspec', "2.13.2", require: false
|
|
57
57
|
gem "scss_lint", require: false
|
|
58
58
|
gem 'fakefs', require: 'fakefs/safe'
|
|
59
59
|
end
|
data/Gemfile.loader
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Load base dependencies
|
|
4
|
-
|
|
4
|
+
base_deps_path = File.expand_path("./Gemfile.development_dependencies", __dir__)
|
|
5
|
+
base_deps = File.read(base_deps_path)
|
|
5
6
|
|
|
6
7
|
# Determine which override file to use
|
|
7
|
-
|
|
8
|
+
override_deps_path = if ENV["CI"] == "true" && File.exist?(File.expand_path("./Gemfile.ci", __dir__))
|
|
8
9
|
# In CI environment, use CI dependencies
|
|
9
|
-
File.
|
|
10
|
+
File.expand_path("./Gemfile.ci", __dir__)
|
|
10
11
|
elsif File.exist?(File.expand_path("./Gemfile.local", __dir__))
|
|
11
12
|
# In non-CI environment, use local dependencies if they exist
|
|
12
|
-
File.
|
|
13
|
-
else
|
|
14
|
-
""
|
|
13
|
+
File.expand_path("./Gemfile.local", __dir__)
|
|
15
14
|
end
|
|
16
15
|
|
|
16
|
+
override_deps = override_deps_path ? File.read(override_deps_path) : ""
|
|
17
|
+
|
|
17
18
|
# Parse override gems
|
|
18
19
|
override_gem_names = override_deps.scan(/^\s*gem\s+["']([^"']+)["']/).flatten
|
|
19
20
|
|
|
@@ -26,7 +27,9 @@ end
|
|
|
26
27
|
base_deps.gsub!(/^\s*$\n/, '')
|
|
27
28
|
|
|
28
29
|
# Evaluate the modified base dependencies
|
|
29
|
-
|
|
30
|
+
# Using instance_eval with filepath preserves __dir__ in evaluated content,
|
|
31
|
+
# allowing eval_gemfile calls to work correctly inside loaded files.
|
|
32
|
+
instance_eval(base_deps, base_deps_path)
|
|
30
33
|
|
|
31
34
|
# Evaluate override dependencies if they exist
|
|
32
|
-
|
|
35
|
+
instance_eval(override_deps, override_deps_path) unless override_deps.empty?
|