Commit 20e1f3d
authored
Fix auto-bundled component pack normalization (#3818)
## Summary
- Normalize auto-bundled component pack loading through
`RenderOptions#react_component_name`, so
`react_component("component_name")` loads `generated/ComponentName`
consistently with DOM/SSR lookup.
- Camelize generated public component names for actual files under the
configured auto-bundling component subdirectory, while preserving
server-bundle and store filename behavior.
- Preserve component/store generated-pack conflict protection for names
that now differ only by case.
Fixes #3809.
## Validation
- `bundle exec rspec spec/helpers/react_on_rails_helper_spec.rb:63
spec/packs_generator_spec.rb:1414` from `react_on_rails/spec/dummy` ->
12 examples, 0 failures.
- `bundle exec rspec spec/packs_generator_spec.rb` from
`react_on_rails/spec/dummy` -> 157 examples, 0 failures.
- `bundle exec rubocop lib/react_on_rails/helper.rb
lib/react_on_rails/packs_generator.rb
spec/dummy/spec/helpers/react_on_rails_helper_spec.rb
spec/dummy/spec/packs_generator_spec.rb` from `react_on_rails` -> 4
files, no offenses.
- `bundle exec rubocop` from `react_on_rails` -> 214 files, no offenses.
- `git diff --check` -> passed.
- `script/ci-changes-detector origin/main` -> Ruby core source code +
dummy app; recommended broad CI set.
- Pre-commit hook -> trailing newlines, autofix, RuboCop passed.
- Pre-push hook -> branch Ruby lint and markdown-links passed.
Known validation note: full `spec/helpers/react_on_rails_helper_spec.rb`
reaches unrelated SSR examples that require
`public/webpack/test/server-bundle.js`; the focused changed helper group
passed. A `codex review --base origin/main` run was started, inspected
the diff and Pro call sites, then was stopped after timing out without
final findings; its attempted broad helper spec also hit sandbox-only
Capybara port binding failures.
## Labels
Labels: full-ci
Reason: this is a small diff, but it affects runtime auto-bundled pack
loading and generated pack naming, so path-based full CI is appropriate
for generator/dummy-app coverage. No `benchmark` label recommended; the
change does not affect performance-sensitive rendering or benchmark code
paths.
## Release Mode
Current live tracker read: #3570 appears to be the active central RC
tracker, but it has no `Agent Release Mode` block. Per AGENTS.md,
treating merge decisions as `strict-rc` and not auto-merging.
## Agent Merge Confidence
Mode: strict-rc
Score: 7/10
Auto-merge recommendation: no
Affected areas: auto-bundling, generated pack loading, dummy app specs
CI detector: `script/ci-changes-detector origin/main` -> Ruby core
source code + dummy app; broad CI recommended
Validation run:
- `bundle exec rspec spec/helpers/react_on_rails_helper_spec.rb:63
spec/packs_generator_spec.rb:1414` -> passed, 12 examples
- `bundle exec rspec spec/packs_generator_spec.rb` -> passed, 157
examples
- `bundle exec rubocop` in `react_on_rails` -> passed, 214 files
- focused RuboCop on touched files -> passed, 4 files
- `git diff --check` -> passed
Review/check gate:
- Local self-review: complete
- Codex review: timed out/stopped after exploratory output; no final
findings emitted
- GitHub checks: pending PR creation
Known residual risk: full CI not yet complete; full helper spec needs
generated SSR bundle assets and was not used as local pass/fail evidence
Finalized by: not independently finalized
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes runtime generated pack paths and public component names for
auto-bundled apps; mis-scoped camelization could break existing
snake_case registrations until packs are regenerated.
>
> **Overview**
> Aligns **auto-bundled** pack naming and loading so snake_case view
names (e.g. `react_component("component_name")`) resolve to the same
**camelized** public name as generated packs
(`generated/ComponentName`).
>
> **`load_pack_for_generated_component`** now uses
`RenderOptions#react_component_name` for dev existence checks and
`append_*_pack_tag` paths instead of the raw helper argument, matching
SSR/DOM registration.
>
> **`PacksGenerator#component_name`** camelizes basenames only for
component files under the configured `components_subdirectory`; files
outside that path keep the previous basename behavior. Component/store
conflict detection is **case-insensitive**, with clearer error text when
casing differs.
>
> Specs cover camelized pack tags, snake_case naming rules, and
case-only component/store conflicts.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
481b108. 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**
* Component/store name conflict detection is now case-insensitive,
catching more naming issues.
* Component name normalization improved for snake_case and client/server
filename variants for consistent runtime names.
* **Tests**
* Updated specs to reflect the refined naming behavior and generated
pack expectations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 38835e9 commit 20e1f3d
4 files changed
Lines changed: 72 additions & 20 deletions
File tree
- react_on_rails
- lib/react_on_rails
- spec/dummy/spec
- helpers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
397 | | - | |
| 397 | + | |
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
| 401 | + | |
401 | 402 | | |
402 | | - | |
403 | | - | |
| 403 | + | |
| 404 | + | |
404 | 405 | | |
405 | 406 | | |
406 | 407 | | |
407 | 408 | | |
408 | 409 | | |
409 | 410 | | |
410 | 411 | | |
411 | | - | |
412 | | - | |
| 412 | + | |
| 413 | + | |
413 | 414 | | |
414 | 415 | | |
415 | 416 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
178 | 183 | | |
179 | 184 | | |
180 | 185 | | |
| |||
715 | 720 | | |
716 | 721 | | |
717 | 722 | | |
| 723 | + | |
718 | 724 | | |
719 | | - | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
720 | 736 | | |
721 | 737 | | |
722 | 738 | | |
| |||
Lines changed: 19 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
64 | 66 | | |
65 | | - | |
| 67 | + | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
72 | | - | |
| 74 | + | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
76 | | - | |
77 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
| |||
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
98 | | - | |
| 101 | + | |
99 | 102 | | |
100 | | - | |
| 103 | + | |
101 | 104 | | |
102 | 105 | | |
103 | | - | |
| 106 | + | |
104 | 107 | | |
105 | 108 | | |
106 | 109 | | |
| |||
115 | 118 | | |
116 | 119 | | |
117 | 120 | | |
118 | | - | |
119 | | - | |
120 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
121 | 125 | | |
122 | 126 | | |
123 | 127 | | |
124 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
125 | 133 | | |
126 | | - | |
| 134 | + | |
127 | 135 | | |
128 | 136 | | |
129 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1162 | 1162 | | |
1163 | 1163 | | |
1164 | 1164 | | |
1165 | | - | |
| 1165 | + | |
1166 | 1166 | | |
1167 | | - | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
1168 | 1171 | | |
1169 | 1172 | | |
1170 | 1173 | | |
| |||
1420 | 1423 | | |
1421 | 1424 | | |
1422 | 1425 | | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
1423 | 1438 | | |
1424 | 1439 | | |
1425 | 1440 | | |
1426 | 1441 | | |
1427 | 1442 | | |
1428 | 1443 | | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
1429 | 1450 | | |
1430 | 1451 | | |
1431 | 1452 | | |
1432 | 1453 | | |
1433 | 1454 | | |
1434 | 1455 | | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
1435 | 1462 | | |
1436 | 1463 | | |
1437 | 1464 | | |
| |||
0 commit comments