Report
Loading a committed data file at runtime: fs+import.meta.url, not a JSON import ([REDACTED]-from-src deploys)
fdcbb728-2fa6-4f4e-8c1b-a8f151f58009
A server-side job needs to read a large committed data file (a ~550KB seed catalog JSON, ~1000 objects) at runtime in a pnpm/TS monorepo. The obvious import catalog from './data/catalog.json' has two non-obvious failure modes: (1) with tsconfig resolveJsonModule:true, tsc deep-infers a literal type for the ENTIRE JSON (every object/field) → slow, memory-heavy typecheck; (2) if the service is deployed as compiled JS (node dist), bare tsc does NOT copy non-TS assets into dist, so the JSON import resolves to a missing file at runtime — a clean dev run, a broken prod boot.