Skip to content

fix: external cross package dependencies - #43

Merged
ChristoPy merged 2 commits into
mainfrom
perf/externalize-cross-package-deps
Jul 27, 2026
Merged

fix: external cross package dependencies#43
ChristoPy merged 2 commits into
mainfrom
perf/externalize-cross-package-deps

Conversation

@ChristoPy

Copy link
Copy Markdown
Contributor

Summary

stop inlining cross-package dependencies into published bundle + make

Related Issue

Closes (N/A)

Why

What problem does this solve?

What changed

Breaking changes

  • Yes
  • No

Checklist

  • Docs updated
  • CI passing
  • I followed the CONTRIBUTING guidelines
  • I added or updated tests (if applicable)

Additional context

Add any other context or screenshots here.

ChristoPy and others added 2 commits July 27, 2026 15:08
The root README promises "changelog individual" (individual changelog) per
package, but none existed. Backfilled CHANGELOG.md for all 13 packages
covering the two releases actually shipped so far: the v2 rewrite (major
version bumps) and the ESM-bundling patch fix. Earlier, undocumented
version history is intentionally left out rather than guessed at.

Also added "CHANGELOG.md" to each package's `files` array -- npm only
auto-includes README/LICENSE/package.json in a published tarball, so
without this the changelog would exist in the repo but never actually ship
in what `npm install` pulls down. Verified via `npm pack --dry-run`.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EqaJ2TCZoyMCFjK4WcKxBR
bun build inlines every reachable import by default, including workspace
dependencies. sdk, adapters, and the 5 framework packages were fully
inlining @abacatepay/rest, @abacatepay/types, @abacatepay/zod, and
@abacatepay/adapters into their own dist -- despite each already declaring
those as real `dependencies`. Framework packages ended up shipping ~480KB-
1MB each, almost entirely a duplicated copy of zod's runtime pulled in
transitively through adapters. elysia was worse (~1MB): it also inlined the
entire `elysia` framework itself, which is a peerDependency, not something
that should ever be bundled into a package meant to run inside a host app
that provides its own elysia instance.

Fix: mark each package's own @abacatepay/* (and, for elysia, the elysia
peer) dependencies as --external in its `bun build` invocation, so they
stay real `import` statements resolved via node_modules instead of being
duplicated into every consumer. No behavior change -- everything marked
external was already a declared dependency, so npm/bun already installs it
correctly for any real consumer.

  adapters                     500KB -> 2.6KB  (zod externalized)
  sdk                           14KB -> 5.4KB  (rest, types externalized)
  express/fastify/hono/supabase 480KB -> ~1.5KB (adapters externalized)
  elysia                         1MB -> 1.1KB  (adapters + elysia externalized)

This surfaced one real bug: sdk/v1 imported `Routes` from the deep subpath
`@abacatepay/types/v1/routes`, which types' bundled build never actually
produces (only `index`, `v1/index`, `v2/index` exist as complete bundles).
It worked before only because types was being inlined wholesale, so the
import resolved against source, not the published subpath. types/v2 already
re-exports `Routes` from its barrel for exactly this reason; types/v1 didn't.
Added the same re-export to types/v1 and pointed sdk/v1 at the barrel
instead of the deep subpath.

Verified with `npm pack` + a fresh isolated install of all 11 tarballs
together (plus elysia as a real peer dependency), running the full
verify.mjs script end-to-end -- 20/20 checks pass, including a functional
call through sdk/v1's fixed Routes usage against the live API.

Patch-bumped every package whose build output changed: types 3.0.2, sdk
2.0.2, adapters 2.0.2, express/fastify/hono/elysia/supabase 2.0.2. No public
API changed.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EqaJ2TCZoyMCFjK4WcKxBR
@ChristoPy ChristoPy self-assigned this Jul 27, 2026
@ChristoPy
ChristoPy merged commit 4360730 into main Jul 27, 2026
2 of 3 checks passed
ChristoPy added a commit that referenced this pull request Jul 27, 2026
)

The changelog-backfill PR (#43) updated package.json's `files` array for
zod, typebox, rest, eslint-plugin, and better-auth to include CHANGELOG.md,
but only bumped the version on the 8 packages actually touched by the
externalization fix in the same PR. These 5 got the files-array change
without a version bump, which means their published tarballs still won't
contain CHANGELOG.md -- npm won't even accept republishing the same version
with different content. Verified via `npm pack --dry-run` before and after.

  zod 2.0.1 -> 2.0.2, typebox 2.0.1 -> 2.0.2, rest 1.0.0 -> 1.0.1,
  eslint-plugin 0.1.3 -> 0.1.4, better-auth 1.0.1 -> 1.0.2

No code changed, only the files array + changelog. Verified with `npm pack
--dry-run` that CHANGELOG.md is now included in all 5.


Claude-Session: https://claude.ai/code/session_01EqaJ2TCZoyMCFjK4WcKxBR

Co-authored-by: Claude Sonnet 5 <[email protected]>
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.

2 participants