Fixing Next.js v14+ Build OOM on Vercel

In March 2024, our Next.js project started failing to build on Vercel with out-of-memory (OOM) errors after we introduced the App Router. Traditional fixes like `NODE_OPTIONS` did not help, and debugging was difficult due to limited container memory and lack of tooling. By inspecting Next.js source code, tuning `experimental.cpus` and `webpackBuildWorker`, and disabling production source maps, we…