fix: resolve pnpm content-addressable store packages in vxrn patch#692
Open
lightstrike wants to merge 1 commit intoonejs:mainfrom
Open
fix: resolve pnpm content-addressable store packages in vxrn patch#692lightstrike wants to merge 1 commit intoonejs:mainfrom
lightstrike wants to merge 1 commit intoonejs:mainfrom
Conversation
applyDependencyPatches now globs .pnpm/<module>@*/node_modules to discover packages that aren't hoisted to node_modules/ or .pnpm/node_modules/. Adds real-path deduplication to prevent double-patching when symlinks and store entries resolve to the same files. Includes tests for store discovery, dedup, version constraints, and flat node_modules regression.
Contributor
Author
|
@natew Would appreciate your review on this when you get a chance. This fixes silent patch failures in pnpm monorepos — we hit it in our starter repo and had to work around it with a manual patchedDependencies entry. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
applyDependencyPatchesnow globs.pnpm/<module>@*/node_modulesto find packages that only exist in pnpm's content-addressable store (not hoisted tonode_modules/or.pnpm/node_modules/). This fixes silent patch failures in pnpm monorepos with strict hoisting, peer dep conflicts, orhoist=false.node_modules/<module>symlinks and.pnpm/<store>/node_modules/<module>directories point to the same physical files. Critical for non-idempotent transforms like['jsx']and['flow'].existsSync(.pnpm), so npm/yarn/bun users see no change.Context
We hit this in a pnpm monorepo (lightstrikelabs/lightstrike-starter#35) where the built-in
@react-navigation/coreexports patch was silently skipped because the package wasn't hoisted — it only lived at.pnpm/@react-navigation+core@7.16.1_<hash>/node_modules/@react-navigation/core/. The workaround was a manualpatchedDependenciesentry inpackage.json. This PR eliminates that workaround by teaching vxrn to discover packages inside pnpm's store.Changes
packages/vxrn/src/utils/patches.ts:moduleToPnpmStorePattern()helper (@scope/name→@scope+name)nodeModulesDirsconstruction to glob pnpm store entries per patch modulepatchedRealPathsSet withrealpathSyncdedup before patch applicationpackages/vxrn/src/utils/patches.test.ts(new):moduleToPnpmStorePatternunit tests (scoped + unscoped)node_modulesregression (non-pnpm)Test plan
npx vitest run src/utils/patches.test.ts)tsc --noEmit)patchedDependenciesworkaround, runone dev, confirm@react-navigation/coreexports patch is appliedone-basic) still work withone patch