|
| 1 | +# Stackpress Package Public Surface Workflow |
| 2 | + |
| 3 | +Use this workflow when adding or moving a public type, helper, function, class, |
| 4 | +constant, or source file under `packages/*`, especially when the symbol may also |
| 5 | +be exposed through the `stackpress` aggregate facade. |
| 6 | + |
| 7 | +Do not use it for private file-local changes or generated-client exports. Follow |
| 8 | +the generator procedure in the contributor reference for generated artifacts. |
| 9 | + |
| 10 | +## Read First |
| 11 | + |
| 12 | +1. [Extension And Contribution](../context/extension-and-contribution.md) for |
| 13 | + semantic ownership and source-boundary rules. |
| 14 | +2. [Contributor Source Patterns](../references/00018-contributor-source-patterns.md) |
| 15 | + for exact placement and public-surface requirements. |
| 16 | +3. [Architecture And Composition](../context/architecture-and-composition.md) |
| 17 | + only when aggregate eligibility is in question. |
| 18 | +4. [Exports, Types, And Generated Contracts](../references/00014-exports-types-generated-contracts.md) |
| 19 | + when changing a subpath, aggregate alias, or package manifest. |
| 20 | + |
| 21 | +## 1. Classify The Surface |
| 22 | + |
| 23 | +Before editing, identify: |
| 24 | + |
| 25 | +- the focused package that owns the symbol; |
| 26 | +- whether it is a type or runtime value; |
| 27 | +- whether it is private, subpath-only, package-root public, aggregate-domain |
| 28 | + public, or aggregate-root public; |
| 29 | +- whether the target entrypoint is server-only, browser-safe, or shared. |
| 30 | + |
| 31 | +Do not infer aggregate exposure from plugin registration, dependency presence, |
| 32 | +or build participation. Each public layer is an explicit decision. |
| 33 | + |
| 34 | +## 2. Update The Owning Package |
| 35 | + |
| 36 | +| Symbol | Owning package placement | |
| 37 | +| --- | --- | |
| 38 | +| shared public type | define or re-export from `src/types.ts`; export with `export type` from `src/index.ts` | |
| 39 | +| subpath-specific type | keep with its subpath; export only from that subpath unless promoted separately | |
| 40 | +| runtime value | implement in its semantic source file; export from `src/index.ts` only when package-root public | |
| 41 | +| generally reusable helper | use a focused root helper module when appropriate | |
| 42 | +| niche helper | keep local to its consumers, even when small duplication is clearer | |
| 43 | + |
| 44 | +Preserve `.js` suffixes in source imports. Never edit `cjs/` or `esm/` as the |
| 45 | +durable source. |
| 46 | + |
| 47 | +## 3. Update Public Subpaths |
| 48 | + |
| 49 | +When adding or changing a direct import path: |
| 50 | + |
| 51 | +1. Add the source entrypoint. |
| 52 | +2. Align the owning package's `package.json` `exports` and `typesVersions`. |
| 53 | +3. Confirm both CJS and ESM builds emit the entrypoint and declaration. |
| 54 | + |
| 55 | +Adding a symbol to an existing barrel does not require a new manifest entry. |
| 56 | + |
| 57 | +## 4. Propagate Through The Aggregate |
| 58 | + |
| 59 | +Only propagate symbols deliberately selected for the `stackpress` facade. Skip |
| 60 | +layers that are not part of the intended public surface. |
| 61 | + |
| 62 | +For types: |
| 63 | + |
| 64 | +```text |
| 65 | +packages/<pkg>/src/types.ts |
| 66 | + -> packages/<pkg>/src/index.ts |
| 67 | + -> packages/stackpress/src/<domain>/types.ts |
| 68 | + -> packages/stackpress/src/<domain>/index.ts |
| 69 | + -> packages/stackpress/src/types.ts |
| 70 | + -> packages/stackpress/src/index.ts |
| 71 | +``` |
| 72 | + |
| 73 | +For runtime values: |
| 74 | + |
| 75 | +```text |
| 76 | +packages/<pkg>/src/<source>.ts |
| 77 | + -> packages/<pkg>/src/index.ts |
| 78 | + -> packages/stackpress/src/<domain>/index.ts |
| 79 | + -> packages/stackpress/src/index.ts |
| 80 | +``` |
| 81 | + |
| 82 | +The domain facade and aggregate root are separate promotion decisions. Use |
| 83 | +explicit aliases for root-name collisions and prefer named forwarding so the |
| 84 | +facade remains reviewable. |
| 85 | + |
| 86 | +Add or change aggregate `package.json` entries only when exposing a new or |
| 87 | +changed aggregate subpath. |
| 88 | + |
| 89 | +## 5. Verify The Promised Imports |
| 90 | + |
| 91 | +1. Build and test the owning package with Node.js 22 and Yarn. |
| 92 | +2. Test every public import path promised by the change, including type-only |
| 93 | + imports where applicable. |
| 94 | +3. If `packages/stackpress` changed, build and test the aggregate and exercise |
| 95 | + the affected focused and root imports. |
| 96 | +4. If a manifest changed, verify CJS, ESM, declarations, packed contents, and a |
| 97 | + consumer import. |
| 98 | +5. Apply the public export/manifest verification requirements from |
| 99 | + [Extension And Contribution](../context/extension-and-contribution.md#verification-matrix). |
| 100 | +6. Confirm generated output was not edited as durable source and unrelated |
| 101 | + package surfaces were not broadened. |
| 102 | + |
| 103 | +## Handoff |
| 104 | + |
| 105 | +Report the semantic owner, selected public layers, files changed, aliases or |
| 106 | +subpaths added, verification performed, intentionally skipped layers, and any |
| 107 | +remaining consumer or release sequencing. |