Skip to content

Allow webpack-cli v7 in peer dependencies#1021

Merged
justin808 merged 13 commits intomainfrom
jg/1020-webpack-cli-v7
Apr 2, 2026
Merged

Allow webpack-cli v7 in peer dependencies#1021
justin808 merged 13 commits intomainfrom
jg/1020-webpack-cli-v7

Conversation

@justin808
Copy link
Copy Markdown
Member

@justin808 justin808 commented Mar 24, 2026

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

  • Verified package.json peer dependency now includes ^7.0.0
  • CI passes

🤖 Generated with Claude Code


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.

Written by Cursor Bugbot for commit a76181e. This will update automatically on new commits. Configure here.

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 24, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Raised webpack minimum to ^5.101.0, added ^7.0.0 support for webpack-cli, constrained webpack-dev-server to ^5.2.2 across manifests and docs; bumped dev webpack to 5.101.3; adjusted CI workflow quoting and TypeScript flags; renamed several Jest mock constructors in a test; added CHANGELOG entry.

Changes

Cohort / File(s) Summary
Package manifests & installer
package.json, lib/install/package.json, spec/dummy/package.json, lib/shakapacker/doctor.rb
Bumped webpack peer/dev requirement to ^5.101.0 / 5.101.3; expanded webpack-cli ranges to include ^7.0.0; restricted webpack-dev-server to ^5.2.2; increased engines.node in spec/dummy.
Documentation & examples
docs/peer-dependencies.md, docs/optional-peer-dependencies.md, docs/v9_upgrade.md, README.md, CHANGELOG.md
Updated docs and example snippets to the new webpack / webpack-cli / webpack-dev-server version ranges; added Unreleased changelog entry.
CI workflows
.github/workflows/trigger-docs-site.yml, .github/workflows/dummy.yml, .github/workflows/node.yml
Changed docs-site glob quoting ('docs/**'"docs/**"); removed cd spec/dummy && npm install step; added --types node and --ignoreDeprecations 6.0 to npx tsc invocations.
Tests
test/package/bundlerUtils.rspack.test.js
Renamed several anonymous Jest mock constructors to named mock functions for @rspack/core plugin mocks (no behavioral change).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through packages, nudged versions anew,
Welcomed v7 and tightened a few,
Docs and CI polished, mocks given names,
A small carrot of change—no tangled snares or blames. 🥕

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Several changes exceed core scope: TypeScript compilation flag modifications (.github/workflows/node.yml), Jest mock function naming updates (test/package/bundlerUtils.rspack.test.js), and YAML quoting syntax change (.github/workflows/trigger-docs-site.yml) are unrelated to webpack-cli v7 peer dependency support. Isolate webpack-cli v7 peer dependency changes into a focused PR; move TypeScript, Jest mock, and workflow formatting changes to separate PRs addressing their specific concerns.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Allow webpack-cli v7 in peer dependencies' directly and clearly summarizes the main change across the entire pull request.
Linked Issues check ✅ Passed All code changes directly address the primary objective: webpack-cli peer dependency extended from ^4.9.2 || ^5.0.0 || ^6.0.0 to include ^7.0.0, eliminating the incompatibility error for projects using webpack-cli v7 [#1020].
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jg/1020-webpack-cli-v7

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Install template not updated for webpack-cli v7
    • Updated lib/install/package.json so the installer’s webpack dependency template now includes the ^7.0.0 range for webpack-cli, matching the root package and docs.

Create PR

Or push these changes by commenting:

@cursor push 5588702eb4
Preview (5588702eb4)
diff --git a/lib/install/package.json b/lib/install/package.json
--- a/lib/install/package.json
+++ b/lib/install/package.json
@@ -9,7 +9,7 @@
     "terser-webpack-plugin": "^5.3.1",
     "webpack": "^5.76.0",
     "webpack-assets-manifest": "^5.0.6 || ^6.0.0",
-    "webpack-cli": "^4.9.2 || ^5.0.0 || ^6.0.0",
+    "webpack-cli": "^4.9.2 || ^5.0.0 || ^6.0.0 || ^7.0.0",
     "webpack-dev-server": "^4.15.2 || ^5.2.2",
     "webpack-merge": "^5.8.0 || ^6.0.0",
     "webpack-subresource-integrity": "^5.1.0"

Comment thread package.json
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 24, 2026

Greptile Summary

This PR extends the webpack-cli peer dependency range in package.json from ^4.9.2 || ^5.0.0 || ^6.0.0 to ^4.9.2 || ^5.0.0 || ^6.0.0 || ^7.0.0, keeping docs/peer-dependencies.md and CHANGELOG.md in sync. The change is minimal and consistent across all three files.

Key points to be aware of:

  • webpack-cli v7 dropped webpack-dev-server@v4 support — users combining webpack-cli@v7 with webpack-dev-server@v4 (still in the peer dep range as ^4.15.2) will hit runtime failures with the dev server. A compatibility note in the docs is recommended.
  • webpack-cli v7 requires webpack >= 5.82.0 — the current webpack peer dep allows as low as ^5.76.0, which could cause issues for users on older webpack patch versions.
  • devDependency still pinned to ^6.0.0 — CI is not yet exercising the newly permitted v7, consistent with the unchecked "CI passes" item in the PR description.

Confidence Score: 4/5

  • Safe to merge with a few follow-up compatibility notes recommended before the next release.
  • The change itself is a one-line peer dep range extension, consistently applied across package.json, docs, and CHANGELOG. The main outstanding item is that CI hasn't been verified against webpack-cli v7, and there are two cross-peer-dep compatibility edge cases (webpack-dev-server v4 and webpack < 5.82.0) worth documenting. None of these block the primary user path of simply adding ^7.0.0 support.
  • package.json — the devDependency and cross-peer-dep compatibility constraints deserve a second look before release.

Important Files Changed

Filename Overview
package.json Adds ^7.0.0 to the webpack-cli peer dependency range. The devDependency still references ^6.0.0, meaning CI doesn't test against v7 yet. Two cross-peer-dep compatibility notes: webpack-cli v7 dropped webpack-dev-server@v4 support and requires webpack >= 5.82.0, both of which conflict with the current lower bounds in peer deps.
docs/peer-dependencies.md Docs kept in sync with package.json peer dep change — ^7.0.0 appended to the webpack-cli range.
CHANGELOG.md Properly adds a changelog entry under [Unreleased] referencing the PR and linked issue.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User installs shakapacker] --> B{Which webpack-cli version?}
    B --> C[v4 / v5 / v6]
    B --> D[v7 - NEW in this PR]
    C --> E[Works with webpack-dev-server v4 or v5]
    D --> F{Which webpack-dev-server?}
    F --> G[v5 - OK]
    F --> H[v4 - Runtime failure\nwds@v4 dropped in cli@v7]
    D --> I{Which webpack version?}
    I --> J[>= 5.82.0 - OK]
    I --> K[5.76 - 5.81 - May fail\ncli@v7 requires >= 5.82.0]
Loading

Comments Outside Diff (1)

  1. package.json, line 94 (link)

    P2 devDependency not updated to webpack-cli v7

    The devDependencies entry for webpack-cli is still pinned to ^6.0.0, meaning CI will run tests against webpack-cli v6 rather than v7. This aligns with the unchecked "CI passes" item in the PR description.

    To fully validate webpack-cli v7 compatibility, consider bumping the dev dependency:

Reviews (1): Last reviewed commit: "Allow webpack-cli v7 in peer dependencie..." | Re-trigger Greptile

Comment thread package.json Outdated
Comment thread package.json Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@package.json`:
- Line 121: The lib/install package.json is missing the same webpack-cli version
range as the main package; update the webpack-cli entry in that package.json
(the "webpack-cli" dependency/peerDependencies line) to include "^7.0.0"
alongside the existing ranges (i.e., "^4.9.2 || ^5.0.0 || ^6.0.0 || ^7.0.0") so
the version constraints match the main package.json; verify the change by
checking the "webpack-cli" key in the package.json for consistency.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 08937aaf-f166-4c08-92e7-337b0d041190

📥 Commits

Reviewing files that changed from the base of the PR and between fc0f9a2 and 141b207.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • docs/peer-dependencies.md
  • package.json

Comment thread package.json
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Mar 24, 2026

Review

The core change is correct. Two gaps worth fixing before merge:

1. lib/install/package.json not updated (important)

Line 12 still reads webpack-cli: ^4.9.2 || ^5.0.0 || ^6.0.0 - missing ^7.0.0. This is the template used by the install generator, so new projects will not get v7 support. Should be updated to include || ^7.0.0.

2. lib/shakapacker/doctor.rb stale version string (minor)

Line 277 reads webpack-cli => ^4.9.2 || ^5.0.0. This appears in the missing dependency warning and is already missing v6 and now v7. Does not affect validation logic but is misleading. Worth updating to match the full supported range.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 141b20774d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread package.json
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Comment thread package.json
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Mar 26, 2026

Two gaps worth fixing before merge. (1) lib/install/package.json line 12 still reads webpack-cli ^4.9.2 || ^5.0.0 || ^6.0.0 - this is the template used by rails shakapacker:install so new projects will not get v7. (2) lib/shakapacker/doctor.rb line 277 has the stale string webpack-cli => ^4.9.2 || ^5.0.0 in the missing-dependency warning shown to users - it already missed v6 and now misses v7. Worth noting: devDependencies is still ^6.0.0 so CI is not exercising v7 yet.

@justin808
Copy link
Copy Markdown
Member Author

Addressed the follow-up compatibility items in this PR as well:

  • Updated installer metadata (lib/install/package.json) to include webpack-cli v7.
  • Raised webpack peer minimum to ^5.101.0 and webpack-dev-server to ^5.2.2 in package.json, installer metadata, and peer dependency docs.
  • Updated doctor guidance (lib/shakapacker/doctor.rb) so reported essential webpack ranges match current support (webpack ^5.101.0, webpack-cli ^4 || ^5 || ^6 || ^7).
  • Updated development/test dependency coverage by moving root devDependency to webpack-cli ^7.0.0 (with webpack 5.101.3) and moving the dummy app to webpack-cli ^7.0.0.
  • Synced lockfiles (yarn.lock and spec/dummy/yarn.lock).

This should close out the remaining compatibility concerns raised in review.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0a1d2b48d4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread spec/dummy/package.json
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
package.json (1)

122-122: Add webpack-dev-server version validation to doctor.rb.

Dropping webpack-dev-server v4 support is a breaking change. lib/shakapacker/doctor.rb validates webpack and webpack-cli versions but does not validate webpack-dev-server. Users still on v4 will receive npm/yarn peer dependency warnings but will silently pass shakapacker:doctor, potentially leading to runtime issues. Consider adding webpack-dev-server to the validation in check_webpack_peer_deps.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` at line 122, The doctor.rb check_webpack_peer_deps currently
validates webpack and webpack-cli but omits webpack-dev-server; update
lib/shakapacker/doctor.rb inside the check_webpack_peer_deps method to also
detect and validate the installed webpack-dev-server version (e.g., ensure it is
^5.x and treat ^4.x as unsupported), surface a clear error/warning via the same
reporting path used for webpack and webpack-cli (including the actual installed
version and recommended range), and add/update any related tests to cover a v4
installation case so users running v4 no longer pass shakapacker:doctor
silently.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@package.json`:
- Line 122: The doctor.rb check_webpack_peer_deps currently validates webpack
and webpack-cli but omits webpack-dev-server; update lib/shakapacker/doctor.rb
inside the check_webpack_peer_deps method to also detect and validate the
installed webpack-dev-server version (e.g., ensure it is ^5.x and treat ^4.x as
unsupported), surface a clear error/warning via the same reporting path used for
webpack and webpack-cli (including the actual installed version and recommended
range), and add/update any related tests to cover a v4 installation case so
users running v4 no longer pass shakapacker:doctor silently.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8e52bcab-8bef-464d-985a-66b6473d69b3

📥 Commits

Reviewing files that changed from the base of the PR and between 56e2084 and 0a1d2b4.

⛔ Files ignored due to path filters (3)
  • spec/dummy/package-lock.json is excluded by !**/package-lock.json
  • spec/dummy/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (9)
  • CHANGELOG.md
  • README.md
  • docs/optional-peer-dependencies.md
  • docs/peer-dependencies.md
  • docs/v9_upgrade.md
  • lib/install/package.json
  • lib/shakapacker/doctor.rb
  • package.json
  • spec/dummy/package.json
✅ Files skipped from review due to trivial changes (7)
  • docs/v9_upgrade.md
  • spec/dummy/package.json
  • README.md
  • docs/optional-peer-dependencies.md
  • lib/shakapacker/doctor.rb
  • CHANGELOG.md
  • lib/install/package.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/peer-dependencies.md

@justin808 justin808 force-pushed the jg/1020-webpack-cli-v7 branch from 0a1d2b4 to f4dc463 Compare March 29, 2026 04:05
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread docs/v9_upgrade.md Outdated
Comment thread CHANGELOG.md Outdated
Comment thread test/package/bundlerUtils.rspack.test.js
Comment thread .github/workflows/trigger-docs-site.yml
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f4dc463144

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread spec/dummy/package.json
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Mar 29, 2026

Review summary posted as inline comments. See discussion threads on CHANGELOG.md, README.md, docs/v9_upgrade.md, test/package/bundlerUtils.rspack.test.js, and .github/workflows/trigger-docs-site.yml for specifics.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Mar 29, 2026

Review: Allow webpack-cli v7 in peer dependencies

The core change is straightforward and well-executed. A few issues worth addressing:

Breaking change: webpack-dev-server v4 dropped without documentation

The range changed from ^4.15.2 || ^5.2.2 to just ^5.2.2, silently dropping v4 support. This should be called out in the changelog — users on webpack-dev-server v4 will get peer dependency warnings that are not currently explained.

Node.js version implication not documented

webpack-cli v7 requires Node >= 20.9.0 (its commander v14 dependency enforces this). The CI matrix already tests only Node 20.x and 22.x, so CI is fine, but consumers on Node 18 LTS would be broken by upgrading to webpack-cli v7. This minimum Node version requirement is not mentioned in the changelog, docs, or peer dependency documentation.

README and upgrade docs still show stale version examples

README.md (lines ~259-260 and ~277-278) and docs/v9_upgrade.md (lines ~341-342) still show webpack-cli ^5.0.0 and webpack-dev-server ^5.0.0 in their example snippets, inconsistent with the updated peer dependency ranges.

--ignoreDeprecations 6.0 suppresses warnings rather than fixing them

The TypeScript flag added to the CI type-check job silences TypeScript 6.0 deprecation warnings instead of resolving them. This is fine as a short-term workaround (--moduleResolution node is deprecated in favour of bundler), but worth a follow-up issue to migrate the .d.ts type-check to a supported resolution mode.

Comment thread .github/workflows/node.yml Outdated
Comment thread docs/v9_upgrade.md Outdated
Comment thread package.json
Comment thread spec/dummy/package-lock.json
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/node.yml:
- Around line 143-145: Replace the suppression of the TypeScript deprecation
warning (--ignoreDeprecations 6.0) with a real fix: update tsconfig.json's
"moduleResolution" from the deprecated "node" (which maps to node10) to a
current option such as "node16" or "nodenext" and remove the
--ignoreDeprecations flag in the workflow; if node10 compatibility is
intentional, leave the workflow but add a clear inline comment in tsconfig.json
explaining why "node10" compatibility is required and when you expect to revisit
it before TypeScript 7.0.

In `@package.json`:
- Line 122: The config currently advertises "webpack-dev-server": "^5.2.2" but
package/webpackDevServerConfig.ts still uses the removed hooks
onBeforeSetupMiddleware and onAfterSetupMiddleware; remove those keys or migrate
them into the v5 setupMiddlewares hook by adapting their handlers to receive
(middlewares, devServer) and then insert the former "before" middleware with
middlewares.unshift(...) and the former "after" middleware with
middlewares.push(...). Update or remove the onBeforeSetupMiddleware and
onAfterSetupMiddleware exports/usages so only setupMiddlewares is present and
wired to the existing middleware functions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c2cf3c7b-ef2b-44a4-9da9-f01fc9dc463b

📥 Commits

Reviewing files that changed from the base of the PR and between 0a1d2b4 and 4b6ce9e.

⛔ Files ignored due to path filters (3)
  • spec/dummy/package-lock.json is excluded by !**/package-lock.json
  • spec/dummy/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (13)
  • .github/workflows/dummy.yml
  • .github/workflows/node.yml
  • .github/workflows/trigger-docs-site.yml
  • CHANGELOG.md
  • README.md
  • docs/optional-peer-dependencies.md
  • docs/peer-dependencies.md
  • docs/v9_upgrade.md
  • lib/install/package.json
  • lib/shakapacker/doctor.rb
  • package.json
  • spec/dummy/package.json
  • test/package/bundlerUtils.rspack.test.js
💤 Files with no reviewable changes (1)
  • .github/workflows/dummy.yml
✅ Files skipped from review due to trivial changes (7)
  • .github/workflows/trigger-docs-site.yml
  • docs/v9_upgrade.md
  • README.md
  • CHANGELOG.md
  • docs/optional-peer-dependencies.md
  • test/package/bundlerUtils.rspack.test.js
  • docs/peer-dependencies.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • spec/dummy/package.json
  • lib/shakapacker/doctor.rb
  • lib/install/package.json

Comment thread .github/workflows/node.yml
Comment thread package.json
Comment thread .github/workflows/node.yml Outdated
Comment thread lib/install/template.rb
Comment thread package/webpackDevServerConfig.ts
Comment thread spec/dummy/package.json
Comment thread README.md
…plicitly

- README and v9_upgrade.md now show webpack-cli ^6.0.0 in example
  snippets (matching the installer default for Node 20.0–20.8), with a
  note that v7 is available on Node >= 20.9.0.
- webpackDevServerConfig.ts now explicitly deletes deprecated
  on_before_setup_middleware / on_after_setup_middleware keys after
  warning, rather than relying on implicit filtering downstream.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Mar 31, 2026

Code Review

Thanks for the PR. The implementation is generally solid. A few issues worth addressing before merge:

Documentation inconsistency — webpack-cli v7 shown without Node caveat

docs/optional-peer-dependencies.md shows webpack-cli ^7.0.0 in its Webpack+Babel and Webpack+SWC examples with no Node.js version caveat. This contradicts the README (which recommends ^6.0.0 and notes v7 requires Node >= 20.9.0) and the installer (which defaults to v6). Users on Node 20.0-20.8 following those docs will hit install failures with no guidance. The examples should either use ^6.0.0 or include the same Node caveat as the README.

CI node version vs. declared engine floor

dummy.yml pins node-version 20 but spec/dummy/package.json now declares node >=20.9.0. In practice GitHub Actions resolves 20 to the latest 20.x so CI passes today. But pinning to at least 20.9 would make the constraint explicit and avoid surprises if the runner image ever changes.

Installer always selects v6 regardless of actual Node version

The template.rb logic pattern-matches on the constraint string and always picks v6, even when the user is on Node >=20.9.0. This is intentionally conservative, but users on modern Node who want v7 must know to manually upgrade. The installer output or upgrade docs should note that users on Node >=20.9.0 can pin webpack-cli ^7.0.0 themselves.

Comment thread docs/optional-peer-dependencies.md Outdated
"webpack": "^5.76.0",
"webpack-cli": "^5.0.0",
"webpack": "^5.101.0",
"webpack-cli": "^7.0.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example uses ^7.0.0 directly, but webpack-cli v7 requires Node.js >= 20.9.0. Users on Node 20.0–20.8 who copy this snippet will get an install error with no indication of why.

The README uses ^6.0.0 here with a separate note about v7. These two docs should be consistent — either use ^6.0.0 in this example, or add a Node version caveat:

Suggested change
"webpack-cli": "^7.0.0",
"webpack-cli": "^6.0.0",

(Or keep ^7.0.0 but add a note above the snippet: > **Note:** webpack-cli v7 requires Node.js >= 20.9.0. Use ^6.0.0 if you are on an older Node 20 release.)

Comment thread docs/optional-peer-dependencies.md Outdated
"webpack": "^5.76.0",
"webpack-cli": "^5.0.0",
"webpack": "^5.101.0",
"webpack-cli": "^7.0.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as the Webpack+Babel example above — ^7.0.0 is shown without the Node >= 20.9.0 caveat.

Suggested change
"webpack-cli": "^7.0.0",
"webpack-cli": "^6.0.0",

Comment thread lib/install/template.rb
if package == "webpack-cli" && constraints.length > 1
# Keep installer defaults compatible with Node.js >= 20.0.0.
# webpack-cli v7 requires Node >= 20.9.0, so default to the latest v6 range.
selected_version = constraints.find { |constraint| constraint.start_with?("^6.") } || selected_version
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This always installs v6 regardless of the user's actual Node.js version. On Node >= 20.9.0 (or Node 21/22), webpack-cli v7 would work fine but users still get v6.

This is a safe, conservative default, but it can surprise users who read the peer dependencies docs and expect v7. Consider adding a say note after installation, e.g.:

say "Note: webpack-cli ^6.0.0 was installed for Node.js compatibility. If your Node version is >= 20.9.0, you can upgrade to webpack-cli ^7.0.0 manually."

Or alternatively, inspect the Node version at install time to decide:

node_major, node_minor = `node --version`.strip.delete_prefix("v").split(".").first(2).map(&:to_i)
selected_version = (node_major > 20 || (node_major == 20 && node_minor >= 9)) ? constraints.last : constraints.find { |c| c.start_with?("^6.") } || selected_version

Comment thread lib/shakapacker/doctor.rb
essential_webpack = {
"webpack" => "^5.76.0",
"webpack-cli" => "^4.9.2 || ^5.0.0"
"webpack" => "^5.101.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only checks that the package is present, not that it satisfies the new version floor (^5.101.0). This was existing behavior, but now that the minimum has been bumped, a user on webpack 5.76–5.100 would pass the doctor check and see confusing build errors later.

Consider checking the installed version against the constraint, similar to what other doctor checks do (if any), or at least document in a comment that this is a presence-only check.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 41944ac7d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread package.json
"webpack": "5.101.3",
"webpack-assets-manifest": "^5.0.6",
"webpack-cli": "^6.0.0",
"webpack-cli": "^7.0.0",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Raise repo Node floor when upgrading webpack-cli to v7

Updating the repository dev dependency to webpack-cli@^7.0.0 raises the tooling requirement to Node >=20.9.0, but the project still declares engines.node as >=20. This creates a setup trap for contributors on Node 20.0–20.8: they satisfy the declared engine yet encounter engine incompatibility during dependency install (especially with the repo’s default Yarn workflow), which blocks local development and CI parity.

Useful? React with 👍 / 👎.

- docs/optional-peer-dependencies.md: use ^6.0.0 in examples (matching
  README) and add Node >= 20.9.0 caveat for v7
- .github/workflows/dummy.yml: pin node-version to 20.9 to match
  spec/dummy/package.json engine floor
- lib/install/template.rb: print info message when defaulting to v6,
  telling users on Node >= 20.9.0 they can upgrade to v7

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@justin808
Copy link
Copy Markdown
Member Author

All three items addressed in e899119:

  1. Docs inconsistency — Changed optional-peer-dependencies.md examples to use ^6.0.0 (matching README) and added a Node >= 20.9.0 caveat note for v7.

  2. CI node version — Pinned dummy.yml node-version from "20" to "20.9" to match spec/dummy/package.json's >=20.9.0 engine floor.

  3. Installer hint — The installer now prints an info message when it selects webpack-cli v6, telling users on Node >= 20.9.0 they can manually upgrade to v7.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Mar 31, 2026

Code Review - PR 1021

The core addition (expanding webpack-cli peer dep to include ^7.0.0) is clean, the deprecation-warning helper is well-structured, and the new Jest tests are a good addition. A few issues worth addressing:

  1. doctor.rb does not warn about dropped webpack-dev-server v4 support

The PR drops ^4.15.2 from the webpack-dev-server peer range (a breaking change), but check_webpack_peer_deps in doctor.rb never checks which version of webpack-dev-server is installed. A user who still has v4 after upgrading will get confusing runtime errors with no doctor guidance. Consider adding webpack-dev-server => ^5.2.2 to the essential_webpack hash, or at minimum a version-range check that warns when v4 is detected.

  1. Hardcoded ^6. string in lib/install/template.rb

The fallback logic uses constraint.start_with?('^6.'). This is tightly coupled to the current constraint format - if the string ever has a different prefix style, the find silently falls through to selected_version (v7), which is the opposite of the intended safe default. Using the full exact string '^6.0.0' would be more precise, and a comment explaining the fallback behaviour would help future maintainers.

  1. Scope of breaking changes vs. version policy

This PR bundles three breaking changes: minimum webpack bumped from ^5.76.0 to ^5.101.0, webpack-dev-server v4 dropped, and installer defaults changed. These are documented in CHANGELOG.md (good), but worth confirming whether the project semver policy requires a new major version, or whether they roll into the current minor. The PR title only mentions the webpack-cli v7 addition, which understates the impact.

  1. spec/dummy/package.json engine requirement is overly specific

Bumping engines.node from >=18.0.0 to >=20.9.0 prevents contributors on Node 20.0-20.8 from running dummy integration tests even though webpack-cli v6 (the new installer default) works fine on those versions. The installer v6 fallback exists precisely to support broad Node 20.x compatibility - this constraint works against that goal. Consider >=20.0.0 instead.

Comment thread lib/install/template.rb
if package == "webpack-cli" && constraints.length > 1
# Keep installer defaults compatible with Node.js >= 20.0.0.
# webpack-cli v7 requires Node >= 20.9.0, so default to the latest v6 range.
selected_version = constraints.find { |constraint| constraint.start_with?("^6.") } || selected_version
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The start_with?("^6.") match is fragile — any variation in the constraint format (e.g. extra space, different prefix) causes the find to return nil and silently fall through to selected_version (v7), which is the opposite of the intended safe default.

Prefer an exact match on the known constraint string:

Suggested change
selected_version = constraints.find { |constraint| constraint.start_with?("^6.") } || selected_version
selected_version = constraints.find { |constraint| constraint == "^6.0.0" } || selected_version

Also worth adding a comment explaining why v6 is preferred over the last constraint, so future maintainers don't remove this when adding v8 support.

Comment thread lib/shakapacker/doctor.rb
"webpack-cli" => "^4.9.2 || ^5.0.0"
"webpack" => "^5.101.0",
"webpack-cli" => "^4.9.2 || ^5.0.0 || ^6.0.0 || ^7.0.0"
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR drops webpack-dev-server v4 support (a breaking change), but webpack-dev-server is not included in the essential_webpack check. A user who still has v4 installed after upgrading will see cryptic runtime errors rather than a clear doctor warning.

Consider adding it here:

Suggested change
}
"webpack-cli" => "^4.9.2 || ^5.0.0 || ^6.0.0 || ^7.0.0",
"webpack-dev-server" => "^5.2.2"

Comment thread spec/dummy/package.json
{
"engines": {
"node": ">=18.0.0",
"node": ">=20.9.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumping to >=20.9.0 is correct for webpack-cli v7, but the installer defaults to webpack-cli v6 specifically to support all of Node 20.x. This constraint prevents contributors on Node 20.0–20.8 from running the dummy integration tests even with the v6 default path.

Consider >=20.0.0 to stay consistent with the installer's compatibility intent:

Suggested change
"node": ">=20.9.0",
"node": ">=20.0.0",

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Mar 31, 2026

Code Review: Allow webpack-cli v7 in peer dependencies

The overall direction is good. The CHANGELOG correctly marks the WDS v4 drop and webpack minimum bump as breaking. A few things worth noting:

1. Hardcoded ^6. string match in installer (lib/install/template.rb:271)

The constraints.find { |c| c.start_with?("^6.") } check is brittle. If a future PR adds ^8.0.0 to the range, this logic will still silently default to v6. The rationale (prefer v6 for Node 20.0-20.8 compat) won't stay valid as the ecosystem ages. At minimum, a comment here flagging that this sentinel needs manual review when peer dep ranges change would prevent a silent regression.

2. Test assertions in webpackDevServerConfig.test.js check keys that would never have been set (lines 26-27)

expect(config.onBeforeSetupMiddleware).toBeUndefined() and expect(config.onAfterSetupMiddleware).toBeUndefined() pass trivially regardless of this PR — those camelCase keys were already absent from webpackDevServerMappedKeys before this change. The assertions don't exercise the new behavior (warning and deletion of deprecated snake_case keys). More meaningful would be asserting config.on_before_setup_middleware and config.on_after_setup_middleware are undefined, since those are the actual keys that now get deleted. The warning assertions are good and should stay.

3. spec/dummy/package.json engines raised to >=20.9.0

The dummy app now requires Node >= 20.9.0 (up from >= 18.0.0) because it pins webpack-cli v7. The main docs recommend v6 by default (Node 20.0+), so there is now a split between what the docs say and what the dummy app requires. Users copying the dummy app as a starting point may be confused.

4. node-version: "20.x" in CI vs the new engine floor

With spec/dummy/package.json requiring >=20.9.0, using "20.x" in the workflow resolves to the latest 20.x today, so it works. But using "20.9" or ">=20.9" would express the intent more precisely and guard against any runner that might resolve to an older 20.x patch.

Comment thread lib/install/template.rb
if package == "webpack-cli" && constraints.length > 1
# Keep installer defaults compatible with Node.js >= 20.0.0.
# webpack-cli v7 requires Node >= 20.9.0, so default to the latest v6 range.
selected_version = constraints.find { |constraint| constraint.start_with?("^6.") } || selected_version
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This string match on "^6." is fragile. If the peer dep range later gains ^8.0.0, this check will still silently default to v6 rather than the intended "latest safe" version. The fallback to selected_version (which is constraints.last) means the intent is already "use last unless we explicitly override it to v6" — but that override logic won't age well.

Consider extracting a constant or adding a comment that this sentinel must be updated manually when the peer dep range changes:

Suggested change
selected_version = constraints.find { |constraint| constraint.start_with?("^6.") } || selected_version
# webpack-cli v7 requires Node >= 20.9.0; default to v6 for broader compat.
# NOTE: Update this sentinel if the peer dep range gains a new major version
# that should become the new safe default (e.g. change "^6." to "^7.").
selected_version = constraints.find { |constraint| constraint.start_with?("^6.") } || selected_version

Comment on lines +26 to +27
expect(config.onBeforeSetupMiddleware).toBeUndefined()
expect(config.onAfterSetupMiddleware).toBeUndefined()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These camelCase assertions pass trivially regardless of this PR. onBeforeSetupMiddleware / onAfterSetupMiddleware were already removed from webpackDevServerMappedKeys, so they would never appear in the output config under any circumstances.

The new behavior being tested is that the snake_case keys are deleted from devServerYamlConfig before the generic mapping loop runs (preventing them from potentially leaking through). Asserting the snake_case forms is more meaningful:

Suggested change
expect(config.onBeforeSetupMiddleware).toBeUndefined()
expect(config.onAfterSetupMiddleware).toBeUndefined()
expect(config.on_before_setup_middleware).toBeUndefined()
expect(config.on_after_setup_middleware).toBeUndefined()

Comment thread spec/dummy/package.json
{
"engines": {
"node": ">=18.0.0",
"node": ">=20.9.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now requires Node >= 20.9.0 because webpack-cli v7 is pinned here. The main project docs recommend webpack-cli v6 as the default (Node 20.0+), so the dummy app now has a stricter floor than what new users are guided toward. Callers who copy this file as a template may be caught off-guard. Consider adding a comment explaining the reason, or switching the dummy app to webpack-cli v6 to match the recommended default.

- uses: actions/setup-node@v4
with:
node-version: "20"
node-version: "20.x"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With spec/dummy/package.json now requiring node >= 20.9.0, using "20.x" works today (resolves to 20.19+), but "20.9" or "20.9.x" would make the intent explicit and guard against a future runner resolving to an older 20.x patch.

Suggested change
node-version: "20.x"
node-version: "20.9"

@justin808 justin808 merged commit 595dd21 into main Apr 2, 2026
65 checks passed
@justin808 justin808 deleted the jg/1020-webpack-cli-v7 branch April 2, 2026 00:29
justin808 added a commit that referenced this pull request Apr 2, 2026
…pass-1

* origin/main:
  Allow webpack-cli v7 in peer dependencies (#1021)

# Conflicts:
#	docs/peer-dependencies.md
ihabadham added a commit that referenced this pull request Apr 17, 2026
Documents both user-visible changes from this PR under Unreleased:
- Changed: shakapacker:install now defaults fresh Rspack installs to v2
  via the widened lib/install/package.json range.
- Fixed: @rspack/plugin-react-refresh peer range widened to accept v2,
  resolving the ERESOLVE conflict for users installing v2 of the plugin.

Follows the format and level of detail used for analogous prior entries
(PR #975 for the initial rspack v2 peer widening, PR #1021 for the
webpack-cli installer default change).
justin808 added a commit that referenced this pull request Apr 30, 2026
* origin/main: (22 commits)
  docs: add Dependabot configuration guide (#1094)
  Sync address-review prompt with upstream PR #16 (#1098)
  Supersede #910: entry shape test with lint unblock (#919)
  fix: align rspack v2 peer deps and installer defaults (#1091)
  docs: update README and guides for Shakapacker v10 (#1092)
  Release 10.0.0
  Update CHANGELOG.md for v10.0.0 (#1089)
  Release 10.0.0-rc.1
  Update CHANGELOG.md for v10.0.0-rc.1 (#1087)
  Supersede #961 by using pack-config-diff (#973)
  Add final summary output to rake release (#1041)
  Add bin/setup to install development deps (#1039)
  Release 10.0.0-rc.0
  Use npx release-it to avoid mise shim failures (#1040)
  Fix Nokogiri build failure on Ruby 3.4.6 (#1038)
  Update CHANGELOG.md for v10.0.0-rc.0 (#1037)
  Update rspack dev deps to 2.0.0-rc.0 (#1036)
  Fix stale and broken documentation across Shakapacker guides (#1023)
  Allow webpack-cli v7 in peer dependencies (#1021)
  refactor: simplify resolving js peer versions when installing (#1034)
  ...

# Conflicts:
#	package.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow webpack-cli > 7

1 participant