Package Setup Comparison
Compare current monorepo setup to mature patterns and outline improvements.
Package setup comparison and hardening plan
This document compares our current monorepo/package setup to patterns used by mature libraries (e.g., Zod) and outlines a prioritized plan to improve resilience, DX, and publish hygiene.
Reference: Zod repository (https://github.com/colinhacks/zod).
Snapshot of our current setup
- Monorepo: pnpm workspaces, Turborepo, packages under
packages/*, apps underapps/*. - CI: Lint (Biome), Build (turbo), Test (vitest) on Node 20; weekly models.dev sync workflow.
- Formatting/Lint: Biome configured; lefthook pre-commit runs formatting.
- Publishing:
tokenlenspublished; scoped packages@tokenlens/coreand@tokenlens/modelsexist but lack full publish metadata. - Module format: ESM with minimal
exportsfields. - Testing: Vitest in
tokenlens; no coverage thresholds; no type-level API tests.
Where we differ from a mature library setup
-
Node versions and constraints
- Ours: No
enginesfields or.nvmrc; CI runs on Node 20 only. - Mature: Pin LTS in
.nvmrc, setenginesin each package, test matrix across multiple Node LTS versions.
- Ours: No
-
Versioning and releases
- Ours: Changesets dependency present in root, but no config or automated release workflow.
- Mature: Changesets-managed versions, changelog generation, provenance-enabled npm publish via GitHub Actions.
-
CI quality gates
- Ours: Lint/build/test; no typecheck step, no coverage thresholds, no bundle/size checks, no consumer smoke tests.
- Mature: Typecheck, coverage gates, size-limit, consumer import tests (ESM and CJS if supported) across Node matrix.
-
Package metadata & publish hygiene
- Ours:
tokenlenshas complete metadata;@tokenlens/*missrepository,bugs,homepage,publishConfig.access. - Mature: Complete metadata for every package; explicit
publishConfig;prepacksafeguards and consistentfilescontent.
- Ours:
-
Exports and entrypoints
- Ours: Minimal exports; some internal
dist/exports/*not surfaced as subpath exports; no./package.jsonexport. - Mature: Clear ESM-only vs dual policy; subpaths exposed;
./package.jsonexported for tooling.
- Ours: Minimal exports; some internal
-
Tests and types
- Ours: No type-level tests ensuring public surface stability.
- Mature:
tsd/expect-typecoverage for the public API.
-
Dependency hygiene & OSS docs
- Ours: No Dependabot/Renovate; missing
SECURITY.md,CONTRIBUTING.md, templates,CODEOWNERS. - Mature: Automated updates and OSS hygiene files standard.
- Ours: No Dependabot/Renovate; missing
-
Docs in published tarballs
- Ours:
filesarrays omitREADME/LICENSE. - Mature: Ensure essential docs ship in the package.
- Ours:
Prioritized TODOs
-
Release and versioning
- Set up Changesets and npm release workflow with provenance and changelog
- Add
prepack/prepublishOnlyto clean and build before publish
-
Runtime and tooling constraints
- Add Node engine constraints and
.nvmrc(LTS), enforce via CI - Document and pin
packageManagerat root and enforce via CI
- Add Node engine constraints and
-
Package publishing hygiene
- Add
publishConfig.access: publicfor scoped packages (@tokenlens/core,@tokenlens/models) - Fill package metadata (
repository,homepage,bugs,license,funding) for all packages - Include
LICENSEandREADMEin publishedfilesarray for all packages
- Add
-
Module format and exports
- Decide ESM-only vs dual CJS+ESM; implement
exportsconditions accordingly - Expose secondary entrypoints via
exports(e.g.,./core,./helpers,./models,./simple) - Export
./package.jsoninexportsfor tooling introspection
- Decide ESM-only vs dual CJS+ESM; implement
-
CI quality gates
- Expand CI matrix to Node 18/20/22; add turbo typecheck/lint/test steps
- Enable coverage in Vitest with minimum thresholds and CI reporting
- Add size-limit (or similar) check for
tokenlens, gate in CI - Add smoke tests: consumer ESM (and CJS if supported) import across Node versions
-
Testing depth
- Type-level API tests with
tsd(orexpect-type) covering public surface
- Type-level API tests with
-
Dependency and security hygiene
- Add Dependabot or Renovate for dependencies and GitHub Actions updates
- Add OSS hygiene:
SECURITY.md,CONTRIBUTING.md, issue/PR templates,CODEOWNERS
-
Documentation
- Add per-package READMEs with usage, API, and badges
Notes and rationale
- Aligning on Node engines, exports, and CI gates reduces regressions for consumers and clarifies support policy.
- Changesets-based release flow improves version discipline, changelog quality, and publish safety.
- Type-level tests catch breaking type changes early, which is critical for TypeScript-first libraries.
References
- Zod repository:
https://github.com/colinhacks/zod