Filter patchedDependencies in isolated pnpm-workspace.yaml#180
Conversation
When pnpm-workspace.yaml was copied verbatim into the isolate, its patchedDependencies field still referenced every workspace patch even when copyPatches had only copied the subset relevant to the target package. pnpm install then failed on missing patch files. The yaml is now read, the patchedDependencies field is rewritten to only contain entries actually copied (and removed entirely if none remain), and written back. Falls back to a verbatim copy when the yaml has no patchedDependencies or cannot be parsed.
There was a problem hiding this comment.
Pull request overview
Updates PNPM isolate output to avoid broken patchedDependencies references in pnpm-workspace.yaml when patch files are excluded from the isolate (fixing #178), keeping workspace config consistent with already-filtered lockfile/manifest behavior.
Changes:
- Add
writeIsolatePnpmWorkspaceto copypnpm-workspace.yamlwhile rewriting/removingpatchedDependenciesto match the patches actually copied. - Replace the direct
pnpm-workspace.yamlcopy insrc/isolate.tswith the new filtered writer. - Add Vitest coverage for the new workspace writer behavior and fallback paths.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/lib/patches/write-isolate-pnpm-workspace.ts | Implements filtered writing of pnpm-workspace.yaml based on copiedPatches, with fallback to verbatim copy. |
| src/lib/patches/write-isolate-pnpm-workspace.test.ts | Adds unit tests validating filtering, field removal, and verbatim-copy fallback behavior. |
| src/isolate.ts | Switches PNPM workspace config handling to use the new filtered writer. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
When every patchedDependencies entry in the source pnpm-workspace.yaml is also present in copiedPatches, copy the file verbatim instead of parsing and rewriting it. This preserves comments, key ordering, and trailing whitespace for the common case where all workspace patches apply to the target. The read-modify-write path still runs whenever any patch is excluded.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Do you think it is worth the "fallback to verbatim copy" if all the patches are included? This is my thought matrix: (Claude can confirm if these cases are met):
|
|
Yes, all five cases are covered exactly as you describe — confirmed against
Each path also has a dedicated unit test in |
|
Yep all good then, ship it 🚀 |
Fixes #178.
When a pnpm workspace declares
patchedDependenciesfor packages that aren't reachable from the target,copyPatchescorrectly skips those patch files but the workspace config was still copied verbatim. The resulting isolate referenced patch files that didn't exist on disk, sopnpm install(e.g. during a Firebase Functions deploy) failed.pnpm-workspace.yamlis now parsed when written into the isolate, and itspatchedDependenciesfield is rewritten to only contain the entries that were actually copied. The field is removed entirely when no patches apply. If the file has nopatchedDependenciesfield or fails to parse, it falls back to a verbatim copy as before. The lockfile and target manifest were already filtered, so this brings the workspace config in line.Scope: cli (patches)
Visibility: user-facing