AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

MDX `Export Const Metadata` Fails To Build With Webpack In 16.2.0 (Regression From 16.1.6)

Next.js 16.2.0 introduces a webpack-specific regression that incorrectly flags MDX files exporting `metadata` as client components, causing build failures for a documented pattern. Turbopack and previous versions are unaffected.

highConfidence 65%Next.jsTurbopackRoute HandlersAffected V16.2.0

Origin Analysis

In Next.js 16.2.0, the webpack module-layer detection logic was updated and now misclassifies `.mdx` files that export `metadata` as client components. The MDX loader output does not include the expected server-component markers, causing the new client-component export validation to throw a false positive.
1. Clone https://github.com/minamicode/my-mdx-repro 2. Run `npm install` 3. Run `npm run build` 4. Build fails with: `You are attempting to export "metadata" from a component marked with "use client", which is disallowed.`

Fixing Code Block

Edge Case Audit

This hotfix bypasses export validation for all MDX files regardless of their actual client/server status (unless `'use client'` is detected textually). In future versions, if the MDX compiler adds `'use client'` automatically or the file is imported into a client component, the metadata export may be silently allowed, leading to runtime errors. For rollback, revert the patch and downgrade to 16.1.6 until an official fix is released.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state