kentcdodds / mdx-bundler

šŸ¦¤ Give me MDX/TSX strings and I'll give you back a component you can render. Supports imports!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Importing Components that import other Components

dominik-sfl opened this issue Ā· comments

  • mdx-bundler version: 9.2.1
  • node version: 16.19.0
  • npm version: 8.19.3

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.

Did you solve it?