feat(packages): sync package.json exports, add-only - #22
Merged
Merged
Conversation
`packageJsonSync` accepts `exports`. The fork gains subpaths upstream adds, keeps the ones it defines itself, and a subpath it has repointed stays repointed. Only merges when both sides are subpath maps: a string or a conditions object can't take extra subpaths, and condition order is significant, so those are left alone. The fork's key order is kept and new subpaths are appended, with their conditions in upstream's order. README lists `exports` (and the already-supported `pnpm`) and states the add-only rule for `scripts` and `exports`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Why
packageJsonSynccould not carryexports, so a subpath added upstream (e.g. a new./configentry on a workspace package) never reached forks, and imports from synced code broke until someone added it by hand.Revives the old unshipped
feat/exportsbranch (ec62629, 2026-07-08) on top of current main, with guards it was missing.What
exportsis a validpackageJsonSynckey (type + zod schema)scripts: the fork gains subpaths upstream adds, keeps the ones it defines itself, and a subpath it has repointed stays repointed{ ".": …, "./config": … }). A string or a conditions object can't take extra subpaths, and condition order is significant, so those are left untouched. The original branch ran these throughsafeMergeRecord, which would have spread a string-formexportsinto characters and alphabetically re-sorted keysexports(and the already-supportedpnpm) and states the add-only ruleTesting
tests/packages.test.ts: subpath add with preserved order and repointed., and the non-subpath-map no-oppnpm ts,pnpm lint,vitest run tests/packages.test.tsgreen locally (13 tests)🤖 Generated with Claude Code