Commit 00202ba
refactor: consolidate Shakapacker bundler/config diagnostics helpers (#3619)
## Summary
Follow-up cleanup from #3508 (issue #3538). `Doctor`, `SystemChecker`,
and `Dev::ServerManager` each carried near-identical copies of the
`shakapacker.yml` parsing, assets-bundler detection, bundler labels, and
dev-server reload-mode helpers. This consolidates them into one mixin
and clears the remaining review nits.
## Changes (mapped to the #3538 checklist)
- **Extract shared helpers** — new
`ReactOnRails::ShakapackerConfigHelpers`, `include`d by
`Doctor`/`SystemChecker` and `extend`ed onto `Dev::ServerManager` (its
commands live on `class << self`). Mirrors the existing untyped
`ConfigPathResolver` mixin precedent.
- **Unify `YAML.safe_load` options** — `SystemChecker` now permits
`Symbol` values and rescues `ScriptError`, matching the other parsers
and `ServerMode`.
- **Memoize parsed config** — `parsed_shakapacker_config` is memoized
per `Doctor` instance (a fresh `Doctor` runs per invocation), so one
diagnosis reads/parses the file once. `ServerManager` intentionally does
**not** memoize — its `class << self` state would leak across specs, the
same reason `default_dev_server_mode` isn't memoized.
- **Remove the `dev_server_procfile_label` alias** — it was a pure
wrapper for `dev_server_label`.
- **Remove unused `ServerManager` helpers** —
`development_reload_feature_label`, `development_mode_title`, and
`hmr_procfile_description` were defined but never called.
- **Non-HMR React Refresh help indentation** — the rspack config-hint
bullet now lines up with the bullets above; webpack omits the bullet
instead of leaving a trailing blank line.
- **Babel qualifier decision** — documented that the
`react-refresh/babel` `WEBPACK_SERVE` qualifier is intentionally
bundler-agnostic (the generated `babel.config.js` gates it on
`WEBPACK_SERVE` for both webpack and rspack); only the bundler plugin
line is bundler-specific.
Net **−109 lines** across the three diagnostics files.
## Testing
- `bundle exec rspec` for `system_checker_spec`, `doctor_spec`,
`server_manager_spec` → **571 examples, 0 failures**
- `bundle exec rubocop` on all four files → **no offenses**
- `bundle exec rake rbs:validate` → **passes**. The RBS-declared
`ServerManager` API is unchanged (all 28 declared methods still present
with the same signatures), so runtime RBS type checking is unaffected.
The moved private helpers were never in the RBS, and the new mixin
follows the existing untyped `ConfigPathResolver` convention (no `.rbs`,
not in the Steepfile; Steep remains disabled in CI).
No CHANGELOG entry, per the repo's changelog guidelines (refactors are
excluded).
Closes #3538
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Refactor-only with no public API changes; behavior should match prior
diagnostics/CLI wording aside from intentional YAML/parser alignment and
help formatting fixes.
>
> **Overview**
> Introduces **`ReactOnRails::ShakapackerConfigHelpers`** so
**`Doctor`**, **`SystemChecker`**, and **`Dev::ServerManager`** share
one implementation for reading **`config/shakapacker.yml`**, resolving
**`SHAKAPACKER_CONFIG`**, detecting **webpack vs rspack**, and labeling
dev-server / HMR vs live reload.
>
> **`Doctor`** and **`SystemChecker`** **`include`** the mixin;
**`ServerManager`** **`extend`**s it so helpers stay on **`class <<
self`**. Duplicate private methods are removed from all three (~109 net
lines). **`SystemChecker`** now uses the same **`YAML.safe_load`**
options (**`Symbol`**, **`ScriptError`**) as the other parsers.
**`Doctor`** memoizes **`parsed_shakapacker_config`** per run;
**`ServerManager`** does not, to avoid class-level state leaking in
specs.
>
> Smaller cleanups: drop unused **`dev_server_procfile_label`** and dead
**`ServerManager`** label helpers; fix non-HMR React Refresh help so
rspack hints align with bullets (no extra blank line for webpack);
document that the **`react-refresh/babel`** **`WEBPACK_SERVE`** note
stays bundler-agnostic.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
9f5454f. 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
## Release Notes
* **Refactoring**
* Consolidated shakapacker configuration utilities into a dedicated
helper module for improved code organization and maintainability across
multiple internal classes.
* **Bug Fixes**
* Fixed React Refresh troubleshooting help text formatting to eliminate
unnecessary blank lines in certain bundler configurations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 9fedd96 commit 00202ba
4 files changed
Lines changed: 162 additions & 271 deletions
File tree
- react_on_rails/lib/react_on_rails
- dev
Lines changed: 16 additions & 117 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
24 | 29 | | |
25 | 30 | | |
26 | 31 | | |
| |||
472 | 477 | | |
473 | 478 | | |
474 | 479 | | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
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 | 480 | | |
523 | 481 | | |
524 | 482 | | |
| |||
572 | 530 | | |
573 | 531 | | |
574 | 532 | | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | | - | |
641 | | - | |
642 | | - | |
643 | 533 | | |
644 | 534 | | |
645 | 535 | | |
| |||
893 | 783 | | |
894 | 784 | | |
895 | 785 | | |
896 | | - | |
| 786 | + | |
897 | 787 | | |
898 | 788 | | |
899 | 789 | | |
900 | 790 | | |
901 | | - | |
902 | 791 | | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
903 | 798 | | |
904 | 799 | | |
905 | 800 | | |
| |||
913 | 808 | | |
914 | 809 | | |
915 | 810 | | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
916 | 815 | | |
917 | 816 | | |
918 | 817 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| 51 | + | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
| |||
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
61 | | - | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
341 | 342 | | |
342 | 343 | | |
343 | 344 | | |
344 | | - | |
| 345 | + | |
345 | 346 | | |
346 | 347 | | |
347 | 348 | | |
| |||
353 | 354 | | |
354 | 355 | | |
355 | 356 | | |
356 | | - | |
| 357 | + | |
357 | 358 | | |
358 | 359 | | |
359 | 360 | | |
| |||
549 | 550 | | |
550 | 551 | | |
551 | 552 | | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | 553 | | |
569 | 554 | | |
570 | 555 | | |
| 556 | + | |
571 | 557 | | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
586 | 563 | | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
| 564 | + | |
598 | 565 | | |
599 | | - | |
| 566 | + | |
600 | 567 | | |
601 | 568 | | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | | - | |
641 | | - | |
642 | | - | |
643 | | - | |
644 | | - | |
645 | | - | |
646 | 569 | | |
647 | 570 | | |
648 | 571 | | |
| |||
2069 | 1992 | | |
2070 | 1993 | | |
2071 | 1994 | | |
2072 | | - | |
2073 | | - | |
2074 | | - | |
2075 | | - | |
2076 | | - | |
2077 | | - | |
2078 | | - | |
2079 | | - | |
2080 | | - | |
2081 | | - | |
2082 | | - | |
2083 | | - | |
2084 | | - | |
2085 | | - | |
2086 | 1995 | | |
2087 | 1996 | | |
2088 | 1997 | | |
| |||
0 commit comments