Skip to content

Commit 595dd21

Browse files
justin808claude
andauthored
Allow webpack-cli v7 in peer dependencies (#1021)
## Summary - Adds `^7.0.0` to the `webpack-cli` peer dependency range in `package.json` - Updates `docs/peer-dependencies.md` to match Fixes #1020 ## Test plan - [x] Verified `package.json` peer dependency now includes `^7.0.0` - [ ] CI passes 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Dependency constraint changes (including dropping webpack-dev-server v4 and raising minimum webpack) can break existing consumer setups and CI if lockfiles/Node versions aren’t updated. Code changes are small and covered by added tests, but affect install and dev-server configuration paths. > > **Overview** > Updates Shakapacker’s Webpack toolchain compatibility: peer dependency ranges now include `webpack-cli` `^7`, bump minimum `webpack` to `^5.101.0`, and drop `webpack-dev-server` v4 support in favor of `^5.2.2` (documented as breaking). > > Adjusts installer and runtime behavior to match: `shakapacker:install` now defaults `webpack-cli` installs to `^6` for Node 20.0–20.8 compatibility while still allowing v7, and `webpackDevServerConfig` warns and ignores removed `dev_server` YAML hooks (`on_before_setup_middleware`/`on_after_setup_middleware`). Tests, dummy app configs/locks, and docs are updated accordingly, along with minor CI and ignore-file tweaks. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit a76181e. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Support added for webpack v5.101, webpack-cli v7, and webpack-dev-server ^5.2.2. * **Documentation** * Updated compatibility docs, examples, and changelog to reflect new version ranges. * **Chores** * Dev dependency versions bumped to align tooling and examples; CI workflow quoting standardized. * **Tests** * Jest mocks refined and TypeScript verification command options adjusted for CI. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
1 parent bfc28c5 commit 595dd21

21 files changed

Lines changed: 409 additions & 254 deletions

.github/workflows/dummy.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
persist-credentials: false
3131
- uses: actions/setup-node@v4
3232
with:
33-
node-version: "20"
33+
node-version: "20.x"
3434
- uses: ruby/setup-ruby@v1
3535
with:
3636
ruby-version: "3.2"
@@ -40,7 +40,6 @@ jobs:
4040
bundle install
4141
yarn install --frozen-lockfile --production=false
4242
npm install -g yalc
43-
cd spec/dummy && npm install
4443
4544
- name: Build TypeScript
4645
run: yarn build

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ yalc.lock
2626
# Config exporter output directory
2727
shakapacker-config-exports/
2828

29+
# Webpack build output
30+
public/packs/
31+
2932
# TypeScript generated files
3033
package/**/*.d.ts
3134
package/**/*.d.ts.map

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,21 @@
1212
### Added
1313

1414
- **Added `bin/shakapacker-watch` binstub for clean Ctrl-C shutdown in Procfile-based workflows**. [PR #1026](https://github.com/shakacode/shakapacker/pull/1026) by [justin808](https://github.com/justin808). The new wrapper script traps INT/TERM signals and forwards TERM to the underlying `bin/shakapacker --watch` process, preventing Ruby interrupt backtraces when stopping `bin/dev`. Use `bin/shakapacker-watch --watch` in Procfiles instead of `bin/shakapacker --watch`.
15+
- Allow `webpack-cli` v7 (`^7.0.0`) in peer dependencies. [PR #1021](https://github.com/shakacode/shakapacker/pull/1021) by [justin808](https://github.com/justin808). Fixes [#1020](https://github.com/shakacode/shakapacker/issues/1020). Note: `webpack-cli` v7 requires Node.js >= 20.9.0.
16+
17+
### ⚠️ Breaking Changes
18+
19+
- Bump minimum `webpack` version to `^5.101.0` (was `^5.76.0`). [PR #1021](https://github.com/shakacode/shakapacker/pull/1021) by [justin808](https://github.com/justin808).
20+
- Require `webpack-dev-server` `^5.2.2`; support for v4 (`^4.15.2`) has been dropped. [PR #1021](https://github.com/shakacode/shakapacker/pull/1021) by [justin808](https://github.com/justin808).
21+
22+
### Changed
23+
24+
- `shakapacker:install` now defaults `webpack-cli` installs to the latest v6 range to stay compatible with Node.js `20.0-20.8`; v7 remains supported via peer dependencies for Node.js >= 20.9.0. [PR #1021](https://github.com/shakacode/shakapacker/pull/1021) by [justin808](https://github.com/justin808).
25+
- Detect deprecated `on_before_setup_middleware` and `on_after_setup_middleware` keys in `dev_server` config, warn, and ignore them for webpack-dev-server v5 compatibility. Use `setup_middlewares` instead. [PR #1021](https://github.com/shakacode/shakapacker/pull/1021) by [justin808](https://github.com/justin808).
1526

1627
### Fixed
1728

18-
- **Ensure latest `compression-webpack-plugin` is installed by `shakapacker:install` [PR #1035](https://github.com/shakacode/shakapacker/pull/1035) by [G-Rath](https://github.com/G-Rath)
29+
- **Ensure latest `compression-webpack-plugin` is installed by `shakapacker:install`** [PR #1035](https://github.com/shakacode/shakapacker/pull/1035) by [G-Rath](https://github.com/G-Rath).
1930

2031
## [v9.7.0] - March 15, 2026
2132

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,16 @@ Depending on your setup, you'll need different subsets of the optional peer depe
254254
"babel-loader": "^8.2.4",
255255
"compression-webpack-plugin": "^9.0.0",
256256
"terser-webpack-plugin": "^5.3.1",
257-
"webpack": "^5.76.0",
257+
"webpack": "^5.101.0",
258258
"webpack-assets-manifest": "^5.0.6",
259-
"webpack-cli": "^5.0.0",
260-
"webpack-dev-server": "^5.0.0"
259+
"webpack-cli": "^6.0.0",
260+
"webpack-dev-server": "^5.2.2"
261261
}
262262
}
263263
```
264264

265+
> **Note:** `webpack-cli` v7 is also supported but requires Node.js >= 20.9.0. If you're on Node >= 20.9.0, you can use `"webpack-cli": "^7.0.0"` instead. See [peer-dependencies.md](./docs/peer-dependencies.md) for the full supported range.
266+
265267
**For Webpack + SWC (faster alternative):**
266268

267269
```json
@@ -272,10 +274,10 @@ Depending on your setup, you'll need different subsets of the optional peer depe
272274
"swc-loader": "^0.2.0",
273275
"compression-webpack-plugin": "^9.0.0",
274276
"terser-webpack-plugin": "^5.3.1",
275-
"webpack": "^5.76.0",
277+
"webpack": "^5.101.0",
276278
"webpack-assets-manifest": "^5.0.6",
277-
"webpack-cli": "^5.0.0",
278-
"webpack-dev-server": "^5.0.0"
279+
"webpack-cli": "^6.0.0",
280+
"webpack-dev-server": "^5.2.2"
279281
}
280282
}
281283
```

docs/optional-peer-dependencies.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ As of Shakapacker v9, all peer dependencies are marked as optional via `peerDepe
2323
"webpack-merge": "^5.8.0" // Direct dependency - always available
2424
},
2525
"peerDependencies": {
26-
"webpack": "^5.76.0",
26+
"webpack": "^5.101.0",
2727
"@rspack/core": "^1.0.0"
2828
// ... all build tools
2929
},
@@ -54,8 +54,8 @@ Type-only imports are erased during compilation and don't trigger module resolut
5454
{
5555
"dependencies": {
5656
"shakapacker": "^9.0.0",
57-
"webpack": "^5.76.0",
58-
"webpack-cli": "^5.0.0",
57+
"webpack": "^5.101.0",
58+
"webpack-cli": "^6.0.0",
5959
"babel-loader": "^8.2.4",
6060
"@babel/core": "^7.17.9",
6161
"@babel/preset-env": "^7.16.11"
@@ -69,14 +69,16 @@ Type-only imports are erased during compilation and don't trigger module resolut
6969
{
7070
"dependencies": {
7171
"shakapacker": "^9.0.0",
72-
"webpack": "^5.76.0",
73-
"webpack-cli": "^5.0.0",
72+
"webpack": "^5.101.0",
73+
"webpack-cli": "^6.0.0",
7474
"@swc/core": "^1.3.0",
7575
"swc-loader": "^0.2.0"
7676
}
7777
}
7878
```
7979

80+
> **Note:** `webpack-cli` v7 is also supported but requires Node.js >= 20.9.0. If your project meets that requirement, you can use `"webpack-cli": "^7.0.0"` instead.
81+
8082
### Rspack + SWC (10x Faster Bundling)
8183

8284
```json
@@ -112,7 +114,7 @@ The installer (`bundle exec rake shakapacker:install`) only adds packages needed
112114

113115
Version ranges are carefully chosen for compatibility:
114116

115-
- **Broader ranges for peer deps** - Allows flexibility (e.g., `^5.76.0` for webpack)
117+
- **Broader ranges for peer deps** - Allows flexibility (e.g., `^5.101.0` for webpack)
116118
- **Specific versions in devDeps** - Ensures testing against known versions
117119
- **Forward compatibility** - Ranges include future minor versions (e.g., `^5.0.0 || ^6.0.0`)
118120

docs/peer-dependencies.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ To simplify peer dependencies while supporting both webpack & rspack, we decided
1919
```text
2020
"mini-css-extract-plugin": "^2.0.0",
2121
"terser-webpack-plugin": "^5.3.1",
22-
"webpack": "^5.76.0",
22+
"webpack": "^5.101.0",
2323
"webpack-assets-manifest": "^5.0.6 || ^6.0.0",
24-
"webpack-cli": "^4.9.2 || ^5.0.0 || ^6.0.0",
25-
"webpack-dev-server": "^4.15.2 || ^5.2.2",
24+
"webpack-cli": "^4.9.2 || ^5.0.0 || ^6.0.0 || ^7.0.0",
25+
"webpack-dev-server": "^5.2.2",
2626
"webpack-merge": "^5.8.0 || ^6.0.0",
2727
"webpack-subresource-integrity": "^5.1.0"
2828
```

docs/v9_upgrade.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,15 @@ assets_bundler: "rspack" # or 'webpack' (default)
337337
"shakapacker": "^9.0.0",
338338
"@swc/core": "^1.3.0",
339339
"swc-loader": "^0.2.0",
340-
"webpack": "^5.76.0",
341-
"webpack-cli": "^5.0.0",
342-
"webpack-dev-server": "^5.0.0"
340+
"webpack": "^5.101.0",
341+
"webpack-cli": "^6.0.0",
342+
"webpack-dev-server": "^5.2.2"
343343
}
344344
}
345345
```
346346

347+
> **Note:** `webpack-cli` v7 is also supported but requires Node.js >= 20.9.0. v4 through v6 work on all supported Node versions. See the full supported range in [peer-dependencies.md](./peer-dependencies.md).
348+
347349
You won't get warnings about missing Babel, Rspack, or esbuild packages.
348350

349351
## Migration Steps

lib/install/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
"webpack": {
88
"mini-css-extract-plugin": "^2.0.0",
99
"terser-webpack-plugin": "^5.3.1",
10-
"webpack": "^5.76.0",
10+
"webpack": "^5.101.0",
1111
"webpack-assets-manifest": "^5.0.6 || ^6.0.0",
12-
"webpack-cli": "^4.9.2 || ^5.0.0 || ^6.0.0",
13-
"webpack-dev-server": "^4.15.2 || ^5.2.2",
12+
"webpack-cli": "^4.9.2 || ^5.0.0 || ^6.0.0 || ^7.0.0",
13+
"webpack-dev-server": "^5.2.2",
1414
"webpack-merge": "^5.8.0 || ^6.0.0",
1515
"webpack-subresource-integrity": "^5.1.0"
1616
},

lib/install/template.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,18 @@
262262

263263
peers.each do |(package, version)|
264264
# constraints conventionally are from oldest to latest
265-
latest_version = version.split("||").last.strip
266-
entry = "#{package}@#{latest_version}"
265+
constraints = version.split("||").map(&:strip)
266+
selected_version = constraints.last
267+
268+
if package == "webpack-cli" && constraints.length > 1
269+
# Keep installer defaults compatible with Node.js >= 20.0.0.
270+
# webpack-cli v7 requires Node >= 20.9.0, so default to the latest v6 range.
271+
selected_version = constraints.find { |constraint| constraint.start_with?("^6.") } || selected_version
272+
say " ℹ️ Defaulting to webpack-cli #{selected_version} for broad Node.js compatibility.", :blue
273+
say " ℹ️ If you're on Node >= 20.9.0, you can upgrade to webpack-cli ^7.0.0 manually.", :blue
274+
end
275+
276+
entry = "#{package}@#{selected_version}"
267277

268278
if dev_dependency_packages.include? package
269279
dev_dependencies_to_add << entry

lib/shakapacker/doctor.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ def check_peer_dependencies
273273

274274
def check_webpack_peer_deps(deps)
275275
essential_webpack = {
276-
"webpack" => "^5.76.0",
277-
"webpack-cli" => "^4.9.2 || ^5.0.0"
276+
"webpack" => "^5.101.0",
277+
"webpack-cli" => "^4.9.2 || ^5.0.0 || ^6.0.0 || ^7.0.0"
278278
}
279279

280280
essential_webpack.each do |package, version|

0 commit comments

Comments
 (0)