Repository navigation
fix(deps): make package-lock.json self-consistent - #2853
Conversation
Greptile SummaryThe lockfile now fully describes the dependency tree that npm ci already installs. It adds missing package URLs and hashes, and removes stale Capacitor and Cordova entries so npm no longer needs to rediscover the tree from the registry.
Confidence Score: 5/5The lockfile-only change appears safe to merge. The PR keeps all dependency versions unchanged. A clean install accepted the new URLs and hashes. Compatible hoisted packages and the current Cordova plugin records remain in the lockfile.
|
| Filename | Overview |
|---|---|
| package-lock.json | Adds resolved and integrity to 827 existing packages. It removes four stale paths without changing dependency versions. A clean install accepted the new hashes and left the lockfile unchanged. |
Sequence Diagram
sequenceDiagram
participant Dev as Developer or CI
participant NPM as npm ci
participant Lock as package-lock.json
participant Registry as npm registry
Dev->>NPM: Start clean install
NPM->>Lock: Read pinned package entries
Lock-->>NPM: Return versions, tarball URLs, and hashes
NPM->>Registry: Fetch package tarballs
Registry-->>NPM: Return tarballs
NPM->>NPM: Check each tarball hash
NPM->>NPM: Hoist matching Capacitor dependencies
NPM-->>Dev: Finish without metadata lookups
Reviews (1): Last reviewed commit: "fix(deps): make package-lock.json self-c..." | Re-trigger Greptile
|
I just merged
We should also make sure it runs against the un-merged android capacitor CI #2809, and for capacitor iOS #2854 |
e9584d9 to
fef98c4
Compare
ohnorobo
left a comment
There was a problem hiding this comment.
nicccce
I agree we should add some CI to keep this in check.
I'm also not opposed to just rming and starting fresh, including the move to lockfileVersion 3
|
Yes, maybe I might do that in a different PR. This one do not touch the dependency tree at all, removing the lock and changing the version could introduce more changes. It could also be the occasion to update some other dependencies like electron, koffi, |
|
I believe the capacitor pra broke it. The proper fix would be to revert the lock files to before the PRs, then call npm install. That way we preserve the original versions and minimize the change |
|
So presumably the issue is one of the capacitor changes here from May 5 to today: Those are also adding needed deps for capacitor, so we can't strictly revert them. It would be helpful to get the CI additions #2809 and #2854 merged so we can test the regenerated lockfile against those builds. |
|
The CI PRs are now merged |
The lockfile did not fully pin the dependency tree, so `npm ci` had to go back to the registry for package metadata on every install: - 827 entries lacked `resolved` and `integrity` (npm/cli#4263), so npm could neither locate nor verify their tarballs from the lock alone. - client/capacitor/node_modules/webpack-{cli,dev-server,merge} were stale copies (7.0.2 / 5.2.3 / 6.0.1) that do not satisfy the ranges declared in client/capacitor/package.json; npm re-resolved the workspace to the root copies and pruned them on every install. - src/cordova/plugin was a leftover entry from before the plugin moved to client/src/cordova/plugin. Fill in the missing fields with `npm-lockfile-fix -r` and drop the four stale entries. No versions change; the installed tree is the one npm already produced. Metadata requests made by `npm ci` from an empty cache (with --no-audit, npm 10.9 / Node 22) go from 830 to 0. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
fef98c4 to
86c299e
Compare
|
@ohnorobo rebased with latest commit from master. I've tried to start fresh but I had too many breaking changes, it should go in another PR. If it is ok for you we can merge. |
Problem
package-lock.jsondoes not fully pin the dependency tree. On everynpm ci, npm has to go back to the registry for package metadata to fill in what the lock leaves undetermined, and it re-resolves four version ranges at install time. A lockfile should make both unnecessary. In practice this means ~830 extra registry requests per install, tarballs that npm cannot verify against the lock for a quarter of the tree, and breakage for tooling that installs strictly from the lockfile (I hit it packaging the Linux client for nixpkgs).To measure it, count the non-tarball registry requests
npm cimakes from an empty cache:On
masterthis prints 830. With this PR it prints 0. (Measured with npm 10.9 on Node 22, the versions the repo declares.--no-auditmatters: the audit step fetches metadata for vulnerable packages independently of the lockfile.)There are three separate defects:
827 of 3549 entries have no
resolvedorintegrityfield. For examplenode_modules/webpack-cliis only{"version": "4.10.0", "dev": true, "license": "MIT", …}. This is npm install removes resolved and integrity properties from package-lock.json if installed from cache npm/cli#4263: entries written from a warm local cache lose those fields, and laternpm installruns never add them back. Each such entry costs a metadata request on every install, and npm has nothing in the lock to verify the tarball against.Stale nested entries under
client/capacitor.client/capacitor/package.jsondeclareswebpack-cli ^4.4.0,webpack-dev-server ^4.5.0andwebpack-merge ^5.8.0, but the lock still carriesclient/capacitor/node_modules/webpack-cli@7.0.2,webpack-dev-server@5.2.3andwebpack-merge@6.0.1, which do not satisfy those ranges. On everynpm ci, npm fetches the packuments, re-resolves the workspace to the root copies (4.10.0 / 4.15.2 / 5.10.0) and prunes the nested entries as extraneous. The 7.x/5.x/6.x versions are therefore never installed anywhere; the lock just claims they are. This is whatnpm ci --loglevel=sillylogs onmaster:A leftover
src/cordova/pluginentry from before the plugin moved toclient/src/cordova/plugin. The directory no longer exists and npm treats the entry as extraneous.Change
This PR only edits
package-lock.json. No versions change, and the installed tree is identical to whatnpm cialready produces today; the lock now records it instead of leaving npm to rediscover it.resolvedandintegrityfor the 827 entries withnpm-lockfile-fix(-rlimits it to entries withoutresolved, leaving the git dependencies alone).The diff is generated, so it is easier to reproduce than to read:
Verification
The affected entries only serve the Capacitor workspace, which no release build uses, so the Electron, Cordova and server-manager builds are unaffected.
Notes
rm package-lock.json && npm install), because regeneration re-resolves every floating range and moves to lockfileVersion 3, which is a much larger change to review.npm ciand fail if it is non-zero.🤖 Generated with Claude Code