The Friday Vercel refused my merge
Friday April 10th, late afternoon. I merge to main a Stripe integration that opens a payment webhook endpoint. Vercel pushes the preview build automatically, and three minutes later the icon turns red. I click. Build-time stack trace:
Error: STRIPE_SECRET_KEY missing at Object.<anonymous> (/.next/server/chunks/lib_stripe.js:9:11) at Module._compile (node:internal/modules/cjs/loader:1376:14)
Enter fullscreen mode
Exit fullscreen mode
Production works, it has the env var. The preview doesn't have the Stripe secret — I had forgotten to push it into the Vercel preview env. Operator error on my side, fine. But one question remains: why does next build crash at module load on a module that's never supposed to run during a static build?
Why next build runs the top level of my modules
The answer fits in one line in the Next.js docs, and it's easy to miss. The Next.js compiler doesn't just transform TypeScript into JavaScript.…