Files
pubsub/tasks/016-build-and-exports-validation.md

88 lines
3.9 KiB
Markdown

---
id: build-and-exports-validation
name: Validate build, package.json exports, and tsup config for all adapters
status: completed
depends_on: []
scope: narrow
risk: low
impact: component
level: implementation
---
## Description
Verify that the build pipeline correctly produces dual ESM + CJS output with declarations for all entry points, and that `package.json` exports map and `tsup.config.ts` entries are consistent.
Currently only `src/index.ts` and `src/event-target-redis.ts` are entry points. As new adapters are added, each needs:
1. An entry in `tsup.config.ts` entry array
2. A sub-path export in `package.json` exports map (ESM + CJS + declarations)
3. A barrel re-export in `src/index.ts`
This task validates the current setup and serves as a checklist item for each adapter task. It can be done early and re-verified as adapters are added.
## Acceptance Criteria
- [ ] `npm run build` produces correct output for existing entry points (index, event-target-redis)
- [ ] `npm run lint` (tsc --noEmit) passes
- [ ] `package.json` exports map has correct ESM/CJS/dts paths for each entry point
- [ ] `tsup.config.ts` lists all current entry points
- [ ] `src/index.ts` re-exports everything from all modules
- [ ] Peer dependencies and peerDependenciesMeta are correct
- [ ] No runtime dependencies (Repeater is inlined)
## References
- docs/architecture/build-distribution.md
- package.json
- tsup.config.ts
## Notes
Validated all acceptance criteria. No changes were needed — the existing configuration is correct.
### Validation Results
1. **`npm run build` produces correct output** ✅
- `src/index.ts``dist/index.js` (ESM), `dist/index.cjs` (CJS), `dist/index.d.ts` + `dist/index.d.cts` (declarations)
- `src/event-target-redis.ts``dist/event-target-redis.js` (ESM), `dist/event-target-redis.cjs` (CJS), `dist/event-target-redis.d.ts` + `dist/event-target-redis.d.cts` (declarations)
- Code splitting enabled: shared chunk between entries (`chunk-JGLUDY7D.js` / `chunk-TBKAZXTS.cjs`)
- Verified both ESM dynamic import and CJS require work for both entry points
2. **`npm run lint` (tsc --noEmit) passes** ✅ — No errors
3. **`package.json` exports map has correct ESM/CJS/dts paths** ✅
- `"."` → import (d.ts + js) / require (d.cts + cjs)
- `"./event-target-redis"` → import (d.ts + js) / require (d.cts + cjs)
- All paths resolve to actual built files
4. **`tsup.config.ts` lists all current entry points** ✅
- `src/index.ts` and `src/event-target-redis.ts` both present
- `format: ['esm', 'cjs']`, `dts: true`, `splitting: true`, `target: 'es2022'`
5. **`src/index.ts` re-exports everything from all modules** ✅
- Exports from: `create_pubsub.js`, `types.js`, `operators.js`, `repeater.js`, `event-target-redis.js`
- All public API surface is accessible from barrel
6. **Peer dependencies and peerDependenciesMeta are correct**
- `ioredis@^5.0.0` as optional peer dep
- Future: `@rayhanadev/iroh` will follow same pattern when added
7. **No runtime dependencies**
- `dependencies: {}` is empty
- `@repeaterjs/repeater` is inlined in `src/repeater.ts`
### Verified type resolution
- `import { createRedisEventTarget } from '@alkdev/pubsub/event-target-redis'` — types resolve correctly
- `import { createPubSub, type EventEnvelope } from '@alkdev/pubsub'` — types resolve correctly
- Works with both `skipLibCheck: true` and `skipLibCheck: false`
### Verified package contents
- `npm pack --dry-run` shows 19 files (all dist files + package.json)
- `files: ["dist"]` correctly includes all build output
## Summary
Validated build pipeline, package.json exports map, and tsup config for all adapters. All acceptance criteria pass with no changes required — the existing configuration is correct and consistent.
- Created: none
- Modified: none (validation-only task)
- Tests: 0 (no test files exist yet; `npm test` exits with "No test files found")