content-collections icon indicating copy to clipboard operation
content-collections copied to clipboard

Bugs: Next.js v16 compatibility of `createContentCollectionPlugin`

Open wottpal opened this issue 1 month ago • 4 comments

Hey there 👋

After updating to Next.js v16 we get several minor content-collections related issues. The core functionality works, but:

  1. We get a little type issue in next.config.ts:
Image

Forcing it like nextConfig = withContentCollections(nextConfig) as NextConfig fixes it for us right now.

  1. When using scripts with bun --bun … the content-collections compilation occurs twice:
Image

Without --bun it only compiles once. Might be bun-related ofc, but maybe not 🤷‍♂️

wottpal avatar Nov 13 '25 13:11 wottpal

Sorry for the delay. I was on vacation. Which version of the next adapter are you using?

sdorra avatar Nov 17 '25 18:11 sdorra

Image

Also, addition to the first issue: If I try to await (which the type error seems to indicate), I get:

> Build error occurred
Error: require() cannot be used on an ESM graph with top-level await. Use import() instead. To see where the top-level await comes from, use --experimental-print-required-tla.

wottpal avatar Nov 18 '25 09:11 wottpal

The type error looks like your nextConfig variable has the type NextConfig, but the content collections plugin returns Promise<Partial<NextConfig>>, which is totally fine as the result (export) of next.config.ts. I think the easiest fix for the problem is to just export the result of withContentCollections directly.

sdorra avatar Nov 19 '25 07:11 sdorra

Can you provide a sample repository for the bun problem?

sdorra avatar Nov 19 '25 07:11 sdorra