Skip to content

Commit cc47920

Browse files
committed
docs(claude): document named export patterns and enforcement
Add comprehensive export pattern guidelines: - Named exports ONLY (default exports forbidden) - Rationale: dual CJS/ESM compatibility - Enforcement: Biome linting + build-time validation Documents the mandatory pattern for all library modules to ensure consistent API surface across CommonJS and ESM consumers.
1 parent 5a9ccf3 commit cc47920

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,21 @@ Blank lines between groups, alphabetical within groups.
201201
- **External modules**: Regular imports
202202
-`import path from 'node:path'`
203203

204+
#### Export Patterns
205+
- **Named exports ONLY**: 🚨 MANDATORY for all library modules
206+
-`export { value }` - Direct named export
207+
-`export { foo, bar, baz }` - Multiple named exports
208+
-`export default value` - FORBIDDEN (breaks dual CJS/ESM compatibility)
209+
-`export default X; export { X as 'module.exports' }` - FORBIDDEN (dual export pattern)
210+
- **Rationale**: Dual-format (CJS/ESM) compatibility requires consistent named exports
211+
- Named exports work identically in both module systems
212+
- Default exports require `.default` access, breaking consistency
213+
- Build validation enforces this pattern (enabled in CI)
214+
- **Enforcement**:
215+
- Biome linting rule: `"noDefaultExport": "error"`
216+
- Build-time validation: `scripts/validate/esm-named-exports.mjs`
217+
- CI validation: `scripts/validate/dist-exports.mjs`
218+
204219
### Package Exports
205220

206221
#### Export Structure

0 commit comments

Comments
 (0)