Commit 26ab212
refactor: clarify RSC migration parser and release safeguards (#3343)
## Summary
Follow-up to #3219 / fixes #3258. This PR is now rebased onto current
`origin/main`.
### RSC migration parser cleanup
- Rename `rsc_plugin_without_client_references?` to
`any_rsc_plugin_missing_client_references?` and document the existential
semantics.
- Consolidate lightweight JS scanner support/limitation notes onto
`advance_js_scan_state`, including caller coverage and
regex/template-literal caveats.
- Clarify why `add_rsc_client_references_setup` keeps defensive
duplicate-helper guards.
### Adjacent hardening
- Strengthen Node renderer `SECURITY:` comments for CommonJS wrapping
via both `additionalContext` and `supportModules`.
- Make the package-json publish rewrite use a same-directory temp file
plus atomic rename before marking the file as changed.
- Add direct coverage for the package-json pin fallback warning
formatter.
- Keep the retry-sleep guard in release metadata lookup explicit and
make the webpack helper test description path-agnostic.
## Review Follow-Ups
- **Must-fix:** none. Thread-aware review scan currently shows 0
unresolved review threads.
- **Optional fixed:** added the direct `supportModules` security anchor
and the `package_json_pin_fallback_warning` formatter spec.
- **Discuss / advice:** the prior `Generator tests / examples (3.2,
minimum)` failure was caused by `npm install shakapacker@10.1.0`
returning `ETARGET` before that npm version was available. The registry
now resolves `shakapacker@10.1.0`, and the React 16 pinned example task
passed locally.
- **Discuss / non-code CI:** the current `claude-review` failure is the
Claude Action hitting its weekly limit (`resets May 29, 3am UTC`), not a
repository test failure.
## CI / Test Plan
- [x] Rebased onto `origin/main`
- [x] `npm view shakapacker@10.1.0 version`
- [x] `(cd react_on_rails && bundle exec rake
run_rspec:shakapacker_examples_react16)`
- [x] `(cd react_on_rails && BUNDLE_FORCE_RUBY_PLATFORM=true bundle exec
rspec spec/react_on_rails/shakapacker_examples_rake_spec.rb
spec/react_on_rails/release_rake_helpers_spec.rb
spec/react_on_rails/generators/js_dependency_manager_spec.rb)`
- [x] Pre-push hook: branch Ruby RuboCop on changed Ruby files
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes RSC config auto-migration control flow and npm publish
package.json handling; mistakes could corrupt webpack configs or leave
bad publish manifests, though new specs cover the release path.
>
> **Overview**
> This PR tightens **RSC webpack config migration** logic and documents
**Node renderer sandboxing**, plus small **release** and **generator**
hardening.
>
> **RSC clientReferences migration** renames
`rsc_plugin_without_client_references?` to
**`any_rsc_plugin_missing_client_references?`** and documents that it is
an existential check (not the complement of “all plugins define
clientReferences”). **`prepare_rsc_client_references_rewrite!`**
replaces the old prepare helper so helper injection and rewrite
decisions stay correct when some plugins already use scoped
`clientReferences`. **`rsc_plugin_sections_safe_to_rewrite?`** now takes
**`is_server:`** when counting unparseable sections. Lightweight JS
scanner limits and caller contracts are **centralized on
`advance_js_scan_state`**, with extra comments on defensive
duplicate-helper guards.
>
> **Node renderer config** comments add explicit **SECURITY** notes that
**`supportModules: true`** and a plain-object **`additionalContext`**
both enable CommonJS wrapping and host **`require`**.
>
> **npm publish** rewrites `package.json` via a **same-directory temp
file and atomic rename**, sets the restore **`changed`** flag only after
rename succeeds, and adds a spec for failed rename cleanup.
>
> **JS dependency fallback** emits a clearer warning listing
**`name@version`** pins written to `package.json` when install fails.
The webpack helper test description is made path-agnostic.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
92f41ed. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* More robust npm publishing via atomic package.json replacement.
* Improved React Server Components setup handling for multi-plugin
configurations.
* **Documentation**
* Expanded security notes for supportModules and sandboxing behavior.
* **Improvements**
* Clearer, better-formatted package manager warning messages.
* **Tests**
* Updated/added tests and path-agnostic test descriptions for related
warnings.
<!-- review_stack_entry_start -->
[](https://app.coderabbit.ai/change-stack/shakacode/react_on_rails/pull/3343?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)
<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent ab50dec commit 26ab212
8 files changed
Lines changed: 165 additions & 49 deletions
File tree
- packages
- react-on-rails/tests
- rakelib
- react_on_rails
- lib/generators/react_on_rails
- rsc_setup
- spec/react_on_rails
- generators
Lines changed: 11 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
56 | 59 | | |
57 | 60 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
63 | 66 | | |
64 | | - | |
65 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
980 | 980 | | |
981 | 981 | | |
982 | 982 | | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
983 | 1000 | | |
984 | 1001 | | |
985 | 1002 | | |
986 | 1003 | | |
987 | 1004 | | |
988 | 1005 | | |
989 | | - | |
990 | | - | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
991 | 1012 | | |
992 | 1013 | | |
993 | 1014 | | |
| |||
1027 | 1048 | | |
1028 | 1049 | | |
1029 | 1050 | | |
1030 | | - | |
1031 | | - | |
1032 | | - | |
1033 | | - | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
1034 | 1055 | | |
1035 | 1056 | | |
1036 | 1057 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
| 581 | + | |
581 | 582 | | |
582 | 583 | | |
583 | 584 | | |
584 | 585 | | |
585 | 586 | | |
586 | 587 | | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
587 | 594 | | |
588 | 595 | | |
589 | 596 | | |
| |||
Lines changed: 84 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
| 126 | + | |
130 | 127 | | |
131 | 128 | | |
132 | 129 | | |
133 | 130 | | |
134 | 131 | | |
135 | 132 | | |
136 | 133 | | |
137 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
140 | 142 | | |
141 | 143 | | |
142 | 144 | | |
143 | 145 | | |
144 | 146 | | |
145 | 147 | | |
146 | 148 | | |
147 | | - | |
| 149 | + | |
148 | 150 | | |
149 | 151 | | |
150 | 152 | | |
151 | 153 | | |
152 | 154 | | |
153 | 155 | | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
159 | 160 | | |
160 | 161 | | |
161 | 162 | | |
| |||
165 | 166 | | |
166 | 167 | | |
167 | 168 | | |
168 | | - | |
| 169 | + | |
169 | 170 | | |
170 | 171 | | |
171 | 172 | | |
| |||
263 | 264 | | |
264 | 265 | | |
265 | 266 | | |
266 | | - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
267 | 273 | | |
268 | 274 | | |
269 | 275 | | |
| |||
273 | 279 | | |
274 | 280 | | |
275 | 281 | | |
276 | | - | |
277 | | - | |
| 282 | + | |
| 283 | + | |
278 | 284 | | |
279 | 285 | | |
280 | 286 | | |
| |||
434 | 440 | | |
435 | 441 | | |
436 | 442 | | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
446 | 449 | | |
447 | 450 | | |
448 | 451 | | |
| |||
475 | 478 | | |
476 | 479 | | |
477 | 480 | | |
478 | | - | |
479 | | - | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
480 | 526 | | |
481 | 527 | | |
482 | 528 | | |
| |||
915 | 961 | | |
916 | 962 | | |
917 | 963 | | |
918 | | - | |
919 | | - | |
920 | | - | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
921 | 974 | | |
922 | 975 | | |
923 | 976 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
231 | 241 | | |
232 | 242 | | |
233 | 243 | | |
| |||
0 commit comments