Fix cache warming and static params for metadata images with top-level await (#95790)
Extracted from https://github.com/vercel/next.js/pull/95468 and arguably
the main fix there.
We need to add code to wait for top-level awaits in two cases:
- If a metadata module (like `opengraph-image.tsx`) is slow to evaluate,
cache warming wouldn't "wait" for it, and then the actual build would
fail with `Unexpected cache miss after cache warming phase`. This is
fixed with placing `instrumentModuleGetter` around them.
- If the evaluation is fast but still async (e.g. `await readFile` on a
large font), the build passes but the segment collector reads the module
too early, doesn't see `generateStaticParams`, and so the image becomes
dynamic instead of prerendered. The fix is `await ensureUserland` before
looking at exports.
Remaining callsites are wrapped so we don't add more bugs like this, but
it's not strictly required now because they are already being awaited
elsewhere. I've done this for consistency.
New tests fail before the fix.