@mr.dj2u/knowledge 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/content/checklists/ship-test-loop.md +16 -0
- package/dist/content/checklists/unified-agent-bundle-validation.md +8 -0
- package/dist/content/examples/ship-test-loop.md +13 -0
- package/dist/content/examples/unified-agent-bundle-bootstrap.md +8 -0
- package/dist/content/guides/animation-performance.md +30 -0
- package/dist/content/guides/post-create-onboarding.md +113 -0
- package/dist/content/patterns/api/api-routes.md +314 -0
- package/dist/content/patterns/api/error-handling.md +311 -0
- package/dist/content/patterns/database/drizzle-schema.md +280 -0
- package/dist/content/patterns/database/migrations.md +365 -0
- package/dist/content/patterns/database/query-organization.md +537 -0
- package/dist/content/patterns/database/relations.md +450 -0
- package/dist/content/patterns/deployment/build-configuration.md +452 -0
- package/dist/content/patterns/deployment/ci-cd-patterns.md +448 -0
- package/dist/content/patterns/deployment/environment-config.md +380 -0
- package/dist/content/patterns/deployment/hosting-setup.md +425 -0
- package/dist/content/patterns/project/configuration-patterns.md +459 -0
- package/dist/content/patterns/project/documentation-org.md +506 -0
- package/dist/content/patterns/project/folder-structure.md +398 -0
- package/dist/content/patterns/project/library-exports.md +465 -0
- package/dist/content/patterns/project/monorepo-structure.md +500 -0
- package/dist/content/patterns/routing/dynamic-routes.md +221 -0
- package/dist/content/patterns/routing/file-based-routing.md +186 -0
- package/dist/content/patterns/routing/route-groups.md +429 -0
- package/dist/content/patterns/state/persistence-middleware.md +521 -0
- package/dist/content/patterns/state/selector-hooks.md +538 -0
- package/dist/content/patterns/state/store-organization.md +539 -0
- package/dist/content/patterns/state/zustand-patterns.md +348 -0
- package/dist/content/patterns/styling/component-styling.md +468 -0
- package/dist/content/patterns/styling/responsive-patterns.md +398 -0
- package/dist/content/patterns/styling/theme-configuration.md +426 -0
- package/dist/content/patterns/styling/uniwind-setup.md +412 -0
- package/dist/content/prompts/continue-development.md +27 -0
- package/dist/content/prompts/create-expo-super-stack.md +29 -0
- package/dist/content/prompts/fix-seo.md +29 -0
- package/dist/content/prompts/onboard-new-expo-app.md +11 -0
- package/dist/content/prompts/prepare-deploy.md +29 -0
- package/dist/content/prompts/project-research-plan.md +29 -0
- package/dist/content/prompts/review-expo-project.md +29 -0
- package/dist/content/prompts/run-doctor.md +30 -0
- package/dist/content/prompts/ship-test-loop.md +24 -0
- package/dist/content/reference/create-expo-stack-uniwind.md +29 -0
- package/dist/content/reference/doctor-dogfood.md +42 -0
- package/dist/content/reference/mcp-sdk-transport.md +30 -0
- package/dist/content/reference/package-ci-patterns.md +24 -0
- package/dist/content/reference/reference-repo-evacuation.md +31 -0
- package/dist/content/resource-index.json +67 -0
- package/dist/content/rules/app-folder-architecture.md +13 -0
- package/dist/content/rules/env-hygiene.md +9 -0
- package/dist/content/rules/seo-metadata.md +7 -0
- package/dist/content/rules/ssr-safety.md +9 -0
- package/dist/content/skills/api-routes.md +33 -0
- package/dist/content/skills/continue-development.md +31 -0
- package/dist/content/skills/debugging.md +31 -0
- package/dist/content/skills/deployment.md +32 -0
- package/dist/content/skills/dev-server-management.md +31 -0
- package/dist/content/skills/env-vars.md +32 -0
- package/dist/content/skills/expo-router-architecture.md +33 -0
- package/dist/content/skills/expo-ssr-safety.md +32 -0
- package/dist/content/skills/plugin-creation.md +41 -0
- package/dist/content/skills/production-server-patterns.md +31 -0
- package/dist/content/skills/project-onboarding.md +31 -0
- package/dist/content/skills/research-plan-intake.md +31 -0
- package/dist/content/skills/seo-metadata.md +31 -0
- package/dist/content/skills/super-stack-startup.md +31 -0
- package/dist/content/skills/uniwind-theming.md +32 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +369 -0
- package/dist/index.js.map +1 -0
- package/dist/patterns/index.d.ts +78 -0
- package/dist/patterns/index.d.ts.map +1 -0
- package/dist/patterns/index.js +264 -0
- package/dist/patterns/index.js.map +1 -0
- package/dist/prompts/index.d.ts +35 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +270 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/skills/index.d.ts +3 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +2 -0
- package/dist/skills/index.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
# Library Exports
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
Library exports patterns define how to structure and expose package functionality via `package.json` export fields, entry points, and barrel exports. These patterns enable proper module resolution, tree-shaking, and TypeScript type support across CommonJS and ESM contexts.
|
|
6
|
+
|
|
7
|
+
## When to Use
|
|
8
|
+
|
|
9
|
+
**Apply library exports patterns when:**
|
|
10
|
+
- ✅ Creating a shared component library
|
|
11
|
+
- ✅ Publishing a utility package to npm or workspace
|
|
12
|
+
- ✅ Designing public APIs for packages
|
|
13
|
+
- ✅ Supporting both CommonJS and ESM consumers
|
|
14
|
+
- ✅ Optimizing bundle size with tree-shaking
|
|
15
|
+
- ✅ Managing peer dependencies
|
|
16
|
+
- ✅ Providing TypeScript type definitions
|
|
17
|
+
|
|
18
|
+
## Core Concepts
|
|
19
|
+
|
|
20
|
+
**Export Field Structure:**
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"main": "dist/index.js", // CommonJS entry
|
|
24
|
+
"module": "dist/index.esm.js", // ESM entry
|
|
25
|
+
"types": "dist/index.d.ts", // TypeScript types
|
|
26
|
+
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"import": "./dist/index.esm.js",
|
|
30
|
+
"require": "./dist/index.js",
|
|
31
|
+
"types": "./dist/index.d.ts"
|
|
32
|
+
},
|
|
33
|
+
"./components": { ... },
|
|
34
|
+
"./hooks": { ... }
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Key Benefits:**
|
|
40
|
+
- Explicit public API definition
|
|
41
|
+
- Tree-shaking support
|
|
42
|
+
- Conditional module resolution
|
|
43
|
+
- Type safety for consumers
|
|
44
|
+
- Clear version contracts
|
|
45
|
+
|
|
46
|
+
## Code Examples
|
|
47
|
+
|
|
48
|
+
### Basic Library - package.json
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"name": "@monorepo/ui",
|
|
53
|
+
"version": "1.0.0",
|
|
54
|
+
"description": "Shared UI component library",
|
|
55
|
+
"license": "MIT",
|
|
56
|
+
|
|
57
|
+
"type": "module",
|
|
58
|
+
"main": "dist/index.js",
|
|
59
|
+
"types": "dist/index.d.ts",
|
|
60
|
+
"files": ["dist", "src"],
|
|
61
|
+
|
|
62
|
+
"scripts": {
|
|
63
|
+
"build": "tsc --project tsconfig.build.json && npm run build:types",
|
|
64
|
+
"build:types": "tsc --emitDeclarationOnly --project tsconfig.build.json",
|
|
65
|
+
"dev": "tsc --watch",
|
|
66
|
+
"lint": "eslint src"
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
"exports": {
|
|
70
|
+
".": {
|
|
71
|
+
"import": "./dist/index.js",
|
|
72
|
+
"require": "./dist/index.cjs",
|
|
73
|
+
"types": "./dist/index.d.ts",
|
|
74
|
+
"default": "./dist/index.js"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
"dependencies": {
|
|
79
|
+
"react": "^19.0.0",
|
|
80
|
+
"react-native": "^0.83.0"
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
"peerDependencies": {
|
|
84
|
+
"react": "^19.0.0",
|
|
85
|
+
"react-native": "^0.83.0"
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
"devDependencies": {
|
|
89
|
+
"@types/react": "^19.0.0",
|
|
90
|
+
"@types/react-native": "^0.83.0",
|
|
91
|
+
"typescript": "^5.9.0"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Multi-entry Library - package.json
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"name": "@monorepo/ui",
|
|
101
|
+
"version": "1.0.0",
|
|
102
|
+
"main": "dist/index.js",
|
|
103
|
+
"types": "dist/index.d.ts",
|
|
104
|
+
|
|
105
|
+
"exports": {
|
|
106
|
+
".": {
|
|
107
|
+
"import": "./dist/index.js",
|
|
108
|
+
"require": "./dist/index.cjs",
|
|
109
|
+
"types": "./dist/index.d.ts"
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
"./components": {
|
|
113
|
+
"import": "./dist/components/index.js",
|
|
114
|
+
"require": "./dist/components/index.cjs",
|
|
115
|
+
"types": "./dist/components/index.d.ts"
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
"./hooks": {
|
|
119
|
+
"import": "./dist/hooks/index.js",
|
|
120
|
+
"require": "./dist/hooks/index.cjs",
|
|
121
|
+
"types": "./dist/hooks/index.d.ts"
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
"./theme": {
|
|
125
|
+
"import": "./dist/theme/index.js",
|
|
126
|
+
"require": "./dist/theme/index.cjs",
|
|
127
|
+
"types": "./dist/theme/index.d.ts"
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
"./package.json": "./package.json"
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
"files": ["dist", "src", "LICENSE"]
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Conditional Exports - package.json
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"name": "@monorepo/ui",
|
|
142
|
+
"version": "1.0.0",
|
|
143
|
+
|
|
144
|
+
"exports": {
|
|
145
|
+
".": {
|
|
146
|
+
"types": "./dist/index.d.ts",
|
|
147
|
+
"import": "./dist/index.mjs",
|
|
148
|
+
"require": "./dist/index.cjs",
|
|
149
|
+
"default": "./dist/index.js"
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
"./button": {
|
|
153
|
+
"types": "./dist/button.d.ts",
|
|
154
|
+
"import": "./dist/button.mjs",
|
|
155
|
+
"require": "./dist/button.cjs"
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
"files": ["dist"]
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Barrel Export Pattern - src/index.ts
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
// src/index.ts - Main barrel export
|
|
167
|
+
// Re-export all public components and hooks
|
|
168
|
+
|
|
169
|
+
// Components
|
|
170
|
+
export { Button } from './components/Button';
|
|
171
|
+
export { Card } from './components/Card';
|
|
172
|
+
export { Modal } from './components/Modal';
|
|
173
|
+
export { TextInput } from './components/TextInput';
|
|
174
|
+
|
|
175
|
+
// Hooks
|
|
176
|
+
export { useTheme } from './hooks/useTheme';
|
|
177
|
+
export { useForm } from './hooks/useForm';
|
|
178
|
+
export { useMedia } from './hooks/useMedia';
|
|
179
|
+
|
|
180
|
+
// Types
|
|
181
|
+
export type { ButtonProps } from './components/Button';
|
|
182
|
+
export type { CardProps } from './components/Card';
|
|
183
|
+
export type { FormState } from './hooks/useForm';
|
|
184
|
+
|
|
185
|
+
// Utils
|
|
186
|
+
export { cn } from './utils/cn';
|
|
187
|
+
export { toPascalCase } from './utils/string';
|
|
188
|
+
|
|
189
|
+
// Constants and defaults
|
|
190
|
+
export { DEFAULT_THEME } from './constants/theme';
|
|
191
|
+
export { BREAKPOINTS } from './constants/breakpoints';
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Submodule Barrel - src/components/index.ts
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
// src/components/index.ts - Components submodule
|
|
198
|
+
export { Button } from './Button';
|
|
199
|
+
export { Card } from './Card';
|
|
200
|
+
export { Modal } from './Modal';
|
|
201
|
+
export { TextInput } from './TextInput';
|
|
202
|
+
export { Select } from './Select';
|
|
203
|
+
|
|
204
|
+
// Re-export types
|
|
205
|
+
export type { ButtonProps } from './Button';
|
|
206
|
+
export type { CardProps } from './Card';
|
|
207
|
+
export type { ModalProps } from './Modal';
|
|
208
|
+
export type { TextInputProps } from './TextInput';
|
|
209
|
+
export type { SelectProps } from './Select';
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Hooks Submodule - src/hooks/index.ts
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
// src/hooks/index.ts - Hooks submodule
|
|
216
|
+
export { useTheme } from './useTheme';
|
|
217
|
+
export { useForm } from './useForm';
|
|
218
|
+
export { useMedia } from './useMedia';
|
|
219
|
+
export { useAsync } from './useAsync';
|
|
220
|
+
export { useDebounce } from './useDebounce';
|
|
221
|
+
|
|
222
|
+
// Re-export types
|
|
223
|
+
export type { UseFormOptions, UseFormState } from './useForm';
|
|
224
|
+
export type { Breakpoint, MediaQuery } from './useMedia';
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Tree-Shaking Friendly Structure
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
// ❌ AVOID - Default exports prevent tree-shaking
|
|
231
|
+
export default {
|
|
232
|
+
Button: ButtonComponent,
|
|
233
|
+
Card: CardComponent,
|
|
234
|
+
Modal: ModalComponent,
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
// ✅ PREFER - Named exports enable tree-shaking
|
|
238
|
+
export { Button } from './Button';
|
|
239
|
+
export { Card } from './Card';
|
|
240
|
+
export { Modal } from './Modal';
|
|
241
|
+
|
|
242
|
+
// Usage with tree-shaking
|
|
243
|
+
// Only Button code included in bundle
|
|
244
|
+
import { Button } from '@monorepo/ui';
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Peer Dependencies - package.json
|
|
248
|
+
|
|
249
|
+
```json
|
|
250
|
+
{
|
|
251
|
+
"name": "@monorepo/ui",
|
|
252
|
+
"version": "1.0.0",
|
|
253
|
+
|
|
254
|
+
"peerDependencies": {
|
|
255
|
+
"react": "^19.0.0",
|
|
256
|
+
"react-native": "^0.83.0"
|
|
257
|
+
},
|
|
258
|
+
|
|
259
|
+
"peerDependenciesMeta": {
|
|
260
|
+
"react-native-reanimated": {
|
|
261
|
+
"optional": true
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
|
|
265
|
+
"dependencies": {
|
|
266
|
+
"zustand": "^4.4.0",
|
|
267
|
+
"clsx": "^2.0.0"
|
|
268
|
+
},
|
|
269
|
+
|
|
270
|
+
"devDependencies": {
|
|
271
|
+
"react": "^19.0.0",
|
|
272
|
+
"react-native": "^0.83.0"
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Component with Documentation - Button.tsx
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
// src/components/Button.tsx
|
|
281
|
+
import { Pressable, Text } from 'react-native';
|
|
282
|
+
import { cn } from '../utils/cn';
|
|
283
|
+
|
|
284
|
+
export interface ButtonProps {
|
|
285
|
+
/**
|
|
286
|
+
* Button text content
|
|
287
|
+
*/
|
|
288
|
+
children: string;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Size variant
|
|
292
|
+
* @default "md"
|
|
293
|
+
*/
|
|
294
|
+
size?: 'sm' | 'md' | 'lg';
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Visual variant
|
|
298
|
+
* @default "primary"
|
|
299
|
+
*/
|
|
300
|
+
variant?: 'primary' | 'secondary' | 'danger';
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Callback when pressed
|
|
304
|
+
*/
|
|
305
|
+
onPress?: () => void;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Disabled state
|
|
309
|
+
* @default false
|
|
310
|
+
*/
|
|
311
|
+
disabled?: boolean;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Reusable button component
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* ```tsx
|
|
319
|
+
* <Button size="lg" variant="primary" onPress={handlePress}>
|
|
320
|
+
* Click me
|
|
321
|
+
* </Button>
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
324
|
+
export function Button({
|
|
325
|
+
children,
|
|
326
|
+
size = 'md',
|
|
327
|
+
variant = 'primary',
|
|
328
|
+
onPress,
|
|
329
|
+
disabled = false,
|
|
330
|
+
}: ButtonProps) {
|
|
331
|
+
return (
|
|
332
|
+
<Pressable
|
|
333
|
+
className={cn(
|
|
334
|
+
'rounded-lg font-semibold',
|
|
335
|
+
// Size classes
|
|
336
|
+
size === 'sm' && 'px-3 py-1 text-sm',
|
|
337
|
+
size === 'md' && 'px-4 py-2 text-base',
|
|
338
|
+
size === 'lg' && 'px-6 py-3 text-lg',
|
|
339
|
+
// Variant classes
|
|
340
|
+
variant === 'primary' && 'bg-blue-500 active:bg-blue-600',
|
|
341
|
+
variant === 'secondary' && 'bg-gray-200 active:bg-gray-300',
|
|
342
|
+
variant === 'danger' && 'bg-red-500 active:bg-red-600',
|
|
343
|
+
// Disabled state
|
|
344
|
+
disabled && 'opacity-50'
|
|
345
|
+
)}
|
|
346
|
+
onPress={onPress}
|
|
347
|
+
disabled={disabled}
|
|
348
|
+
>
|
|
349
|
+
<Text className={cn(
|
|
350
|
+
'text-center',
|
|
351
|
+
variant === 'primary' && 'text-white',
|
|
352
|
+
variant === 'secondary' && 'text-black',
|
|
353
|
+
variant === 'danger' && 'text-white'
|
|
354
|
+
)}>
|
|
355
|
+
{children}
|
|
356
|
+
</Text>
|
|
357
|
+
</Pressable>
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### TypeScript Configuration - tsconfig.build.json
|
|
363
|
+
|
|
364
|
+
```json
|
|
365
|
+
{
|
|
366
|
+
"extends": "../../tsconfig.base.json",
|
|
367
|
+
|
|
368
|
+
"compilerOptions": {
|
|
369
|
+
"outDir": "./dist",
|
|
370
|
+
"declaration": true,
|
|
371
|
+
"declarationMap": true,
|
|
372
|
+
"sourceMap": true,
|
|
373
|
+
"emitDeclarationOnly": false,
|
|
374
|
+
|
|
375
|
+
"module": "ESNext",
|
|
376
|
+
"target": "ES2020",
|
|
377
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
378
|
+
|
|
379
|
+
"strict": true,
|
|
380
|
+
"skipLibCheck": true,
|
|
381
|
+
"forceConsistentCasingInFileNames": true
|
|
382
|
+
},
|
|
383
|
+
|
|
384
|
+
"include": ["src"],
|
|
385
|
+
"exclude": ["node_modules", "dist", "**/*.test.ts"]
|
|
386
|
+
}
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
## Library Exports Best Practices
|
|
390
|
+
|
|
391
|
+
### ✅ DO
|
|
392
|
+
|
|
393
|
+
1. **Define explicit export fields**
|
|
394
|
+
```json
|
|
395
|
+
"exports": {
|
|
396
|
+
".": { "import": "...", "require": "...", "types": "..." },
|
|
397
|
+
"./components": { ... }
|
|
398
|
+
}
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
2. **Use named exports for tree-shaking**
|
|
402
|
+
```typescript
|
|
403
|
+
export { Button } // ✅ Tree-shakeable
|
|
404
|
+
export default Button // ❌ Prevents tree-shaking
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
3. **Re-export from barrel files**
|
|
408
|
+
```typescript
|
|
409
|
+
// src/index.ts
|
|
410
|
+
export { Button } from './Button';
|
|
411
|
+
export { Card } from './Card';
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
4. **Provide TypeScript type definitions**
|
|
415
|
+
```json
|
|
416
|
+
"types": "dist/index.d.ts",
|
|
417
|
+
"exports": { ".": { "types": "dist/index.d.ts" } }
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
5. **Document peer dependencies**
|
|
421
|
+
```json
|
|
422
|
+
"peerDependencies": {
|
|
423
|
+
"react": "^19.0.0"
|
|
424
|
+
}
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### ❌ DON'T
|
|
428
|
+
|
|
429
|
+
1. **Don't use default exports for libraries**
|
|
430
|
+
```typescript
|
|
431
|
+
❌ export default { Button, Card, Modal }
|
|
432
|
+
✅ export { Button }; export { Card }
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
2. **Don't export internal utilities**
|
|
436
|
+
```typescript
|
|
437
|
+
// src/index.ts
|
|
438
|
+
❌ export { _helpers } from './helpers'
|
|
439
|
+
✅ Only export public APIs
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
3. **Don't forget type definitions**
|
|
443
|
+
```json
|
|
444
|
+
❌ "main": "dist/index.js" (no types)
|
|
445
|
+
✅ "types": "dist/index.d.ts"
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
4. **Don't create circular exports**
|
|
449
|
+
```typescript
|
|
450
|
+
// Button.ts
|
|
451
|
+
❌ export { Card } from './Card'
|
|
452
|
+
// Card.ts
|
|
453
|
+
❌ export { Button } from './Button'
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
## Related Patterns
|
|
457
|
+
|
|
458
|
+
- [Monorepo Structure](./monorepo-structure.md) — Workspace organization
|
|
459
|
+
- [Folder Structure](./folder-structure.md) — File organization
|
|
460
|
+
- [Configuration Patterns](./configuration-patterns.md) — tsconfig.json setup
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
*Pattern extracted from production libraries: @monorepo/ui, @monorepo/hooks, mercury-ui, mercury package*
|
|
465
|
+
*Examples: package.json exports field, barrel exports, component libraries, peer dependencies*
|