Commit cbd4fc4
fix: pin third-party npm deps in generator to prevent peer dep conflicts (#3083)
## Summary
- Pin all third-party npm dependency constants in the install generator
and `bin/switch-bundler` to `^major.0.0` version ranges
- Fixes CI breakage from `@rspack/plugin-react-refresh@2.0.0` requiring
`@rspack/core@^2.0.0-0` while `@rspack/core` latest is still `1.7.11`
- Follows the same pinning pattern used by Shakapacker's own installer
## Why
The generator listed all third-party npm packages as bare names,
resolving to whatever `latest` pointed to at install time. When
`@rspack/plugin-react-refresh` published 2.0.0 with a peer dep on
`@rspack/core@^2.0.0-0` — while `@rspack/core` latest was still 1.7.11 —
npm refused to install, breaking three rspack generator specs on main.
Every comparable tool (Shakapacker, Webpacker, create-next-app,
create-vite) pins dependencies. This PR closes the gap.
## What changed
| Constant | Example pin | Notes |
|----------|------------|-------|
| `REACT_DEPENDENCIES` | `react@^19.0.0` | Current major |
| `CSS_DEPENDENCIES` | `css-loader@^7.0.0` | Current major |
| `RSPACK_DEPENDENCIES` | `@rspack/core@^1.0.0` | **The fix** |
| `RSPACK_DEV_DEPENDENCIES` | `@rspack/plugin-react-refresh@^1.0.0` |
**The fix** |
| `TYPESCRIPT_DEPENDENCIES` | `typescript@^6.0.0` | Current major |
| `SWC_DEPENDENCIES` | `@swc/core@^1.3.0` | Matches Shakapacker |
| `DEV_DEPENDENCIES` | bare | Pre-1.0, `^0.x` too narrow |
| `bin/switch-bundler` | All deps pinned | Same pattern |
## Verification
Created test apps from both `main` and this branch:
- **Basic install (no --rspack):** `diff package.json` → **identical**,
zero behavior change
- **`--rspack` on main:** fails with `ERESOLVE` peer dep conflict
- **`--rspack` on this branch:** succeeds, all packages installed at
expected 1.x versions
## Test plan
- [ ] CI `rspec-package-tests` passes (the three failing rspack specs
should be green)
- [ ] CI `rspec-unit-tests` passes (updated constant assertions in
`js_dependency_manager_spec.rb`)
- [ ] Verify no regressions in other generator specs
Closes #3082
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* npm dependencies are now pinned to caret-major ranges (e.g.,
^major.0.0) to avoid peer dependency conflicts and prevent
CI/bundler/SWC-related breakage.
* **Documentation**
* Changelog updated to describe the new dependency pinning approach and
rationale.
* **Installer**
* Install/switch tooling now handles versioned npm specifiers correctly
when updating project dependencies.
* **Tests**
* Test suite updated to verify the new versioned dependency behavior in
generators.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 2f70481 commit cbd4fc4
5 files changed
Lines changed: 157 additions & 46 deletions
File tree
- react_on_rails
- lib/generators/react_on_rails
- templates/base/base/bin
- spec/react_on_rails/generators
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
| |||
Lines changed: 31 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
55 | 64 | | |
56 | 65 | | |
57 | 66 | | |
58 | 67 | | |
59 | | - | |
60 | | - | |
61 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
62 | 71 | | |
63 | 72 | | |
64 | 73 | | |
65 | 74 | | |
66 | | - | |
| 75 | + | |
67 | 76 | | |
68 | 77 | | |
69 | 78 | | |
70 | 79 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
75 | 84 | | |
76 | 85 | | |
77 | 86 | | |
| 87 | + | |
78 | 88 | | |
79 | 89 | | |
80 | 90 | | |
81 | 91 | | |
82 | 92 | | |
83 | 93 | | |
84 | 94 | | |
85 | | - | |
86 | | - | |
| 95 | + | |
| 96 | + | |
87 | 97 | | |
88 | 98 | | |
89 | 99 | | |
| 100 | + | |
90 | 101 | | |
91 | | - | |
92 | | - | |
| 102 | + | |
| 103 | + | |
93 | 104 | | |
94 | 105 | | |
95 | 106 | | |
| |||
100 | 111 | | |
101 | 112 | | |
102 | 113 | | |
103 | | - | |
104 | | - | |
105 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
106 | 117 | | |
107 | 118 | | |
108 | 119 | | |
109 | 120 | | |
| 121 | + | |
110 | 122 | | |
111 | | - | |
112 | | - | |
| 123 | + | |
| 124 | + | |
113 | 125 | | |
114 | 126 | | |
115 | 127 | | |
| |||
222 | 234 | | |
223 | 235 | | |
224 | 236 | | |
225 | | - | |
| 237 | + | |
| 238 | + | |
226 | 239 | | |
227 | 240 | | |
228 | 241 | | |
| |||
Lines changed: 12 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
9 | 12 | | |
10 | | - | |
11 | | - | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
15 | | - | |
16 | | - | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| |||
83 | 86 | | |
84 | 87 | | |
85 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
86 | 92 | | |
87 | | - | |
| 93 | + | |
88 | 94 | | |
89 | 95 | | |
90 | | - | |
| 96 | + | |
91 | 97 | | |
92 | 98 | | |
93 | 99 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
664 | 664 | | |
665 | 665 | | |
666 | 666 | | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
667 | 677 | | |
668 | 678 | | |
669 | 679 | | |
| |||
0 commit comments