kentcdodds / mdx-bundler

🦤 Give me MDX/TSX strings and I'll give you back a component you can render. Supports imports!
MIT License
1.78k stars 75 forks source link

Importing Components that import other Components #212

Open dominik-sfl opened 1 year ago

dominik-sfl commented 1 year ago

What you did:

I am importing a component into my mdx blog post:

import Imper from "./Imper";

Hello!

<Imper />

When Imper does not rely on any other components from my own project, this works. However, when I import other components inside Imper (that are not provided as globals), I get this error:

Server Error
SyntaxError: Unexpected token '<'

This error happened while generating the page. Any console logs will be displayed in the terminal window.

I am not sure whether this is intended or what I am doing wrong here exactly? I would've expected mdx-bundler to automatically import all other components that my Imper component relies on?

I do know that providing those components as globals fixes this problem, but I do not want to have a ton of globals that I might not re-use a lot.

xiaojundebug commented 1 year ago

Did you solve it?

yswrepos commented 7 months ago

Adding my +1 here, I'm facing the same issue.