pmndrs / pmndrs/docs

next-mdx-remote 6 drops object-valued JSX props: <Sandpack files={{…}}> compiles with zero files

Open
#554 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
119
Forks
100
Avg merge
35m
Merged PRs (30d)
2

Description

Summary

Since the bump to next-mdx-remote 6.0.0 (ff889a1e), object-valued JSX attributes written in MDX no longer reach the component. <Sandpack files={{ '/App.tsx': '…' }} /> is compiled with files === {}.

This has two different symptoms depending on whether the block also sets template:

  1. Hard build failure when there is no template. SandpackProvider throws Error: [sandpack-react]: without a template, you must pass at least one file, which aborts the whole static export.
  2. Silent data loss when there is a template. The page builds, and the Sandpack renders with none of the authored files.

folder="…" is unaffected — those files are read from disk in the RSC and still resolve.

Impact

Symptom 1 is currently breaking downstream docs deploys. react-three-fiber's "Build documentation and deploy to GitHub Pages" has failed on every run since 2026-07-30 (its first push to master after the bump); the last green run was 2026-05-06. Example failure, on /getting-started/introduction: https://github.com/pmndrs/react-three-fiber/actions/runs/30643760945

Symptom 2 applies to this repo's own docs. Every files={{…}} example in docs/authoring/sandpack.mdx also passes template="react-ts", so they build without error and render empty — which is likely why CI here has stayed green.

Note that consumers run the published ghcr.io/pmndrs/docs:3 image via build.yml@v3, so a fix needs a new image publish to reach them.

Reproduction

git clone https://github.com/pmndrs/docs && cd docs
git clone https://github.com/pmndrs/react-three-fiber ../r3f && cp -R ../r3f/docs extdocs
pnpm install
MDX=extdocs OUTPUT=export DIST_DIR=extdocs/out BASE_PATH="" \
  HOME_REDIRECT=/getting-started/introduction \
  NEXT_PUBLIC_LIBNAME="React Three Fiber" \
  MDX_BASEURL=https://github.com/pmndrs/react-three-fiber/raw/master/docs \
  pnpm build
Error occurred prerendering page "/getting-started/introduction"
Error: [sandpack-react]: without a template, you must pass at least one file
Export encountered an error on /[...slug]/page: /getting-started/introduction, exiting the build.

The block that throws is the TypeScript example in docs/getting-started/introduction.mdx, which passes files={{ '/styles.css': …, '/index.tsx': … }} and no template.

Diagnosis

Logging the props Sandpack actually receives, at the top of src/components/mdx/Sandpack/Sandpack.tsx:

With next-mdx-remote 6.0.0 — inline files arrive empty, folder still resolves:

{"folder":null,"propsFilesKeys":[],"resolvedFileKeys":[],"template":null}
{"folder":"…/getting-started/basic-example-sandpack","propsFilesKeys":[],"resolvedFileKeys":["/index.jsx","/styles.css"],"template":null}

With next-mdx-remote 5.0.0, same source and same MDX:

{"folder":null,"propsFilesKeys":["/styles.css","/index.tsx"],"resolvedFileKeys":["/styles.css","/index.tsx"],"template":null}

Building this repo's own docs (MDX=docs) on 6.0.0 shows symptom 2 — the authored files are gone, but template keeps it from throwing:

{"folder":null,"propsFilesKeys":[],"resolvedFileKeys":[],"template":"react-ts"}

What isolates it

Source next-mdx-remote Result
v3 tip 6.0.0 (lockfile) fails on /getting-started/introduction
b06e5458 (2026-05-07, pre-bump) 5.0.0 25/25 pages
v3 tip 5.0.0 (pinned) 25/25 pages

Same source at the tip passes or fails purely on the next-mdx-remote major, which points at the upgrade rather than at anything in src/.

I have not worked out which v6 change drops the attribute — whether compileMDX needs different options now, or whether this is an upstream regression worth reporting there. Happy to dig further or put up a PR if you have a preferred direction.

Environment

  • pmndrs/docs v3 @ 6469729f, and b06e5458 for the passing comparison
  • Node 20.19.0, pnpm 10.28.1, macOS arm64
  • next-mdx-remote 6.0.0 vs 5.0.0, @codesandbox/sandpack-react 2.20.0 (unchanged across both)
  • MDX under test: react-three-fiber master docs

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/components/mdx/Sandpack/Sandpack.tsx and reproduce the failure using the provided pnpm build command. Compare next-mdx-remote 6.0.0 with 5.0.0 and inspect the compileMDX path, plus the examples in docs/getting-started/introduction.mdx and docs/authoring/sandpack.mdx. Done means inline files reach Sandpack, both affected cases build correctly, and the published image path is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
markdown, nextjs, typescript
Domain
build-system, documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.