Skip to content

feat(packages): sync package.json exports, add-only - #22

Merged
flipvh merged 1 commit into
mainfrom
feat/sync-package-exports
Sep 21, 2026
Merged

flipvh merged 1 commit into
mainfrom
feat/sync-package-exports

Conversation

@flipvh

@flipvh flipvh commented Sep 21, 2026

Copy link
Copy Markdown
Member

Why

packageJsonSync could not carry exports, so a subpath added upstream (e.g. a new ./config entry on a workspace package) never reached forks, and imports from synced code broke until someone added it by hand.

Revives the old unshipped feat/exports branch (ec62629, 2026-07-08) on top of current main, with guards it was missing.

What

  • exports is a valid packageJsonSync key (type + zod schema)
  • Add-only, like scripts: 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 ({ ".": …, "./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 through safeMergeRecord, which would have spread a string-form exports into characters and alphabetically re-sorted keys
  • Fork key order is kept; 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

Testing

  • Two new cases in tests/packages.test.ts: subpath add with preserved order and repointed ., and the non-subpath-map no-op
  • pnpm ts, pnpm lint, vitest run tests/packages.test.ts green locally (13 tests)

🤖 Generated with Claude Code

`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>
@flipvh
flipvh merged commit e59b8c5 into main Sep 21, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant