Commit b2a9aeb
Fix RSpec helper optimization gap with private SSR directories (#1838)
## Summary
Fixes an optimization gap in the RSpec helper where server bundle
staleness was not detected when using private SSR directories
(introduced in PR #1798).
- **Issue**: Default `webpack_generated_files: ['manifest.json']`
configuration only monitored client assets, missing server bundle
changes in private `ssr-generated/` directory
- **Impact**: Tests could run with stale server-side code, leading to
incorrect test results
- **Solution**: Enhanced `ensure_webpack_generated_files_exists` to
automatically include server bundles and other critical files in
monitoring list
## Root Cause
PR #1798 moved server bundles to private directories for security, but
the RSpec helper optimization continued monitoring only `manifest.json`
by default. This created a gap where:
1. Server bundle changes in `ssr-generated/server-bundle.js`
2. Client assets remain fresh in `public/packs-test/manifest.json`
3. RSpec helper reports "no rebuild needed" ❌
4. Tests run with stale server-side code
**Why this worked before:** Prior to PR #1798, both client and server
bundles were co-located in the same `public/packs/` directory, so the
RSpec helper's fallback logic would detect server bundle staleness even
when only monitoring `manifest.json`.
## Fix Details
**Before:**
```ruby
def ensure_webpack_generated_files_exists
return unless webpack_generated_files.empty? # ❌ Never runs with default config
# ...
end
```
**After:**
```ruby
def ensure_webpack_generated_files_exists
all_required_files = [
"manifest.json",
server_bundle_js_file,
rsc_bundle_js_file,
react_client_manifest_file,
react_server_client_manifest_file
].compact_blank
if webpack_generated_files.empty?
self.webpack_generated_files = all_required_files
else
missing_files = all_required_files.reject { |file| webpack_generated_files.include?(file) }
self.webpack_generated_files += missing_files if missing_files.any?
end
end
```
## Testing
- ✅ Comprehensive test coverage added for all scenarios
- ✅ Verified fix resolves gap with test apps
- ✅ Backward compatibility maintained
- ✅ Works across different directory configurations
## Test plan
- [x] RSpec helper correctly detects server bundle staleness with
default config
- [x] Cross-directory monitoring works (client in `public/`, server in
`ssr-generated/`)
- [x] Existing configurations continue working unchanged
- [x] Edge cases handled (nil values, custom configurations)
Fixes #1822
🤖 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/1838)
<!-- Reviewable:end -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- Bug Fixes
- More reliable two-phase population of required Webpack assets,
avoiding duplicates.
- Preserves pre-existing custom files while adding only missing
essentials.
- Avoids adding nil/empty entries when server bundle or manifests are
absent.
- Includes RSC and additional Pro manifests when configured.
- Improves server-bundle monitoring behavior for faster test runs.
- Tests
- Added comprehensive tests covering asset inclusion, duplication
prevention, custom configs, RSC support, and multi-directory monitoring.
<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: Justin Gordon <[email protected]>
Co-authored-by: Claude <[email protected]>1 parent 924fb00 commit b2a9aeb
File tree
2 files changed
+134
-7
lines changed- lib/react_on_rails
- spec/react_on_rails
2 files changed
+134
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
432 | | - | |
433 | | - | |
434 | | - | |
| 432 | + | |
435 | 433 | | |
436 | 434 | | |
437 | 435 | | |
438 | | - | |
439 | | - | |
440 | | - | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
441 | 439 | | |
442 | 440 | | |
443 | | - | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
444 | 449 | | |
445 | 450 | | |
446 | 451 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
290 | 301 | | |
291 | 302 | | |
292 | 303 | | |
| |||
626 | 637 | | |
627 | 638 | | |
628 | 639 | | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
629 | 751 | | |
630 | 752 | | |
631 | 753 | | |
| |||
0 commit comments