Skip to main content
A package lives at packages/<category>/<name> and is published as @stackra/<name>. The category is only a folder (see Package categories). Every package is also a member and carries its required files.

Shape: entries first

Every library package has one shape (0126, which supersedes the archetypes of 0004). pnpm new package <name> --category <c> --entries … renders it. tooling presets keep their own shape (below).

Tooling

Data, not a build: JSON or JSONC presets with a files allowlist and an exports map, tag tier:config, no src/ layers. A change goes into the preset, never into each consumer. Presets keep ./x.ts specifiers because plain Node loads them.

Exports, barrels and imports

  • Every package builds with tsdown to ESM-only dist/*.mjs plus .d.mts. Each exports entry lists the @stackra/source condition first (pointing at ./src/**, read by typecheck, Vitest and Vite), then types and default in dist (runtimes load these). The validator checks the shape (0025).
  • index.ts is the only barrel name. A barrel declares nothing; it re-exports.
  • A consumer imports the package or a declared subpath, never another package’s src/ (@stackra/*/src/* is a lint error).
  • A package never imports an app, a service, or encore.dev and ~encore/*.
  • A shared package holds mechanisms, not product literals: no brand name, locale list, project id or process.env read. Decorators annotate code (classes, methods, fields); define* creates values other code references (defineToken, defineConfig, definePermissions, defineEvents, defineMeters, defineEntitlements); the app holds the definition. See Boundaries.
  • Naming, one declaration per file and specifier style: Code style.

Provenance of copied code

Code copied from another repository is copied, not depended on, and says where it came from. Next to the package, ORIGIN.md records:
  • the source repository, path and commit hash, and the date;
  • what changed on copy (renames, product values removed, dependencies swapped);
  • how to pull a later change: diff the source at the new commit against the recorded one, port by hand, update the file.

Port or rewrite

Decide per package before copying: A port that diverges from its origin does so openly: in ORIGIN.md, not silently.

What enforces this

The package-steward reviews every new package and every new exports subpath; see the agent roster.