Package Build Pipeline and Type Safety in CI
ARCHITECTURE •
Situation
The monorepo packages (@juun/db, @juun/api) were exporting raw source files directly, relying on transpilePackages in Next.js config.
Unlike @juun/ui which required this workaround due to RSC directive limitations (timeline #18), these packages contain no "use client" or "use server" directives—making them viable candidates for proper bundling.
CI pipeline skipped building these packages, missing potential type errors that would only surface at runtime.
OpenAPI type generation ran in CI with network dependencies, causing unreliable builds.
Task
- Establish proper package build pipeline with type declaration generation
- Enable full TypeScript validation in CI without transpilation blind spots
- Remove network dependencies from CI by committing generated types
Action
1. Added Build Pipeline to @juun/db
@juun/api already had tsup configured. Added equivalent setup to @juun/db:
tsup configuration:
- CJS + ESM dual format output
- Type declarations with
dts: true - 5 entry points: index, client, post, timeline, test-connection
- Node.js platform target for Prisma compatibility
- Tree-shaking and minification enabled
package.json exports migration: From src to dist
Similar pattern applied to /client, /post, /timeline sub-paths.
2. CI Pipeline Enhancement
Build stages for each packages added before Next.js type generation to ensure workspace packages have type declarations available for downstream consumers.
3. OpenAPI Type Management
- Removed generated types from
.gitignore - Updated pre-commit hook to generate types before type checks
Generates fresh OpenAPI types locally (where network is available) and commits them, eliminating network dependency in CI.
Result
Migrated from "transpile on-demand" to "build once, consume everywhere" architecture. CI now performs full TypeScript validation against built type declarations, catching errors that previously surfaced only at runtime.