fix(webpack-cli): declare json5/js-yaml/toml as optional peerDependencies#4787
Conversation
…cies The CLI parses `.json5`, `.yaml`/`.yml` and `.toml` configs by loading the respective parser (`json5`, `js-yaml`, `toml`) from the user's project, but these packages were not declared anywhere in webpack-cli's manifest. Under strict Yarn PnP (`pnpFallbackMode: none`) an undeclared package is unsound to resolve, so the parser cannot be reached and there is no signal telling users which package to install. Declare them as optional peerDependencies (mirroring webpack-dev-server and webpack-bundle-analyzer) so package managers surface the requirement and the parsers resolve correctly under PnP when the user installs them. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E8q7bNUb92fDzxLRdLY6L5
|
| Name | Type |
|---|---|
| webpack-cli | Minor |
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
One or more co-authors of this pull request were not found. You must specify co-authors in commit message trailer via: Supported
Alternatively, if the co-author should not be included, remove the Please update your commit message(s) by doing |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4787 +/- ##
=======================================
Coverage 93.43% 93.43%
=======================================
Files 14 14
Lines 5420 5420
Branches 788 788
=======================================
Hits 5064 5064
Misses 354 354
Partials 2 2 Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
What kind of change does this PR introduce?
Bugfix / dependency-metadata fix for the new non-JS config support.
Did you add tests for your changes?
No new automated test (this is a manifest/metadata change). It was verified manually with a real Yarn Berry PnP reproduction — see below.
Summary
webpack-cli now parses
.json5,.yaml/.ymland.tomlconfigs by loading the respective parser (json5,js-yaml,toml) from the user's project, and asks users to install it on demand. However, those packages were not declared anywhere inpackages/webpack-cli/package.json— not independencies,peerDependencies, orpeerDependenciesMeta.Under Yarn PnP an undeclared package is unsound to resolve, so the parser cannot be reached and there is no package-manager signal telling users which package to install.
This PR declares the three parsers as optional
peerDependencies(mirroring the existingwebpack-dev-server/webpack-bundle-analyzerpattern):Verification
Reproduced webpack-cli's actual parser-resolution mechanism under real Yarn Berry (4.17) PnP:
pnpFallbackMode: none)tried to access json5, but it isn't declared in its dependencies; this makes the require call ambiguous and unsoundNotes:
fallback-except-top-level) can mask the issue by silently falling back to a top-level dependency — the classic fragile phantom-dependency behavior. Strict setups (and configs that live in a workspace not declaring the parser) break.The version ranges reflect the latest published versions (json5
2.2.3, js-yaml5.1.0, toml4.1.1) and the used APIs (.parse/.load), which are stable across those majors. Happy to tighten/loosen them per maintainer preference.🤖 Generated with Claude Code
https://claude.ai/code/session_01E8q7bNUb92fDzxLRdLY6L5
Generated by Claude Code