Regression in webpack build process for MDX metadata export in Next.js 16.2.0.
The issue involves a regression in Next.js 16.2.0 where exporting metadata from MDX components fails to build with webpack, despite being documented as supported. The same code works with Turbopack and in Next.js 16.1.6. The fix likely requires understanding both MDX and Next.js's webpack configuration.
https://github.com/minamicode/my-mdx-repro
git clone https://github.com/minamicode/my-mdx-repronpm installnpm run buildCurrent behavior Build fails with webpack in Next.js 16.2.0 with the following error: You are attempting to export "metadata" from a component marked with "use client", which is disallowed.
Expected behavior Build succeeds. This pattern is explicitly documented as supported in the Next.js MDX guide: https://nextjs.org/docs/app/guides/mdx The same code builds successfully in:
Next.js 16.1.6 with webpack Next.js 16.2.0 with Turbopack
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:53:31 PST 2026; root:xnu-12377.91.3~2/RELEASE_ARM64_T8103
Available memory (MB): 8192
Available CPU cores: 8
Binaries:
Node: 22.9.0
npm: 11.10.1
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 16.2.0 // Latest available version is detected (16.2.0).
eslint-config-next: N/A
react: 19.2.4
react-dom: 19.2.4
typescript: 5.9.3
Next.js Config:
output: N/A
Markdown (MDX), Webpack
next build (local), Other (Deployed)
This pattern is explicitly documented as supported in the Next.js MDX guide: https://nextjs.org/docs/app/guides/mdx
The bug is webpack-specific — the same code builds successfully with Turbopack in 16.2.0. It also built successfully with webpack in 16.1.6, suggesting this is a regression introduced in 16.2.0.
Workaround: downgrade to [email protected]
Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!