Skip to content

Commit 0a15053

Browse files
ihabadhamclaude
andauthored
fix: align rspack v2 peer deps and installer defaults (#1091)
## Summary Make Shakapacker's Rspack v2 support self-consistent by: - widening `@rspack/plugin-react-refresh` peer support to `^1.0.0 || ^2.0.0-0` - widening `lib/install/package.json` so `shakapacker:install` selects Rspack v2 for `@rspack/core` and `@rspack/cli` - updating the Rspack docs/examples to match the new default install path ## Why PR #975 widened the root peer ranges for `@rspack/core` and `@rspack/cli`, but `shakapacker:install` still read `lib/install/package.json` and installed the v1 line: - `@rspack/core: ^1.0.0` - `@rspack/cli: ^1.0.0` At the same time, `@rspack/plugin-react-refresh` stayed pinned to `^1.0.0` in `package.json`. That left Rspack v2 support in an inconsistent state: 1. fresh installs still started on Rspack v1 2. downstream projects that intentionally upgraded to Rspack v2 could end up in install / reinstall conflicts because Shakapacker still advertised plugin v1-only peer support This surfaced directly in the downstream React on Rails Rspack v2 work: shakacode/react_on_rails#3084. ## What this changes - `package.json` - `@rspack/plugin-react-refresh`: `^1.0.0` → `^1.0.0 || ^2.0.0-0` - `lib/install/package.json` - `@rspack/core`: `^1.0.0` → `^1.0.0 || ^2.0.0-0` - `@rspack/cli`: `^1.0.0` → `^1.0.0 || ^2.0.0-0` - docs - remove the stale plugin-v1 note - update peer-deps docs and dependency examples to match the new supported/default path Because `lib/install/template.rb` already selects `constraints.last`, widening those installer ranges makes fresh Rspack installs choose the v2 prerelease line automatically. ## Verification I verified this with real fresh Rails apps, not just isolated package-manager commands. ### 1) Shakapacker alone Using a local path gem plus a locally packed npm tarball from this branch: - `bundle exec rails shakapacker:install` with `SHAKAPACKER_ASSETS_BUNDLER=rspack` wrote: - `@rspack/core: ^2.0.0-0` - `@rspack/cli: ^2.0.0-0` - `npm install --save-dev @rspack/cli@^2.0.0-0 @rspack/plugin-react-refresh@^2.0.0 react-refresh` succeeded - clean later `npm install` succeeded - `bundle exec rails shakapacker:compile` succeeded with Rspack `2.0.0-rc.1` ### 2) Full React on Rails install flow Using this Shakapacker branch plus the downstream React on Rails PR branch locally: - `bundle exec rails generate react_on_rails:install --rspack --ignore-warnings` succeeded - resulting app had: - `@rspack/core: ^2.0.0-0` - `@rspack/cli: ^2.0.0-0` - `@rspack/plugin-react-refresh: 2.0.0` - clean later `npm install` succeeded - `bundle exec rails shakapacker:compile` succeeded So this removes the need for downstream generator-time workarounds and gives React on Rails a clean path to ship Rspack v2. ## Pull Request checklist - [x] Update documentation - [x] Update CHANGELOG file <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Updated docs and examples to reference the Rspack v2 prerelease ranges and Shakapacker v10, and removed an outdated note about plugin versioning. * **Chores** * Broadened dependency/peer ranges to support both the stable v1 line and the v2 prerelease line and adjusted install defaults to use the latest supported Rspack range. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 860a5ef commit 0a15053

7 files changed

Lines changed: 19 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99

1010
## [Unreleased]
1111

12+
### Changed
13+
14+
- **Changed `shakapacker:install` to default fresh Rspack installs to v2 (`^2.0.0-0`)**. [PR #1091](https://github.com/shakacode/shakapacker/pull/1091) by [ihabadham](https://github.com/ihabadham). `lib/install/package.json` now declares `@rspack/core` and `@rspack/cli` as `^1.0.0 || ^2.0.0-0`; fresh installs pick the v2 range. Existing apps are unaffected. Note: Rspack v2 requires Node.js 20.19.0+.
15+
16+
### Fixed
17+
18+
- **Widened `@rspack/plugin-react-refresh` peer range to `^1.0.0 || ^2.0.0-0`**. [PR #1091](https://github.com/shakacode/shakapacker/pull/1091) by [ihabadham](https://github.com/ihabadham). Fixes the `ERESOLVE` conflict when installing `@rspack/plugin-react-refresh@^2.0.0` alongside `shakapacker@10.0.0`.
19+
1220
## [v10.0.0] - April 8, 2026
1321

1422
### Added

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ Depending on your setup, you'll need different subsets of the optional peer depe
281281
{
282282
"dependencies": {
283283
"shakapacker": "^10.0.0",
284-
"@rspack/core": "^1.0.0",
285-
"@rspack/cli": "^1.0.0",
284+
"@rspack/core": "^2.0.0-0",
285+
"@rspack/cli": "^2.0.0-0",
286286
"@swc/core": "^1.3.0",
287287
"swc-loader": "^0.2.0",
288288
"rspack-manifest-plugin": "^5.0.0"

docs/optional-peer-dependencies.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ As of Shakapacker v9 (and continuing in v10), all peer dependencies are marked a
2424
},
2525
"peerDependencies": {
2626
"webpack": "^5.101.0",
27-
"@rspack/core": "^1.0.0"
27+
"@rspack/core": "^1.0.0 || ^2.0.0-0"
2828
// ... all build tools
2929
},
3030
"peerDependenciesMeta": {
@@ -85,8 +85,8 @@ Type-only imports are erased during compilation and don't trigger module resolut
8585
{
8686
"dependencies": {
8787
"shakapacker": "^10.0.0",
88-
"@rspack/core": "^1.0.0",
89-
"@rspack/cli": "^1.0.0",
88+
"@rspack/core": "^2.0.0-0",
89+
"@rspack/cli": "^2.0.0-0",
9090
"rspack-manifest-plugin": "^5.0.0"
9191
}
9292
}

docs/peer-dependencies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ releases support.
3535
```text
3636
"@rspack/cli": "^1.0.0 || ^2.0.0-0"
3737
"@rspack/core": "^1.0.0 || ^2.0.0-0"
38-
"@rspack/plugin-react-refresh": "^1.0.0"
38+
"@rspack/plugin-react-refresh": "^1.0.0 || ^2.0.0-0"
3939
"rspack-manifest-plugin": "^5.0.0"
4040
```
4141

docs/rspack.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ Shakapacker supports [Rspack](https://rspack.rs) as an alternative assets bundle
88

99
Shakapacker supports both Rspack v1 (`^1.0.0`) and Rspack v2 (`^2.0.0-0`). No configuration changes are needed when upgrading between rspack versions — shakapacker's generated config works with both.
1010

11+
Fresh installs default to the latest supported Rspack range from `lib/install/package.json`, which is currently the Rspack v2 prerelease line (`^2.0.0-0`).
12+
1113
**Rspack v2 note:** Rspack v2 ships as a pure ESM package and requires **Node.js 20.19.0+**.
1214

1315
**Rspack v1 note:** Rspack v1 itself supports older Node versions, but Shakapacker requires Node 20+.
1416

15-
**React refresh plugin note:** `@rspack/plugin-react-refresh` currently remains on the v1 line in Shakapacker peer deps.
16-
1717
**Current CI coverage note:** Shakapacker currently validates rspack v2 using `2.0.0-rc.0`. The rspack v2 dev dependencies are intentionally pinned while v2 is pre-release and should be revisited when stable `2.0.0` is released.
1818

1919
### Why upgrade to Rspack v2?

lib/install/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"rspack": {
3-
"@rspack/cli": "^1.0.0",
4-
"@rspack/core": "^1.0.0",
3+
"@rspack/cli": "^1.0.0 || ^2.0.0-0",
4+
"@rspack/core": "^1.0.0 || ^2.0.0-0",
55
"rspack-manifest-plugin": "^5.0.0"
66
},
77
"webpack": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
"@babel/runtime": "^7.17.9",
103103
"@rspack/cli": "^1.0.0 || ^2.0.0-0",
104104
"@rspack/core": "^1.0.0 || ^2.0.0-0",
105-
"@rspack/plugin-react-refresh": "^1.0.0",
105+
"@rspack/plugin-react-refresh": "^1.0.0 || ^2.0.0-0",
106106
"@swc/core": "^1.3.0",
107107
"@types/babel__core": "^7.0.0",
108108
"@types/webpack": "^5.0.0",

0 commit comments

Comments
 (0)