npm: Switch from legacy-peer-deps to strict-peer-deps - #81029
npm: Switch from legacy-peer-deps to strict-peer-deps#81029manzoorwanijk wants to merge 1 commit into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: 0 B Total Size: 7.78 MB |
f1cff85 to
c898255
Compare
|
Changed back to draft for now as it creates some lockfile diff like |
|
This is a good idea 👍 I recall looking at this in the past and similarly thinking we should drop it. |
What?
Replaces
legacy-peer-deps = truewithstrict-peer-deps = truein.npmrcand updates the lockfile.Why?
legacy-peer-depswas added in #53426 (August 2023) as part of the npm upgrade, to retain npm 6-style behavior where peer dependencies are ignored during resolution. The npm docs explicitly recommend against it:Switching to
strict-peer-depsgives us:peerDependenciescontract is actually enforced. Withlegacy-peer-deps, npm silently ignores peer requirements, so incompatible peer combinations can land unnoticed and only surface as runtime bugs. Withstrict-peer-deps, any conflicting peer range fails the install immediately, so incompatibilities are caught at dependency-update time instead.picomatchand@octokit/*copies), shrinkingpackage-lock.jsonby 654 lines.How?
.npmrc:legacy-peer-deps = true→strict-peer-deps = true.npm installto updatepackage-lock.json. The whole tree resolves cleanly under strict mode — noERESOLVEconflicts and no overrides needed, confirming our current dependency set already satisfies all peer ranges.Testing Instructions
node_modulesand runnpm ci(ornpm install) — the install must complete without peer-dependency errors and without modifyingpackage-lock.json.npm run buildand the CI checks — no behavioral changes expected, as no package versions change beyond the hoisting rearrangement.Testing Instructions for Keyboard
N/A — no UI changes.
Use of AI Tools
Drafted with assistance from Claude Code; the change and lockfile analysis were reviewed by the author.