fix(next-mdx): pin .mdx server pages to the rsc bundleLayer - metadata exports build under webpack#95057
Draft
icyJoseph wants to merge 1 commit into
Draft
fix(next-mdx): pin .mdx server pages to the rsc bundleLayer - metadata exports build under webpack#95057icyJoseph wants to merge 1 commit into
icyJoseph wants to merge 1 commit into
Conversation
…ata exports build under webpack
Contributor
Stats cancelledCommit: 6575da2 |
Contributor
Failing test suitesCommit: 6575da2 | About building and testing Next.js
Expand output● hmr-intercept-routes › should update intercept routes via HMR |
| '@mdx-js/react', | ||
| require.resolve('./mdx-components.js'), | ||
| ] | ||
| // App Router `.mdx` pages are Server Components, so pin the SWC pass to |
Contributor
There was a problem hiding this comment.
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.
An App Router
.mdxpage that doesexport const metadata = {…}fails to build with webpack:You are attempting to export "metadata" from a component marked with "use client"@next/mdxregisters its.mdxrule with the layer-agnosticoptions.defaultLoaders.babel, so the SWC pass runs withbundleLayer: undefined. That makesisReactServerLayerfalse, and as of 16.2 the RSC metadata guard rejects any non-react-server module that exportsmetadata, even without an actual"use client"directive. A.tsxpage in the same dir is unaffected because Next's core layered rules only match/\.(tsx|ts|js|cjs|mjs|jsx)$/, so.mdxnever gets therscloader and falls through to the layer-less one.One possible fix is to pin the MDX SWC pass to the
rscbundle layer (App Router.mdxpages are Server Components), during the server compile step.Also added
app/metadata/page.mdx+ an assertion intest/e2e/app-dir/mdx/mdx.test.ts(runs for both mdx-rs and non-rs) verifying the exportedmetadatarenders.Fixes #91735