fix(next-mdx): preserve MDX metadata in webpack#94983
Open
mturac wants to merge 1 commit into
Open
Conversation
276c91a to
bd04e27
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Teach
@next/mdxto pass app-router MDX files throughnext-swc-loaderwith the React Server Components bundle layer when webpack is used.This keeps MDX pages that export
metadataclassified as Server Components instead of being rejected as Client Components.Why
The documented app-router MDX pattern supports
export const metadata, but under webpack the custom MDX rule reused the default SWC loader without the RSC bundle layer. That madeapp/page.mdxfail duringnext build --webpackwith:How
@next/mdxwebpack rules.bundleLayer: "rsc"only when that loader isnext-swc-loader.metadataexport and assert the rendered<title>.Fixes #91735
Testing
pnpm build-allHEADLESS=true pnpm test-start-webpack test/e2e/app-dir/mdx/mdx.test.ts -t "should work in initial html"HEADLESS=true pnpm test-start-webpack test/e2e/app-dir/mdx/mdx.test.tsHEADLESS=true pnpm test-start-turbo test/e2e/app-dir/mdx/mdx.test.tsnode --check packages/next-mdx/index.jspnpm prettier --check packages/next-mdx/index.js test/e2e/app-dir/mdx/mdx.test.ts test/e2e/app-dir/mdx/app/page.mdxpnpm --filter @next/mdx pack-for-isolated-testsgit diff --check