web-infra-dev / rspress

🦀💨 A fast Rspack-based static site generator.
https://rspress.dev
MIT License
1.44k stars 133 forks source link

[Bug]: passing `props` onto `.mdx` component breaks rendering #1555

Open JounQin opened 1 week ago

JounQin commented 1 week ago

Version

System: OS: macOS 15.1 CPU: (10) arm64 Apple M1 Max Memory: 5.05 GB / 64.00 GB Shell: 5.9 - /bin/zsh Browsers: Chrome: 130.0.6723.92 Safari: 18.1 npmPackages: @rspress/core: ^1.35.3 => 1.35.3

Details

import Test from '../components/Test.mdx'

<Test />

<Test color="red" />

<Test /> renders normally, <Test color="red" /> results:

Uncaught Error: Expected component `Test` to be defined: you likely forgot to import, pass, or provide it.

https://mdxjs.com/docs/using-mdx/#props

Reproduce link

https://codesandbox.io/p/devbox/xenodochial-david-52cfy2?file=%2Fdocs%2Findex.mdx%3A5%2C21

Reproduce Steps

  1. run npm i && npm dev
  2. check the error logs
Timeless0911 commented 1 week ago

Currently, the processing of nested mdx is simple flatting, so this feature is not supported yet.

https://github.com/web-infra-dev/rspress/blob/main/packages/core/src/node/utils/flattenMdxContent.ts