@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.
Files changed (83) hide show
  1. package/dist/content/checklists/ship-test-loop.md +16 -0
  2. package/dist/content/checklists/unified-agent-bundle-validation.md +8 -0
  3. package/dist/content/examples/ship-test-loop.md +13 -0
  4. package/dist/content/examples/unified-agent-bundle-bootstrap.md +8 -0
  5. package/dist/content/guides/animation-performance.md +30 -0
  6. package/dist/content/guides/post-create-onboarding.md +113 -0
  7. package/dist/content/patterns/api/api-routes.md +314 -0
  8. package/dist/content/patterns/api/error-handling.md +311 -0
  9. package/dist/content/patterns/database/drizzle-schema.md +280 -0
  10. package/dist/content/patterns/database/migrations.md +365 -0
  11. package/dist/content/patterns/database/query-organization.md +537 -0
  12. package/dist/content/patterns/database/relations.md +450 -0
  13. package/dist/content/patterns/deployment/build-configuration.md +452 -0
  14. package/dist/content/patterns/deployment/ci-cd-patterns.md +448 -0
  15. package/dist/content/patterns/deployment/environment-config.md +380 -0
  16. package/dist/content/patterns/deployment/hosting-setup.md +425 -0
  17. package/dist/content/patterns/project/configuration-patterns.md +459 -0
  18. package/dist/content/patterns/project/documentation-org.md +506 -0
  19. package/dist/content/patterns/project/folder-structure.md +398 -0
  20. package/dist/content/patterns/project/library-exports.md +465 -0
  21. package/dist/content/patterns/project/monorepo-structure.md +500 -0
  22. package/dist/content/patterns/routing/dynamic-routes.md +221 -0
  23. package/dist/content/patterns/routing/file-based-routing.md +186 -0
  24. package/dist/content/patterns/routing/route-groups.md +429 -0
  25. package/dist/content/patterns/state/persistence-middleware.md +521 -0
  26. package/dist/content/patterns/state/selector-hooks.md +538 -0
  27. package/dist/content/patterns/state/store-organization.md +539 -0
  28. package/dist/content/patterns/state/zustand-patterns.md +348 -0
  29. package/dist/content/patterns/styling/component-styling.md +468 -0
  30. package/dist/content/patterns/styling/responsive-patterns.md +398 -0
  31. package/dist/content/patterns/styling/theme-configuration.md +426 -0
  32. package/dist/content/patterns/styling/uniwind-setup.md +412 -0
  33. package/dist/content/prompts/continue-development.md +27 -0
  34. package/dist/content/prompts/create-expo-super-stack.md +29 -0
  35. package/dist/content/prompts/fix-seo.md +29 -0
  36. package/dist/content/prompts/onboard-new-expo-app.md +11 -0
  37. package/dist/content/prompts/prepare-deploy.md +29 -0
  38. package/dist/content/prompts/project-research-plan.md +29 -0
  39. package/dist/content/prompts/review-expo-project.md +29 -0
  40. package/dist/content/prompts/run-doctor.md +30 -0
  41. package/dist/content/prompts/ship-test-loop.md +24 -0
  42. package/dist/content/reference/create-expo-stack-uniwind.md +29 -0
  43. package/dist/content/reference/doctor-dogfood.md +42 -0
  44. package/dist/content/reference/mcp-sdk-transport.md +30 -0
  45. package/dist/content/reference/package-ci-patterns.md +24 -0
  46. package/dist/content/reference/reference-repo-evacuation.md +31 -0
  47. package/dist/content/resource-index.json +67 -0
  48. package/dist/content/rules/app-folder-architecture.md +13 -0
  49. package/dist/content/rules/env-hygiene.md +9 -0
  50. package/dist/content/rules/seo-metadata.md +7 -0
  51. package/dist/content/rules/ssr-safety.md +9 -0
  52. package/dist/content/skills/api-routes.md +33 -0
  53. package/dist/content/skills/continue-development.md +31 -0
  54. package/dist/content/skills/debugging.md +31 -0
  55. package/dist/content/skills/deployment.md +32 -0
  56. package/dist/content/skills/dev-server-management.md +31 -0
  57. package/dist/content/skills/env-vars.md +32 -0
  58. package/dist/content/skills/expo-router-architecture.md +33 -0
  59. package/dist/content/skills/expo-ssr-safety.md +32 -0
  60. package/dist/content/skills/plugin-creation.md +41 -0
  61. package/dist/content/skills/production-server-patterns.md +31 -0
  62. package/dist/content/skills/project-onboarding.md +31 -0
  63. package/dist/content/skills/research-plan-intake.md +31 -0
  64. package/dist/content/skills/seo-metadata.md +31 -0
  65. package/dist/content/skills/super-stack-startup.md +31 -0
  66. package/dist/content/skills/uniwind-theming.md +32 -0
  67. package/dist/index.d.ts +46 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +369 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/patterns/index.d.ts +78 -0
  72. package/dist/patterns/index.d.ts.map +1 -0
  73. package/dist/patterns/index.js +264 -0
  74. package/dist/patterns/index.js.map +1 -0
  75. package/dist/prompts/index.d.ts +35 -0
  76. package/dist/prompts/index.d.ts.map +1 -0
  77. package/dist/prompts/index.js +270 -0
  78. package/dist/prompts/index.js.map +1 -0
  79. package/dist/skills/index.d.ts +3 -0
  80. package/dist/skills/index.d.ts.map +1 -0
  81. package/dist/skills/index.js +2 -0
  82. package/dist/skills/index.js.map +1 -0
  83. package/package.json +50 -0
@@ -0,0 +1,452 @@
1
+ # Build Configuration Pattern
2
+
3
+ ## Description
4
+
5
+ Build configuration involves setting up Expo's Metro bundler and native build systems to optimize app compilation, control output formats, manage dependencies, and enable platform-specific customization. This includes `metro.config.js`, `app.json` build settings, and build hooks.
6
+
7
+ ## When to Use
8
+
9
+ **Configure builds when:**
10
+ - ✅ Setting up Metro bundler for React Native
11
+ - ✅ Customizing native code compilation
12
+ - ✅ Optimizing bundle size and performance
13
+ - ✅ Managing dependencies during build
14
+ - ✅ Enabling/disabling features per platform
15
+ - ✅ Setting up development vs. production builds
16
+ - ✅ Configuring EAS Build settings
17
+
18
+ ## Core Concepts
19
+
20
+ **Build Configuration Layers:**
21
+ ```
22
+ 1. metro.config.js → Metro bundler configuration
23
+ 2. app.json → Expo app configuration + build settings
24
+ 3. eas.json → EAS Build cloud build configuration
25
+ 4. babel.config.js → JavaScript transpilation
26
+ 5. tsconfig.json → TypeScript compilation
27
+ 6. Plugins → Expo plugins for native config
28
+ ```
29
+
30
+ **Key Build Concerns:**
31
+ 1. Module resolution and paths
32
+ 2. Asset handling and transforms
33
+ 3. Platform-specific bundling
34
+ 4. Dependency optimization
35
+ 5. Environment variable injection
36
+ 6. Native module integration
37
+
38
+ ## Code Examples
39
+
40
+ ### Metro Configuration
41
+
42
+ ```typescript
43
+ // File: metro.config.js
44
+ const { getDefaultConfig } = require('@react-native/metro-config');
45
+ const path = require('path');
46
+
47
+ const config = getDefaultConfig(__dirname);
48
+
49
+ /**
50
+ * Configure module resolution
51
+ */
52
+ config.resolver = {
53
+ ...config.resolver,
54
+ // Add path aliases
55
+ extraNodeModules: {
56
+ '@': path.resolve(__dirname, 'src'),
57
+ '@/assets': path.resolve(__dirname, 'assets'),
58
+ },
59
+ // Async requires allowed in certain directories
60
+ asyncRequireModulePath: path.resolve(__dirname, 'metro'),
61
+ // Additional source extensions
62
+ sourceExts: [
63
+ 'ts',
64
+ 'tsx',
65
+ 'js',
66
+ 'jsx',
67
+ 'json',
68
+ 'mjs',
69
+ 'cjs',
70
+ ],
71
+ };
72
+
73
+ /**
74
+ * Configure transformer options
75
+ */
76
+ config.transformer = {
77
+ ...config.transformer,
78
+ // Enable experimental stable types
79
+ unstable_allowRequireContext: true,
80
+ };
81
+
82
+ /**
83
+ * Configure watchman (file watcher)
84
+ */
85
+ config.watchman = {
86
+ ...config.watchman,
87
+ healthCheck: {
88
+ enabled: true,
89
+ },
90
+ };
91
+
92
+ module.exports = config;
93
+ ```
94
+
95
+ ### App Configuration
96
+
97
+ ```json
98
+ {
99
+ "expo": {
100
+ "name": "MyApp",
101
+ "slug": "myapp",
102
+ "version": "1.0.0",
103
+ "orientation": "portrait",
104
+ "icon": "./assets/icon.png",
105
+ "userInterfaceStyle": "light",
106
+ "newArchEnabled": false,
107
+
108
+ "splash": {
109
+ "image": "./assets/splash.png",
110
+ "resizeMode": "contain",
111
+ "backgroundColor": "#ffffff"
112
+ },
113
+
114
+ "assetBundlePatterns": ["**/*"],
115
+
116
+ "ios": {
117
+ "supportsTabletMode": true,
118
+ "bundleIdentifier": "com.mycompany.myapp",
119
+ "buildNumber": "1"
120
+ },
121
+
122
+ "android": {
123
+ "adaptiveIcon": {
124
+ "foregroundImage": "./assets/adaptive-icon.png",
125
+ "backgroundColor": "#ffffff"
126
+ },
127
+ "package": "com.mycompany.myapp",
128
+ "versionCode": 1
129
+ },
130
+
131
+ "web": {
132
+ "favicon": "./assets/favicon.png",
133
+ "output": "static",
134
+ "bundler": "metro"
135
+ },
136
+
137
+ "plugins": [
138
+ [
139
+ "expo-build-properties",
140
+ {
141
+ "ios": {
142
+ "deploymentTarget": "13.0"
143
+ },
144
+ "android": {
145
+ "minSdkVersion": 21,
146
+ "targetSdkVersion": 34,
147
+ "compileSdkVersion": 34
148
+ }
149
+ }
150
+ ]
151
+ ],
152
+
153
+ "extra": {
154
+ "eas": {
155
+ "projectId": "12345678-1234-1234-1234-123456789012"
156
+ }
157
+ }
158
+ }
159
+ }
160
+ ```
161
+
162
+ ### EAS Build Configuration
163
+
164
+ ```json
165
+ {
166
+ "build": {
167
+ "preview": {
168
+ "android": {
169
+ "buildType": "apk",
170
+ "releaseChannel": "preview"
171
+ },
172
+ "ios": {
173
+ "buildType": "simulator"
174
+ }
175
+ },
176
+ "preview2": {
177
+ "android": {
178
+ "buildType": "apk",
179
+ "gradleCommand": ":app:assembleRelease"
180
+ }
181
+ },
182
+ "production": {
183
+ "android": {
184
+ "buildType": "aab",
185
+ "releaseChannel": "production"
186
+ },
187
+ "ios": {
188
+ "buildType": "archive"
189
+ }
190
+ },
191
+ "development": {
192
+ "developmentClient": true,
193
+ "distribution": "internal"
194
+ }
195
+ },
196
+
197
+ "submit": {
198
+ "production": {
199
+ "android": {
200
+ "serviceAccount": "@env ANDROID_SERVICE_ACCOUNT",
201
+ "track": "production"
202
+ },
203
+ "ios": {
204
+ "ascAppId": "1234567890",
205
+ "appleId": "@env APPLE_ID",
206
+ "ascAppPassword": "@env ASC_APP_PASSWORD"
207
+ }
208
+ }
209
+ }
210
+ }
211
+ ```
212
+
213
+ ### Babel Configuration
214
+
215
+ ```javascript
216
+ // File: babel.config.js
217
+ module.exports = function (api) {
218
+ api.cache(true);
219
+ return {
220
+ presets: ['babel-preset-expo'],
221
+ plugins: [
222
+ // Path aliases
223
+ [
224
+ 'module-resolver',
225
+ {
226
+ extensions: ['.ts', '.tsx', '.js', '.jsx'],
227
+ alias: {
228
+ '@': './src',
229
+ '@/assets': './assets',
230
+ },
231
+ },
232
+ ],
233
+ // Class properties and private fields
234
+ '@babel/plugin-proposal-class-properties',
235
+ '@babel/plugin-proposal-private-methods',
236
+ // Dynamic imports
237
+ '@babel/plugin-syntax-dynamic-import',
238
+ ],
239
+ };
240
+ };
241
+ ```
242
+
243
+ ### TypeScript Configuration
244
+
245
+ ```json
246
+ {
247
+ "compilerOptions": {
248
+ "target": "ES2020",
249
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
250
+ "jsx": "react-jsx",
251
+ "module": "ESNext",
252
+ "moduleResolution": "bundler",
253
+ "strict": true,
254
+ "allowSyntheticDefaultImports": true,
255
+ "esModuleInterop": true,
256
+ "skipLibCheck": true,
257
+ "forceConsistentCasingInFileNames": true,
258
+ "resolveJsonModule": true,
259
+ "isolatedModules": true,
260
+ "declaration": true,
261
+ "declarationMap": true,
262
+ "sourceMap": true,
263
+
264
+ "baseUrl": ".",
265
+ "paths": {
266
+ "@/*": ["src/*"],
267
+ "@/assets/*": ["assets/*"]
268
+ }
269
+ },
270
+ "include": [
271
+ "src/**/*",
272
+ "app.json",
273
+ "metro.config.js",
274
+ "babel.config.js"
275
+ ],
276
+ "exclude": [
277
+ "node_modules",
278
+ "dist",
279
+ "build"
280
+ ]
281
+ }
282
+ ```
283
+
284
+ ### Development vs. Production Build
285
+
286
+ ```javascript
287
+ // File: metro.config.js
288
+ const { getDefaultConfig } = require('@react-native/metro-config');
289
+
290
+ const config = getDefaultConfig(__dirname);
291
+
292
+ /**
293
+ * Development-specific optimizations
294
+ */
295
+ if (process.env.NODE_ENV === 'development') {
296
+ config.transformer.minifierPath = false; // No minification
297
+ config.resolver.sourceExts = [
298
+ 'ts',
299
+ 'tsx',
300
+ 'js',
301
+ 'jsx',
302
+ 'json',
303
+ 'mjs',
304
+ ];
305
+ }
306
+
307
+ /**
308
+ * Production-specific optimizations
309
+ */
310
+ if (process.env.NODE_ENV === 'production') {
311
+ config.transformer = {
312
+ ...config.transformer,
313
+ minifierPath: 'metro-minify-uglify', // Use UglifyJS
314
+ };
315
+
316
+ config.resolver = {
317
+ ...config.resolver,
318
+ // In production, prefer compiled (lower priority on source)
319
+ resolverMainFields: ['react-native', 'browser', 'main'],
320
+ };
321
+ }
322
+
323
+ module.exports = config;
324
+ ```
325
+
326
+ ### Build Optimization
327
+
328
+ ```javascript
329
+ // File: metro.config.js
330
+
331
+ const config = getDefaultConfig(__dirname);
332
+
333
+ /**
334
+ * Optimize for bundle size
335
+ */
336
+ config.transformer.getTransformOptions = async () => ({
337
+ transform: {
338
+ experimentalImportSupport: false,
339
+ inlineRequires: true,
340
+ },
341
+ });
342
+
343
+ /**
344
+ * Configure caching
345
+ */
346
+ config.cacheVersion = '1.0.0';
347
+ config.resetCache = process.env.RESET_CACHE === 'true';
348
+
349
+ /**
350
+ * Configure serializer for web
351
+ */
352
+ config.serializer = {
353
+ ...config.serializer,
354
+ // Enable treeshaking for web
355
+ isThirdPartyModule: (module) =>
356
+ /node_modules/.test(module),
357
+ };
358
+
359
+ module.exports = config;
360
+ ```
361
+
362
+ ## Build Configuration Best Practices
363
+
364
+ ### ✅ DO
365
+
366
+ 1. **Use environment variables for secrets**
367
+ ```json
368
+ {
369
+ "extra": {
370
+ "eas": {
371
+ "projectId": "@env EAS_PROJECT_ID"
372
+ }
373
+ }
374
+ }
375
+ ```
376
+
377
+ 2. **Configure different build profiles**
378
+ ```json
379
+ {
380
+ "build": {
381
+ "development": { "developmentClient": true },
382
+ "preview": { "distribution": "internal" },
383
+ "production": { "distribution": "store" }
384
+ }
385
+ }
386
+ ```
387
+
388
+ 3. **Optimize for production**
389
+ ```javascript
390
+ // Production builds use minification
391
+ if (process.env.NODE_ENV === 'production') {
392
+ config.transformer.minifierPath = 'metro-minify-uglify';
393
+ }
394
+ ```
395
+
396
+ 4. **Document build settings**
397
+ ```javascript
398
+ // metro.config.js
399
+ /**
400
+ * Metro configuration for React Native
401
+ *
402
+ * Development: Fast refresh, no minification
403
+ * Production: Minified, optimized for size
404
+ */
405
+ ```
406
+
407
+ ### ❌ DON'T
408
+
409
+ 1. **Don't hardcode secrets in config**
410
+ ```javascript
411
+ // ❌ WRONG - Secrets in code
412
+ {
413
+ "apiKey": "sk-1234567890abcdef"
414
+ }
415
+
416
+ // ✅ RIGHT - Use environment variables
417
+ {
418
+ "apiKey": "@env API_KEY"
419
+ }
420
+ ```
421
+
422
+ 2. **Don't miss platform-specific settings**
423
+ ```json
424
+ // ❌ WRONG - No platform config
425
+ { "bundleIdentifier": "com.myapp" }
426
+
427
+ // ✅ RIGHT - Platform-specific IDs
428
+ {
429
+ "ios": { "bundleIdentifier": "com.myapp" },
430
+ "android": { "package": "com.myapp" }
431
+ }
432
+ ```
433
+
434
+ 3. **Don't ignore dependency conflicts**
435
+ ```javascript
436
+ // ❌ WRONG - Unresolved conflicts
437
+ // Conflicting peer dependencies not addressed
438
+
439
+ // ✅ RIGHT - Resolve in metro config
440
+ config.resolver.extraNodeModules = { ... };
441
+ ```
442
+
443
+ ## Related Patterns
444
+
445
+ - [CI/CD Patterns](./ci-cd-patterns.md) — Automated builds and deployment
446
+ - [Environment Configuration](./environment-config.md) — Environment setup
447
+ - [Hosting Setup](./hosting-setup.md) — Deployment targets
448
+
449
+ ---
450
+
451
+ *Pattern extracted from production repositories: time2pay, core-monorepo, expo-super-template*
452
+ *Files: metro.config.js, app.json, eas.json, babel.config.js, tsconfig.json*