Skip to content

chore: build all packages with tsup, ship ESM + CJS and typedefs#17

Open
eduardoborges wants to merge 2 commits intoAbacatePay:mainfrom
eduardoborges:chore/sdk-tsup-build
Open

chore: build all packages with tsup, ship ESM + CJS and typedefs#17
eduardoborges wants to merge 2 commits intoAbacatePay:mainfrom
eduardoborges:chore/sdk-tsup-build

Conversation

@eduardoborges
Copy link
Copy Markdown

@eduardoborges eduardoborges commented Mar 18, 2026

Problem

Packages were built with a mix of bun build + tsc --emitDeclarationOnly, or tsc alone. That led to:

  • Fragile build steps: separate JS and declaration steps that can get out of sync and depend on rootDir/path resolution.
  • ESM-only output: consumers using require() or older Node/bundlers had no supported CJS entry.
  • Inconsistent tooling: each package had its own build script shape (e.g. rm -rf dist, bun run types), making the monorepo harder to maintain.

Motivation

  • Single build pipeline: Use tsup for every package so one command produces ESM, CJS, and type declarations. Fewer moving parts and less room for error.
  • Dual format: Ship both import (ESM) and require (CJS) via package.json exports and main so Node, bundlers, and legacy setups can consume the packages.
  • Typedefs in package.json: Add types / typings and correct exports so TypeScript and editors resolve declarations without extra config.

Changes

  • All packages now use a tsup.config.ts with format: ["esm", "cjs"] and dts: true.
  • Build script is bun run scripts/version.ts && tsup (or gen:version where used); the separate types script was removed.
  • package.json per package:
    • exports: import.js, require.cjs, types.d.ts (and subpaths where applicable).
    • main set to .cjs for CJS entry.
    • typings added alongside types.
    • tsup added as a devDependency.
  • @abacatepay/types: types/v1/routes.ts and types/v2/routes.ts added as tsup entries so @abacatepay/types/v1/routes resolves for the SDK.
  • SDK: tsconfig.json no longer overrides paths with {}, so the base config paths are used for declaration generation.

- Add tsup.config.ts with entry points for index, v1, v2
- Replace bun build + tsc with single tsup build (ESM + dts)
- Add typings field to package.json for declaration discovery
- Add tsup devDependency

Made-with: Cursor
@eduardoborges eduardoborges changed the title chore(sdk): build with tsup and ship typedefs fix(sdk): build with tsup and ship typedefs Mar 18, 2026
- Add tsup to every package (rest, types, zod, typebox, adapters, supabase,
  hono, fastify, express, elysia, better-auth, eslint-plugin, sdk)
- Single build step: ESM, CJS, and .d.ts via tsup (dts: true)
- Add typings field and require exports for CJS consumers
- types: add v1/routes and v2/routes entries for SDK subpath imports
- sdk tsconfig: drop empty paths override so base paths apply for dts

Made-with: Cursor
@eduardoborges eduardoborges changed the title fix(sdk): build with tsup and ship typedefs chore: build all packages with tsup, ship ESM + CJS and typedefs Mar 18, 2026
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