fix: use npm ci on Vercel so patch-package runs against pristine node_modules#62
Conversation
…_modules Vercel restores node_modules from the build cache before running the install command. With `npm install`, the cached files are kept in place and patch-package then runs against a pre-patched starlight-llms-txt, causing the postinstall step to fail with 'Failed to apply patch for package starlight-llms-txt' on every deploy after #51. `npm ci` deletes node_modules before installing, so patch-package always runs against the pristine npm tarball. Co-Authored-By: Oz <oz-agent@warp.dev>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
I'm starting a first review of this pull request. You can view the conversation on Warp. I completed the review and no human review was requested for this pull request. Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR changes Vercel's install command from npm install to npm ci, making production installs lockfile-strict and ensuring patch-package runs against a freshly installed node_modules tree.
Concerns
- No blocking correctness or security concerns found in the annotated diff.
Verdict
Found: 0 critical, 0 important, 0 suggestions
Approve
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
Summary
Switch the Vercel
installCommandfromnpm installtonpm cisopatch-packagealways runs against a pristinenode_modules. Production deploys have been failing for ~40 minutes (all Production builds since7d6185a); this unblocks them.Root cause
Every Production deploy after
7d6185a(#51 —Improve llms.txt aggregate coverage) fails at thenpm installpostinstall step with:Vercel restores
node_modulesfrom the previous build cache before runningnpm install(visible in the build log:Restored build cache from previous deployment ...). The previous successful Production deploy (202eeb3) shipped with the olderpatches/starlight-llms-txt+0.8.1.patch, which modifiedllms-custom.txt.tsandllms-full.txt.tsto forwardexcludeto all generated llms outputs.#51 regenerated that patch so it also patches
generator.tswith aCanonical page:line via a newgetDocUrlhelper. The regenerated patch is correct against the pristine upstream0.8.1tarball (verified by downloading the tarball directly), but the cachednode_modulesalready had the old patch's edits tollms-custom.txt.tsandllms-full.txt.ts. Because the lockfile is satisfied,npm installis a no-op for those files — sopatch-packageruns against pre-patched sources andgit applyfails at the file level:generator.ts(the only genuinely new edit in #51) applies fine in isolation. The breakage is entirely on the two files whose hunks overlap the historical patch.Why
npm cinpm cideletesnode_modulesbefore installing (per npm docs), sopatch-packagealways sees the pristine npm tarball — exactly the state the patch was authored against.npm ciis also the standard install command for CI environments: deterministic, lockfile-strict, and won't mutate the lockfile out from under us.Trade-off:
npm cierrors ifpackage.jsonandpackage-lock.jsonever drift. That's a desirable property for CI and we're already in sync today (the localnpm cisucceeded).Why not just clear the Vercel build cache
Clearing it via the dashboard would unblock the next deploy, but the underlying fragility (
npm install+patch-packageagainst a cache that may or may not be pre-patched) would resurface the next time anyone edits the patch.npm cifixes the root cause once.Validation
rm -rf node_modules && npm cisucceeds locally;patch-packagereportsstarlight-llms-txt@0.8.1 ✔.npm run buildfinishes with 316 pages in ~92s.Co-Authored-By: Oz oz-agent@warp.dev