add-export
Add a new subpath export to the @cyanheads/mcp-ts-core package. Use when creating a new public API surface that consumers import from a dedicated subpath (e.g., @cyanheads/mcp-ts-core/newutil).
Context
Subpath exports are defined in package.json under the exports field. Each subpath maps to a source entry point that gets compiled to dist/. The exports catalog in CLAUDE.md must stay in sync with package.json.
The build uses tsconfig.build.json (not tsconfig.json) with rootDir: ./src and include: ["src/**/*"]. This means every source file at src/foo/bar.ts compiles to dist/foo/bar.js — the dist/ paths in exports must mirror the source tree exactly, not flatten it.
Steps
-
Create the entry point source file under
src/(e.g.,src/utils/new-util.ts) -
Add the subpath to
package.jsonexports, mirroring the source path:// source: src/utils/new-util.ts → dist: dist/utils/new-util.js "./newutil": { "types": "./dist/utils/new-util.d.ts", "import": "./dist/utils/new-util.js" } -
Update the exports catalog in
CLAUDE.md— add a row to the table -
Build with
bun run buildto generatedist/output -
Verify the export by inspecting the compiled output directly:
# Confirm the compiled file exists at the expected dist path ls dist/utils/new-util.js # Confirm the declared exports resolve to real files bun -e "import('./dist/utils/new-util.js').then(m => console.log(Object.keys(m)))" -
Run
bun run devcheckto verify
Naming conventions
| Convention | Rule |
|---|---|
| Subpath | lowercase, no underscores (e.g., utils/errorHandler) |
| Source file | kebab-case (e.g., error-handler.ts) |
| Export name | camelCase for values, PascalCase for types |
Checklist
- Source entry point file created with JSDoc header
- Subpath added to
package.jsonexportswithtypesandimportconditions - Exports catalog in
CLAUDE.mdupdated with new row -
bun run buildsucceeds - Compiled file exists at expected
dist/path and exports the expected symbols -
bun run devcheckpasses