
The Hidden Cost of Import Chains
You open a seemingly simple file in your codebase: // src/api/user-profile.ts (52 lines) import { validateUser } from ' ./validators ' ; import { formatResponse } from ' ./formatters ' ; import { logRequest } from ' ./logger ' ; export async function getUserProfile ( userId : string ) { validateUser ( userId ); const user = await fetchUser ( userId ); logRequest ( ' getUserProfile ' , userId ); return formatResponse ( user ); } Looks clean, right? Just 52 lines, three imports, straightforward logic. But when your AI assistant tries to understand this file, here's what actually gets loaded into its context window: src/api/user-profile.ts 52 lines 1,245 tokens └─ validators.ts 89 lines 2,134 tokens └─ validation-rules.ts 156 lines 3,721 tokens └─ error-types.ts 41 lines 982 tokens └─ formatters.ts 103 lines 2,456 tokens └─ format-utils.ts 78 lines 1,867 tokens └─ logger.ts 67 lines 1,603 tokens └─ log-transport.ts 124 lines 2,967 tokens └─ log-formatter.ts 91 lines 2,178 tokens Total: 80
Continue reading on Dev.to
Opens in a new tab
![Join a list of strings with '[' as prefix, ']' as suffix, and ',' as delimiter using streams.](/_next/image?url=https%3A%2F%2Fmedia2.dev.to%2Fdynamic%2Fimage%2Fwidth%3D800%252Cheight%3D%252Cfit%3Dscale-down%252Cgravity%3Dauto%252Cformat%3Dauto%2Fhttps%253A%252F%252Fdev-to-uploads.s3.amazonaws.com%252Fuploads%252Farticles%252F9qcm43evuzjr784iwng7.png&w=1200&q=75)
