Named exports through src/index.ts
Rule
The public API is exactly what src/index.ts re-exports. Use named exports only; never export default. A module that is not re-exported from src/index.ts is internal. Add a name to src/index.ts only when a task requirement names it.
Do
export function tokenize(text: string): string[] {
return text
.toLowerCase()
.split(/[^\p{L}\p{N}]+/u)
.filter((t) => t.length > 0);
}// src/index.ts
export { tokenize } from './tokenize.js';
export { createIndex } from './index-builder.js';
export type { Result } from './result.js';Don’t
export default function tokenize(text: string): string[] {
return text.toLowerCase().split(/\s+/);
}Rationale
Named exports keep import names stable across consumers and make the API surface greppable. One entry file gives SemVer review a single place to see what changed. The A7 governance contract lets agents change exports only where a requirement names them.