react_on_rails 16.2.0.beta.4 → 16.2.0.beta.8
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/CHANGELOG.md +27 -8
- data/CONTRIBUTING.md +1 -1
- data/Gemfile.development_dependencies +0 -1
- data/Gemfile.lock +1 -9
- data/bin/ci-rerun-failures +39 -16
- data/bin/ci-run-failed-specs +1 -1
- data/bin/ci-switch-config +8 -2
- data/bin/lefthook/ruby-autofix +2 -1
- data/knip.ts +35 -9
- data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt +32 -52
- data/lib/generators/react_on_rails/templates/base/base/config/shakapacker.yml +5 -1
- data/lib/react_on_rails/dev/server_manager.rb +11 -4
- data/lib/react_on_rails/doctor.rb +245 -0
- data/lib/react_on_rails/helper.rb +9 -0
- data/lib/react_on_rails/version.rb +1 -1
- data/react_on_rails_pro/CHANGELOG.md +7 -0
- data/react_on_rails_pro/CONTRIBUTING.md +2 -13
- data/react_on_rails_pro/Gemfile.lock +21 -3
- data/react_on_rails_pro/docs/code-splitting-loadable-components.md +1 -1
- data/react_on_rails_pro/docs/contributors-info/releasing.md +2 -2
- data/react_on_rails_pro/docs/installation.md +106 -104
- data/react_on_rails_pro/docs/node-renderer/basics.md +3 -3
- data/react_on_rails_pro/docs/node-renderer/error-reporting-and-tracing.md +8 -8
- data/react_on_rails_pro/docs/node-renderer/js-configuration.md +1 -1
- data/react_on_rails_pro/docs/updating.md +209 -15
- data/react_on_rails_pro/lib/react_on_rails_pro/concerns/stream.rb +58 -4
- data/react_on_rails_pro/lib/react_on_rails_pro/configuration.rb +17 -3
- data/react_on_rails_pro/lib/react_on_rails_pro/license_public_key.rb +9 -9
- data/react_on_rails_pro/lib/react_on_rails_pro/request.rb +41 -25
- data/react_on_rails_pro/lib/react_on_rails_pro/stream_request.rb +27 -7
- data/react_on_rails_pro/lib/react_on_rails_pro/utils.rb +3 -3
- data/react_on_rails_pro/lib/react_on_rails_pro/version.rb +1 -1
- data/react_on_rails_pro/package-scripts.yml +1 -1
- data/react_on_rails_pro/package.json +5 -8
- data/react_on_rails_pro/packages/node-renderer/src/integrations/api.ts +1 -1
- data/react_on_rails_pro/rakelib/public_key_management.rake +6 -5
- data/react_on_rails_pro/react_on_rails_pro.gemspec +1 -0
- data/react_on_rails_pro/spec/dummy/Gemfile.lock +20 -3
- data/react_on_rails_pro/spec/dummy/app/controllers/pages_controller.rb +3 -3
- data/react_on_rails_pro/spec/dummy/bin/dev +4 -8
- data/react_on_rails_pro/spec/dummy/client/node-renderer.js +3 -3
- data/react_on_rails_pro/spec/dummy/config/environments/production.rb +1 -1
- data/react_on_rails_pro/spec/dummy/config/initializers/react_on_rails.rb +28 -12
- data/react_on_rails_pro/spec/dummy/config.ru +1 -1
- data/react_on_rails_pro/spec/dummy/package.json +2 -2
- data/react_on_rails_pro/spec/dummy/spec/helpers/react_on_rails_pro_helper_spec.rb +40 -11
- data/react_on_rails_pro/spec/dummy/spec/rails_helper.rb +1 -1
- data/react_on_rails_pro/spec/dummy/spec/requests/renderer_console_logging_spec.rb +5 -5
- data/react_on_rails_pro/spec/dummy/spec/system/integration_spec.rb +20 -14
- data/react_on_rails_pro/spec/dummy/spec/system/renderer_integration_spec.rb +3 -3
- data/react_on_rails_pro/spec/dummy/yarn.lock +4 -4
- data/react_on_rails_pro/spec/execjs-compatible-dummy/config/environments/production.rb +1 -1
- data/react_on_rails_pro/spec/execjs-compatible-dummy/config/initializers/react_on_rails.rb +16 -43
- data/react_on_rails_pro/spec/react_on_rails_pro/assets_precompile_spec.rb +15 -18
- data/react_on_rails_pro/spec/react_on_rails_pro/cache_spec.rb +1 -1
- data/react_on_rails_pro/spec/react_on_rails_pro/configuration_spec.rb +5 -3
- data/react_on_rails_pro/spec/react_on_rails_pro/license_validator_spec.rb +27 -12
- data/react_on_rails_pro/spec/react_on_rails_pro/request_spec.rb +0 -27
- data/react_on_rails_pro/spec/react_on_rails_pro/spec_helper.rb +1 -1
- data/react_on_rails_pro/spec/react_on_rails_pro/stream_decorator_spec.rb +89 -0
- data/react_on_rails_pro/spec/react_on_rails_pro/stream_spec.rb +144 -0
- data/react_on_rails_pro/spec/react_on_rails_pro/support/caching.rb +1 -1
- data/react_on_rails_pro/spec/react_on_rails_pro/support/mock_block_helper.rb +4 -2
- metadata +2 -3
- data/react_on_rails_pro/spec/dummy/client/app/ror-auto-load-components/TestingStreamableComponent.jsx +0 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e2d569c0148019a12155710806cbd6f3d94f6641ffd074099dc9b4255b0202d6
|
|
4
|
+
data.tar.gz: 8abd5fedee13d2d2d1bfa6fc6a03e8a6d11710ece7fb84b26fb3afc387156d75
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 22ef214ab6d5c12257a9ebc3fbf01c56c4211405ac4398628b1d69813d236d39dfe02d48168d4fabb0a0eb5d54ce624fb37790776952e4300547e502170432a4
|
|
7
|
+
data.tar.gz: e1fdf86179a42c10af444265839d2e95fe15b3771f0606038ce1c01611efcd96c03d34c1e94682b718b6011c6f0d9c049b59b1713bdb75fa942a23e08e0c60b2
|
data/CHANGELOG.md
CHANGED
|
@@ -23,6 +23,18 @@ After a release, please make sure to run `bundle exec rake update_changelog`. Th
|
|
|
23
23
|
|
|
24
24
|
Changes since the last non-beta release.
|
|
25
25
|
|
|
26
|
+
#### Changed
|
|
27
|
+
|
|
28
|
+
- **Generator Configuration Modernization**: Updated the generator to enable recommended configurations by default for new applications:
|
|
29
|
+
|
|
30
|
+
- `config.build_test_command` is now uncommented and set to `"RAILS_ENV=test bin/shakapacker"` by default, enabling automatic asset building during tests for better integration test reliability
|
|
31
|
+
- `config.auto_load_bundle = true` is now set by default, enabling automatic loading of component bundles
|
|
32
|
+
- `config.components_subdirectory = "ror_components"` is now set by default, organizing React components in a dedicated subdirectory
|
|
33
|
+
|
|
34
|
+
**Note:** These changes only affect newly generated applications. Existing applications are unaffected and do not need to make any changes. If you want to adopt these settings in an existing app, you can manually add them to your `config/initializers/react_on_rails.rb` file. [PR 2039](https://github.com/shakacode/react_on_rails/pull/2039) by [justin808](https://github.com/justin808).
|
|
35
|
+
|
|
36
|
+
### [16.2.0.beta.4] - 2025-11-12
|
|
37
|
+
|
|
26
38
|
#### Added
|
|
27
39
|
|
|
28
40
|
- **Rspack Support**: Added `--rspack` flag to `react_on_rails:install` generator for significantly faster builds (~20x improvement with SWC). Includes unified webpack/rspack configuration templates and `bin/switch-bundler` utility to switch between bundlers post-installation. [PR #1852](https://github.com/shakacode/react_on_rails/pull/1852) by [justin808](https://github.com/justin808).
|
|
@@ -35,6 +47,8 @@ Changes since the last non-beta release.
|
|
|
35
47
|
|
|
36
48
|
- **Improved RSC Payload Error Handling**: Errors that happen during generation of RSC payload are transferred properly to rails side and logs the error message and stack. [PR #1888](https://github.com/shakacode/react_on_rails/pull/1888) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
|
|
37
49
|
|
|
50
|
+
- **Use as Git dependency**: All packages can now be installed as Git dependencies. This is useful for development and testing purposes. See [CONTRIBUTING.md](./CONTRIBUTING.md#git-dependencies) for documentation. [PR #1873](https://github.com/shakacode/react_on_rails/pull/1873) by [alexeyr-ci2](https://github.com/alexeyr-ci2).
|
|
51
|
+
|
|
38
52
|
#### Changed
|
|
39
53
|
|
|
40
54
|
- **Shakapacker 9.0.0 Upgrade**: Upgraded Shakapacker from 8.2.0 to 9.0.0 with Babel transpiler configuration for compatibility. Key changes include:
|
|
@@ -45,19 +59,23 @@ Changes since the last non-beta release.
|
|
|
45
59
|
- Fixed webpack configuration to process SCSS rules and CSS loaders in a single pass for better performance
|
|
46
60
|
[PR 1904](https://github.com/shakacode/react_on_rails/pull/1904) by [justin808](https://github.com/justin808).
|
|
47
61
|
|
|
48
|
-
-
|
|
62
|
+
- **`immediate_hydration` now automatically enabled for Pro users**: The `config.immediate_hydration` configuration option has been removed. Immediate hydration is now automatically enabled for React on Rails Pro users and disabled for non-Pro users, simplifying configuration while providing optimal performance by default. Component-level overrides are still supported via the `immediate_hydration` parameter on `react_component`, `redux_store`, and `stream_react_component` helpers. [PR 1997](https://github.com/shakacode/react_on_rails/pull/1997) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
|
|
63
|
+
|
|
64
|
+
- **`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).
|
|
49
65
|
|
|
50
|
-
|
|
66
|
+
#### Documentation
|
|
51
67
|
|
|
52
|
-
- **
|
|
68
|
+
- **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).
|
|
53
69
|
|
|
54
|
-
|
|
70
|
+
#### Deprecated
|
|
55
71
|
|
|
56
|
-
-
|
|
72
|
+
- **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).
|
|
57
73
|
|
|
58
|
-
####
|
|
74
|
+
#### Fixed
|
|
59
75
|
|
|
60
|
-
- **
|
|
76
|
+
- **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).
|
|
77
|
+
|
|
78
|
+
- **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).
|
|
61
79
|
|
|
62
80
|
#### Breaking Changes
|
|
63
81
|
|
|
@@ -1819,7 +1837,8 @@ such as:
|
|
|
1819
1837
|
|
|
1820
1838
|
- Fix several generator-related issues.
|
|
1821
1839
|
|
|
1822
|
-
[unreleased]: https://github.com/shakacode/react_on_rails/compare/16.
|
|
1840
|
+
[unreleased]: https://github.com/shakacode/react_on_rails/compare/16.2.0.beta.4...master
|
|
1841
|
+
[16.2.0.beta.4]: https://github.com/shakacode/react_on_rails/compare/16.1.1...16.2.0.beta.4
|
|
1823
1842
|
[16.1.1]: https://github.com/shakacode/react_on_rails/compare/16.1.0...16.1.1
|
|
1824
1843
|
[16.1.0]: https://github.com/shakacode/react_on_rails/compare/16.0.0...16.1.0
|
|
1825
1844
|
[16.0.0]: https://github.com/shakacode/react_on_rails/compare/14.2.0...16.0.0
|
data/CONTRIBUTING.md
CHANGED
|
@@ -129,7 +129,7 @@ Package react-on-rails@12.0.0-12070fd1 added ==> /Users/justin/shakacode/react-o
|
|
|
129
129
|
Don't forget you may need to run yarn after adding packages with yalc to install/update dependencies/bin scripts.
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
-
Of course, you can do the same with `react-on-rails-pro` and
|
|
132
|
+
Of course, you can do the same with `react-on-rails-pro` and `react-on-rails-pro-node-renderer` packages.
|
|
133
133
|
|
|
134
134
|
This is the approach `spec/dummy` apps use, so you can also look at their implementation.
|
|
135
135
|
|
|
@@ -38,7 +38,6 @@ group :development, :test do
|
|
|
38
38
|
gem "rubocop", "1.61.0", require: false
|
|
39
39
|
gem "rubocop-performance", "~>1.20.0", require: false
|
|
40
40
|
gem "rubocop-rspec", "~>2.26", require: false
|
|
41
|
-
gem "scss_lint", require: false
|
|
42
41
|
gem "spring", "~> 4.0"
|
|
43
42
|
gem "lefthook", require: false
|
|
44
43
|
# Added for Ruby 3.5+ compatibility to silence warnings
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
react_on_rails (16.2.0.beta.
|
|
4
|
+
react_on_rails (16.2.0.beta.8)
|
|
5
5
|
addressable
|
|
6
6
|
connection_pool
|
|
7
7
|
execjs (~> 2.5)
|
|
@@ -332,11 +332,6 @@ GEM
|
|
|
332
332
|
rubocop (~> 1.40)
|
|
333
333
|
ruby-progressbar (1.13.0)
|
|
334
334
|
rubyzip (2.3.2)
|
|
335
|
-
sass (3.7.4)
|
|
336
|
-
sass-listen (~> 4.0.0)
|
|
337
|
-
sass-listen (4.0.0)
|
|
338
|
-
rb-fsevent (~> 0.9, >= 0.9.4)
|
|
339
|
-
rb-inotify (~> 0.9, >= 0.9.7)
|
|
340
335
|
sass-rails (6.0.0)
|
|
341
336
|
sassc-rails (~> 2.1, >= 2.1.1)
|
|
342
337
|
sassc (2.4.0)
|
|
@@ -347,8 +342,6 @@ GEM
|
|
|
347
342
|
sprockets (> 3.0)
|
|
348
343
|
sprockets-rails
|
|
349
344
|
tilt
|
|
350
|
-
scss_lint (0.60.0)
|
|
351
|
-
sass (~> 3.5, >= 3.5.5)
|
|
352
345
|
sdoc (2.6.1)
|
|
353
346
|
rdoc (>= 5.0)
|
|
354
347
|
securerandom (0.4.1)
|
|
@@ -473,7 +466,6 @@ DEPENDENCIES
|
|
|
473
466
|
rubocop-performance (~> 1.20.0)
|
|
474
467
|
rubocop-rspec (~> 2.26)
|
|
475
468
|
sass-rails (~> 6.0)
|
|
476
|
-
scss_lint
|
|
477
469
|
sdoc
|
|
478
470
|
selenium-webdriver (= 4.9.0)
|
|
479
471
|
shakapacker (= 9.3.0)
|
data/bin/ci-rerun-failures
CHANGED
|
@@ -173,15 +173,41 @@ if [ -z "$FAILED_CHECKS" ]; then
|
|
|
173
173
|
exit 0
|
|
174
174
|
fi
|
|
175
175
|
|
|
176
|
-
# Map CI job names to
|
|
176
|
+
# Map CI job names to identifiers
|
|
177
177
|
# NOTE: Version numbers below must match .github/workflows/main.yml matrix configuration
|
|
178
178
|
declare -A JOB_MAP
|
|
179
|
-
JOB_MAP["lint-js-and-ruby"]="
|
|
180
|
-
JOB_MAP["rspec-package-tests"]="
|
|
181
|
-
JOB_MAP["package-js-tests"]="
|
|
182
|
-
JOB_MAP["dummy-app-integration-tests (3.4, 22, latest)"]="
|
|
183
|
-
JOB_MAP["dummy-app-integration-tests (3.2, 20, minimum)"]="
|
|
184
|
-
JOB_MAP["examples"]="
|
|
179
|
+
JOB_MAP["lint-js-and-ruby"]="lint-js-and-ruby"
|
|
180
|
+
JOB_MAP["rspec-package-tests"]="rspec-package-tests"
|
|
181
|
+
JOB_MAP["package-js-tests"]="package-js-tests"
|
|
182
|
+
JOB_MAP["dummy-app-integration-tests (3.4, 22, latest)"]="dummy-app-integration-tests"
|
|
183
|
+
JOB_MAP["dummy-app-integration-tests (3.2, 20, minimum)"]="dummy-app-integration-tests"
|
|
184
|
+
JOB_MAP["examples"]="examples"
|
|
185
|
+
|
|
186
|
+
# Function to execute commands without eval
|
|
187
|
+
run_command() {
|
|
188
|
+
local cmd_id="$1"
|
|
189
|
+
case "$cmd_id" in
|
|
190
|
+
"lint-js-and-ruby")
|
|
191
|
+
bundle exec rubocop && yarn run eslint --report-unused-disable-directives && yarn start format.listDifferent
|
|
192
|
+
;;
|
|
193
|
+
"rspec-package-tests")
|
|
194
|
+
bundle exec rake run_rspec:gem
|
|
195
|
+
;;
|
|
196
|
+
"package-js-tests")
|
|
197
|
+
yarn test
|
|
198
|
+
;;
|
|
199
|
+
"dummy-app-integration-tests")
|
|
200
|
+
bundle exec rake run_rspec:all_dummy
|
|
201
|
+
;;
|
|
202
|
+
"examples")
|
|
203
|
+
bundle exec rake run_rspec:shakapacker_examples
|
|
204
|
+
;;
|
|
205
|
+
*)
|
|
206
|
+
echo "Unknown command ID: $cmd_id"
|
|
207
|
+
return 1
|
|
208
|
+
;;
|
|
209
|
+
esac
|
|
210
|
+
}
|
|
185
211
|
|
|
186
212
|
# Map CI job names to human-readable versions (matches SWITCHING_CI_CONFIGS.md)
|
|
187
213
|
declare -A JOB_VERSION_MAP
|
|
@@ -236,10 +262,10 @@ if [ "$NUM_COMMANDS" -eq 0 ]; then
|
|
|
236
262
|
fi
|
|
237
263
|
|
|
238
264
|
echo -e "${BLUE}Will run the following commands:${NC}"
|
|
239
|
-
for
|
|
240
|
-
job_name="${COMMANDS_TO_RUN[$
|
|
265
|
+
for cmd_id in "${!COMMANDS_TO_RUN[@]}"; do
|
|
266
|
+
job_name="${COMMANDS_TO_RUN[$cmd_id]}"
|
|
241
267
|
version_info=$(get_version_info "$job_name")
|
|
242
|
-
echo -e "${BLUE} • $job_name${version_info}
|
|
268
|
+
echo -e "${BLUE} • $job_name${version_info}${NC}"
|
|
243
269
|
done
|
|
244
270
|
echo ""
|
|
245
271
|
|
|
@@ -270,17 +296,14 @@ fi
|
|
|
270
296
|
# Run commands
|
|
271
297
|
FAILED_COMMANDS=()
|
|
272
298
|
|
|
273
|
-
for
|
|
274
|
-
job_name="${COMMANDS_TO_RUN[$
|
|
299
|
+
for cmd_id in "${!COMMANDS_TO_RUN[@]}"; do
|
|
300
|
+
job_name="${COMMANDS_TO_RUN[$cmd_id]}"
|
|
275
301
|
version_info=$(get_version_info "$job_name")
|
|
276
302
|
|
|
277
303
|
echo -e "${BLUE}▶ Running: $job_name${version_info}${NC}"
|
|
278
|
-
echo -e "${BLUE}Command: $cmd${NC}"
|
|
279
304
|
echo ""
|
|
280
305
|
|
|
281
|
-
|
|
282
|
-
# not from user input. Commands may contain shell operators like && and ||.
|
|
283
|
-
if eval "$cmd"; then
|
|
306
|
+
if run_command "$cmd_id"; then
|
|
284
307
|
echo -e "${GREEN}✓ $job_name${version_info} passed${NC}"
|
|
285
308
|
echo ""
|
|
286
309
|
else
|
data/bin/ci-run-failed-specs
CHANGED
|
@@ -139,7 +139,7 @@ echo ""
|
|
|
139
139
|
|
|
140
140
|
# Determine the working directory (check if we need to be in spec/dummy)
|
|
141
141
|
WORKING_DIR="."
|
|
142
|
-
if [[ "${UNIQUE_SPECS[0]}" == *"spec/system"* ]] || [[ "${UNIQUE_SPECS[0]}" == *"spec/helpers"* ]]; then
|
|
142
|
+
if [ ${#UNIQUE_SPECS[@]} -gt 0 ] && ([[ "${UNIQUE_SPECS[0]}" == *"spec/system"* ]] || [[ "${UNIQUE_SPECS[0]}" == *"spec/helpers"* ]]); then
|
|
143
143
|
if [ -d "spec/dummy" ]; then
|
|
144
144
|
WORKING_DIR="spec/dummy"
|
|
145
145
|
echo -e "${BLUE}Running from spec/dummy directory${NC}"
|
data/bin/ci-switch-config
CHANGED
|
@@ -255,6 +255,9 @@ EOF
|
|
|
255
255
|
set_node_version "20.18.1" "$VERSION_MANAGER"
|
|
256
256
|
|
|
257
257
|
# Run conversion script
|
|
258
|
+
# NOTE: This uses whatever 'ruby' is in PATH after version manager updates above.
|
|
259
|
+
# The version manager may not have reloaded yet, so ensure your current Ruby is
|
|
260
|
+
# compatible with script/convert (Ruby 2.6+ should work).
|
|
258
261
|
print_header "Running script/convert to downgrade dependencies"
|
|
259
262
|
cd "$PROJECT_ROOT"
|
|
260
263
|
ruby script/convert
|
|
@@ -395,8 +398,11 @@ EOF
|
|
|
395
398
|
# Restore files from git
|
|
396
399
|
print_header "Restoring dependency files from git"
|
|
397
400
|
cd "$PROJECT_ROOT"
|
|
398
|
-
git restore Gemfile.development_dependencies package.json spec/dummy/package.json packages/react-on-rails-pro/package.json 2>/dev/null
|
|
399
|
-
|
|
401
|
+
if ! git restore Gemfile.development_dependencies package.json spec/dummy/package.json packages/react-on-rails-pro/package.json 2>/dev/null; then
|
|
402
|
+
print_warning "Some files could not be restored (may not exist in git)"
|
|
403
|
+
else
|
|
404
|
+
print_success "Files restored from git"
|
|
405
|
+
fi
|
|
400
406
|
|
|
401
407
|
# Clean and reinstall
|
|
402
408
|
print_header "Cleaning node_modules and reinstalling"
|
data/bin/lefthook/ruby-autofix
CHANGED
data/knip.ts
CHANGED
|
@@ -5,13 +5,11 @@ const config: KnipConfig = {
|
|
|
5
5
|
workspaces: {
|
|
6
6
|
// Root workspace - manages the monorepo and global tooling
|
|
7
7
|
'.': {
|
|
8
|
-
entry: ['eslint.config.ts'],
|
|
8
|
+
entry: ['eslint.config.ts', 'jest.config.base.js'],
|
|
9
9
|
project: ['*.{js,mjs,ts}'],
|
|
10
10
|
ignoreBinaries: [
|
|
11
11
|
// Has to be installed globally
|
|
12
12
|
'yalc',
|
|
13
|
-
// Used in package.json scripts (devDependency, so unlisted in production mode)
|
|
14
|
-
'nps',
|
|
15
13
|
// Pro package binaries used in Pro workflows
|
|
16
14
|
'playwright',
|
|
17
15
|
'e2e-test',
|
|
@@ -41,6 +39,17 @@ const config: KnipConfig = {
|
|
|
41
39
|
// SWC transpiler dependencies used in dummy apps
|
|
42
40
|
'@swc/core',
|
|
43
41
|
'swc-loader',
|
|
42
|
+
// Test dependencies used by child workspaces (packages/react-on-rails, packages/react-on-rails-pro)
|
|
43
|
+
'@testing-library/dom',
|
|
44
|
+
'@testing-library/jest-dom',
|
|
45
|
+
'@testing-library/react',
|
|
46
|
+
'@types/react-dom',
|
|
47
|
+
'create-react-class',
|
|
48
|
+
'jest-fetch-mock',
|
|
49
|
+
'prop-types',
|
|
50
|
+
'react',
|
|
51
|
+
'react-dom',
|
|
52
|
+
'redux',
|
|
44
53
|
],
|
|
45
54
|
},
|
|
46
55
|
|
|
@@ -89,6 +98,11 @@ const config: KnipConfig = {
|
|
|
89
98
|
'src/RSCRoute.tsx:RSCRouteProps',
|
|
90
99
|
'src/streamServerRenderedReactComponent.ts:StreamingTrackers',
|
|
91
100
|
],
|
|
101
|
+
ignoreDependencies: [
|
|
102
|
+
// Test dependencies used only in tests
|
|
103
|
+
'@types/mock-fs',
|
|
104
|
+
'mock-fs',
|
|
105
|
+
],
|
|
92
106
|
},
|
|
93
107
|
'spec/dummy': {
|
|
94
108
|
entry: [
|
|
@@ -112,6 +126,12 @@ const config: KnipConfig = {
|
|
|
112
126
|
'**/app-react16/**/*',
|
|
113
127
|
// Playwright support files and helpers - generated by cypress-on-rails gem
|
|
114
128
|
'e2e/playwright/support/**',
|
|
129
|
+
// Components and files used dynamically by React on Rails (registered at runtime)
|
|
130
|
+
'client/app/actions/**',
|
|
131
|
+
'client/app/components/**',
|
|
132
|
+
'client/app/routes/**',
|
|
133
|
+
'client/app/startup/**',
|
|
134
|
+
'client/app/store/**',
|
|
115
135
|
],
|
|
116
136
|
project: ['**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}!', 'config/webpack/*.js'],
|
|
117
137
|
paths: {
|
|
@@ -124,9 +144,6 @@ const config: KnipConfig = {
|
|
|
124
144
|
'bin/.*',
|
|
125
145
|
],
|
|
126
146
|
ignoreDependencies: [
|
|
127
|
-
// Build-time dependencies not detected by Knip in any mode
|
|
128
|
-
'@babel/runtime',
|
|
129
|
-
'mini-css-extract-plugin',
|
|
130
147
|
// There's no ReScript plugin for Knip
|
|
131
148
|
'@rescript/react',
|
|
132
149
|
// The Babel plugin fails to detect it
|
|
@@ -136,18 +153,27 @@ const config: KnipConfig = {
|
|
|
136
153
|
'node-libs-browser',
|
|
137
154
|
// The below dependencies are not detected by the Webpack plugin
|
|
138
155
|
// due to the config issue.
|
|
139
|
-
'css-loader',
|
|
140
156
|
'expose-loader',
|
|
141
157
|
'file-loader',
|
|
142
158
|
'imports-loader',
|
|
143
159
|
'null-loader',
|
|
144
|
-
'sass',
|
|
145
|
-
'sass-loader',
|
|
146
160
|
'sass-resources-loader',
|
|
147
161
|
'style-loader',
|
|
148
162
|
'url-loader',
|
|
149
163
|
// Transitive dependency of shakapacker but listed as direct dependency
|
|
150
164
|
'webpack-merge',
|
|
165
|
+
// Dependencies not detected in production mode
|
|
166
|
+
'@babel/runtime',
|
|
167
|
+
'mini-css-extract-plugin',
|
|
168
|
+
'css-loader',
|
|
169
|
+
'sass',
|
|
170
|
+
'sass-loader',
|
|
171
|
+
// Dependencies used dynamically by React on Rails
|
|
172
|
+
'create-react-class',
|
|
173
|
+
'react-helmet',
|
|
174
|
+
'@types/react-helmet',
|
|
175
|
+
'react-redux',
|
|
176
|
+
'react-router-dom',
|
|
151
177
|
],
|
|
152
178
|
},
|
|
153
179
|
},
|
data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt
CHANGED
|
@@ -1,67 +1,47 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
#
|
|
4
|
-
#
|
|
3
|
+
# React on Rails configuration
|
|
4
|
+
# See https://github.com/shakacode/react_on_rails/blob/master/docs/api-reference/configuration.md
|
|
5
|
+
# for complete documentation of all configuration options.
|
|
5
6
|
|
|
6
7
|
ReactOnRails.configure do |config|
|
|
7
|
-
# This configures the script to run to build the production assets by webpack. Set this to nil
|
|
8
|
-
# if you don't want react_on_rails building this file for you.
|
|
9
|
-
# If nil, then the standard shakacode/shakapacker assets:precompile will run
|
|
10
|
-
# config.build_production_command = nil
|
|
11
|
-
|
|
12
|
-
################################################################################
|
|
13
8
|
################################################################################
|
|
14
|
-
#
|
|
15
|
-
# Below options are used with the use of this test helper:
|
|
16
|
-
# ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
|
|
9
|
+
# Server Rendering (Recommended)
|
|
17
10
|
################################################################################
|
|
18
|
-
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
# ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
|
|
22
|
-
#
|
|
23
|
-
# with rspec then this controls what npm command is run
|
|
24
|
-
# to automatically refresh your webpack assets on every test run.
|
|
25
|
-
#
|
|
26
|
-
# Alternately, you can remove the `ReactOnRails::TestHelper.configure_rspec_to_compile_assets`
|
|
27
|
-
# and set the config/shakapacker.yml option for test to true.
|
|
28
|
-
config.build_test_command = "RAILS_ENV=test bin/shakapacker"
|
|
11
|
+
# Configure server bundle for server-side rendering with `prerender: true`
|
|
12
|
+
# Set to "" if you're not using server rendering
|
|
13
|
+
config.server_bundle_js_file = "server-bundle.js"
|
|
29
14
|
|
|
30
15
|
################################################################################
|
|
16
|
+
# Test Configuration (Optional)
|
|
31
17
|
################################################################################
|
|
32
|
-
#
|
|
33
|
-
################################################################################
|
|
34
|
-
# This is the file used for server rendering of React when using `(prerender: true)`
|
|
35
|
-
# If you are never using server rendering, you should set this to "".
|
|
36
|
-
# Note, there is only one server bundle, unlike JavaScript where you want to minimize the size
|
|
37
|
-
# of the JS sent to the client. For the server rendering, React on Rails creates a pool of
|
|
38
|
-
# JavaScript execution instances which should handle any component requested.
|
|
18
|
+
# ⚠️ IMPORTANT: Two mutually exclusive approaches - use ONLY ONE:
|
|
39
19
|
#
|
|
40
|
-
#
|
|
41
|
-
#
|
|
42
|
-
#
|
|
20
|
+
# RECOMMENDED APPROACH: Set `compile: true` in config/shakapacker.yml test section
|
|
21
|
+
# - Simpler configuration (no additional setup needed)
|
|
22
|
+
# - Handled automatically by Shakapacker
|
|
43
23
|
#
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
#
|
|
47
|
-
#
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
# Enforce that server bundles are only loaded from private (non-public) directories.
|
|
51
|
-
# When true, server bundles will only be loaded from the configured server_bundle_output_path.
|
|
52
|
-
# This is recommended for production to prevent server-side code from being exposed.
|
|
53
|
-
config.enforce_private_server_bundles = true
|
|
24
|
+
# ALTERNATIVE APPROACH: Uncomment below AND configure ReactOnRails::TestHelper
|
|
25
|
+
# - Provides explicit control over test asset compilation timing
|
|
26
|
+
# - Requires adding ReactOnRails::TestHelper to spec/rails_helper.rb
|
|
27
|
+
# - See: https://github.com/shakacode/react_on_rails/blob/master/docs/guides/testing-configuration.md
|
|
28
|
+
#
|
|
29
|
+
config.build_test_command = "RAILS_ENV=test bin/shakapacker"
|
|
54
30
|
|
|
55
|
-
|
|
56
|
-
################################################################################
|
|
57
|
-
# FILE SYSTEM BASED COMPONENT REGISTRY
|
|
58
|
-
################################################################################
|
|
59
|
-
# `components_subdirectory` is the name of the matching directories that contain automatically registered components
|
|
60
|
-
# for use in the Rails views. The default is nil, you can enable the feature by updating it in the next line.
|
|
31
|
+
config.auto_load_bundle = true
|
|
61
32
|
config.components_subdirectory = "ror_components"
|
|
33
|
+
################################################################################
|
|
34
|
+
# Advanced Configuration
|
|
35
|
+
################################################################################
|
|
36
|
+
# Most configuration options have sensible defaults and don't need to be set.
|
|
37
|
+
# For advanced options including:
|
|
38
|
+
# - File-based component registry (components_subdirectory, auto_load_bundle)
|
|
39
|
+
# - Component loading strategies (async/defer/sync)
|
|
40
|
+
# - Server bundle security and organization
|
|
41
|
+
# - I18n configuration
|
|
42
|
+
# - Server rendering pool configuration
|
|
43
|
+
# - Custom rendering extensions
|
|
44
|
+
# - And more...
|
|
62
45
|
#
|
|
63
|
-
#
|
|
64
|
-
# generated directory. default is false, you can pass option at the time of individual usage or update the default
|
|
65
|
-
# in the following line
|
|
66
|
-
config.auto_load_bundle = true
|
|
46
|
+
# See: https://github.com/shakacode/react_on_rails/blob/master/docs/api-reference/configuration.md
|
|
67
47
|
end
|
|
@@ -55,6 +55,11 @@ default: &default
|
|
|
55
55
|
# https://webpack.js.org/guides/build-performance/#avoid-production-specific-tooling
|
|
56
56
|
useContentHash: false
|
|
57
57
|
|
|
58
|
+
# On-demand compilation of packs when modified. Defaults to false.
|
|
59
|
+
# Set to false if using bin/shakapacker-dev-server or bin/shakapacker --watch via Procfiles.
|
|
60
|
+
# Set to true only in test environment for on-demand compilation.
|
|
61
|
+
compile: false
|
|
62
|
+
|
|
58
63
|
# Setting the asset host here will override Rails.application.config.asset_host.
|
|
59
64
|
# Here, you can set different asset_host per environment. Note that
|
|
60
65
|
# SHAKAPACKER_ASSET_HOST will override both configurations.
|
|
@@ -72,7 +77,6 @@ default: &default
|
|
|
72
77
|
|
|
73
78
|
development:
|
|
74
79
|
<<: *default
|
|
75
|
-
compile: true
|
|
76
80
|
compiler_strategy: mtime
|
|
77
81
|
|
|
78
82
|
# Reference: https://webpack.js.org/configuration/dev-server/
|
|
@@ -144,10 +144,11 @@ module ReactOnRails
|
|
|
144
144
|
puts help_troubleshooting
|
|
145
145
|
end
|
|
146
146
|
|
|
147
|
+
# rubocop:disable Metrics/AbcSize
|
|
147
148
|
def run_from_command_line(args = ARGV)
|
|
148
149
|
require "optparse"
|
|
149
150
|
|
|
150
|
-
options = { route: nil, rails_env: nil }
|
|
151
|
+
options = { route: nil, rails_env: nil, verbose: false }
|
|
151
152
|
|
|
152
153
|
OptionParser.new do |opts|
|
|
153
154
|
opts.banner = "Usage: dev [command] [options]"
|
|
@@ -160,6 +161,10 @@ module ReactOnRails
|
|
|
160
161
|
options[:rails_env] = env
|
|
161
162
|
end
|
|
162
163
|
|
|
164
|
+
opts.on("-v", "--verbose", "Enable verbose output for pack generation") do
|
|
165
|
+
options[:verbose] = true
|
|
166
|
+
end
|
|
167
|
+
|
|
163
168
|
opts.on("-h", "--help", "Prints this help") do
|
|
164
169
|
show_help
|
|
165
170
|
exit
|
|
@@ -172,21 +177,23 @@ module ReactOnRails
|
|
|
172
177
|
# Main execution
|
|
173
178
|
case command
|
|
174
179
|
when "production-assets", "prod"
|
|
175
|
-
start(:production_like, nil, verbose:
|
|
180
|
+
start(:production_like, nil, verbose: options[:verbose], route: options[:route],
|
|
181
|
+
rails_env: options[:rails_env])
|
|
176
182
|
when "static"
|
|
177
|
-
start(:static, "Procfile.dev-static-assets", verbose:
|
|
183
|
+
start(:static, "Procfile.dev-static-assets", verbose: options[:verbose], route: options[:route])
|
|
178
184
|
when "kill"
|
|
179
185
|
kill_processes
|
|
180
186
|
when "help", "--help", "-h"
|
|
181
187
|
show_help
|
|
182
188
|
when "hmr", nil
|
|
183
|
-
start(:development, "Procfile.dev", verbose:
|
|
189
|
+
start(:development, "Procfile.dev", verbose: options[:verbose], route: options[:route])
|
|
184
190
|
else
|
|
185
191
|
puts "Unknown argument: #{command}"
|
|
186
192
|
puts "Run 'dev help' for usage information"
|
|
187
193
|
exit 1
|
|
188
194
|
end
|
|
189
195
|
end
|
|
196
|
+
# rubocop:enable Metrics/AbcSize
|
|
190
197
|
|
|
191
198
|
private
|
|
192
199
|
|