GithubHelp home page GithubHelp logo

When importing .mdx file in a .stories.tsx file: Unexpected `FunctionDeclaration` in code: only import/exports are supported about mdx HOT 3 CLOSED

raDiesle avatar raDiesle commented on July 23, 2024
When importing .mdx file in a .stories.tsx file: Unexpected `FunctionDeclaration` in code: only import/exports are supported

from mdx.

Comments (3)

raDiesle avatar raDiesle commented on July 23, 2024

I carefully read https://mdxjs.com/docs/troubleshooting-mdx/#unexpected-type-in-code-only-importexports-are-supported
Does it mean I cannot have a stories.mdx file and import multiple mdx contents to be combined to render, anylonger with new version?

from mdx.

ChristianMurphy avatar ChristianMurphy commented on July 23, 2024

Welcome @raDiesle!

Taking a step back first.

  1. Storybook natively supports MDX in its story format https://storybook.js.org/docs/writing-docs/mdx Don't write a custom integration, use the official one used and tested by millions of other people.
  2. CRA is deprecated and no longer supported by the CRA team (source: reactjs/react.dev#5487 (comment)) consider moving to Vite, Remix, or Next.

To answer your direct question,
it's likely a configuration or a content problem.
People would also need to see the MDX you are trying to render to offer better insights.

Does it mean I cannot have a stories.mdx file and import multiple mdx contents to be combined to render, anylonger with new version?

No. MDX can still import any number of external sources.

from mdx.

raDiesle avatar raDiesle commented on July 23, 2024

Ok, thanks!

Seems like renaming to .stories removes the error of Storybook, still not clear why when debugging the builders.

from mdx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.