Skip to content

fix: stop package-lock.json drift - #2451

Merged
mariechatfield merged 2 commits into
mainfrom
marie/fix-lockfile-optional-peer-drift
Jul 22, 2026
Merged

fix: stop package-lock.json drift#2451
mariechatfield merged 2 commits into
mainfrom
marie/fix-lockfile-optional-peer-drift

Conversation

@mariechatfield

@mariechatfield mariechatfield commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

package-lock.json has been flapping on nearly every dependabot merge, including two prior one-off fixes (#2393, and an earlier "chore: fix package-lock.json sync issue") that didn't hold — see #2446 for the latest recurrence.

Root cause: @conventional-changelog/git-client (transitive dep of @commitlint/cli via @commitlint/read) declares conventional-commits-parser and conventional-commits-filter as optional peer dependencies with no other hard consumer anywhere in the tree:

"peerDependencies": {
  "conventional-commits-filter": "^5.0.0",
  "conventional-commits-parser": "^6.4.0"
},
"peerDependenciesMeta": {
  "conventional-commits-filter": { "optional": true },
  "conventional-commits-parser": { "optional": true }
}

npm's resolution of an unclaimed optional peer like this is order-sensitive rather than input-sensitive — the same package.json can resolve either way depending on install state. git log -S on the relevant lockfile block shows it flipping in and out across ~15 unrelated commits (dependabot and human PRs alike), unrelated to whatever each commit was actually about.

Fix

Add both packages to the existing overrides block, forcing a single deterministic resolution instead of leaving it to the optional-peer coin flip:

"overrides": {
  "conventional-commits-parser": "^7.1.0",
  "conventional-commits-filter": "^5.0.0"
}

This also collapses duplicated nested copies (@commitlint/parse/node_modules/..., @commitlint/types/node_modules/...) into one hoisted resolution.

Test plan

  • rm -rf node_modules && npm install — verified byte-identical package-lock.json across repeated clean installs (no more drift)
  • npm run build, npm run lint:staged ran clean via lint-staged pre-commit hook

🤖 Generated with Claude Code

…n drift

@conventional-changelog/git-client (transitive dep of @commitlint/cli via
@commitlint/read) declares conventional-commits-parser and
conventional-commits-filter as optional peer dependencies with no other
hard consumer in the tree. npm's resolution of unclaimed optional peers is
order-sensitive, so nearly every commit touching package-lock.json flipped
these entries in or out regardless of what the commit actually changed
(confirmed via git log -S across ~15 unrelated commits, including two prior
one-off "sync package-lock.json" fixes that didn't hold).

Overriding both to fixed versions forces a single deterministic resolution
instead of an optional-peer coin flip. Verified stable across a full clean
reinstall (rm -rf node_modules && npm install) with zero further lockfile
diff.
@mariechatfield mariechatfield changed the title fix: pin conventional-commits-parser/-filter to stop package-lock.json drift fix: stop package-lock.json drift Jul 22, 2026
@mariechatfield
mariechatfield marked this pull request as ready for review July 22, 2026 16:15
@mariechatfield
mariechatfield requested a review from a team as a code owner July 22, 2026 16:15
@mariechatfield
mariechatfield enabled auto-merge July 22, 2026 16:20
@mariechatfield
mariechatfield added this pull request to the merge queue Jul 22, 2026
Merged via the queue into main with commit b91cb23 Jul 22, 2026
39 checks passed
@mariechatfield
mariechatfield deleted the marie/fix-lockfile-optional-peer-drift branch July 22, 2026 16:35
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.

2 participants