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 { logRequ...

Source: DEV Community
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: 801 lines, 19,153 tokens Your