You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running storybook build, the process fails with error messages that lead me to believe that the MDX compilation package is not working correctly:
× Expected ';', '}' or <eof>
╭─[/Users/xxx/Documents/DEV/storybook-vite-2/src/stories/Configure.mdx:33:1]
33 │
34 │ <Meta title="Configure your project" />
35 │
36 │ ╭─▶ <div className="sb-container">
37 │ │ <div className='sb-section-title'>
38 │ │ # Configure your project
39 │ │
40 │ │ Because Storybook works separately from your app, you'll need to configure it for your specific stack and setup. Below, explore guides for configuring Storybook with popular frameworks and tools. If you get stuck, learn how you can ask for help from our community.
41 │ │ </div>
42 │ │ <div className="sb-section">
43 │ │ <div className="sb-section-item">
44 │ │ <img
45 │ │ src={Styling}
46 │ │ alt="A wall of logos representing different styling technologies"
47 │ │ />
48 │ │ <h4 className="sb-section-item-heading">Add styling and CSS</h4>
49 │ │ <p className="sb-section-item-paragraph">Like with web applications, there are many ways to include CSS within Storybook. Learn more about setting up styling within Storybook.</p>
50 │ │ <a
51 │ │ href="https://storybook.js.org/docs/react/configure/styling-and-css"
52 │ │ target="_blank"
53 │ │ >Learn more<RightArrow /></a>
54 │ │ </div>
55 │ │ <div className="sb-section-item">
56 │ │ <img
57 │ │ src={Context}
58 │ │ alt="An abstraction representing the composition of data for a component"
59 │ │ />
60 │ │ <h4 className="sb-section-item-heading">Provide context and mocking</h4>
61 │ │ <p className="sb-section-item-paragraph">Often when a story doesn't render, it's because your component is expecting a specific environment or context (like a theme provider) to be available.</p>
62 │ │ <a
63 │ │ href="https://storybook.js.org/docs/react/writing-stories/decorators#context-for-mocking"
64 │ │ target="_blank"
65 │ │ >Learn more<RightArrow /></a>
66 │ │ </div>
67 │ │ <div className="sb-section-item">
68 │ │ <img src={Assets} alt="A representation of typography and image assets" />
69 │ │ <div>
70 │ │ <h4 className="sb-section-item-heading">Load assets and resources</h4>
71 │ │ <p className="sb-section-item-paragraph">To link static files (like fonts) to your projects and stories, use the
72 │ │ `staticDirs` configuration option to specify folders to load when
73 │ │ starting Storybook.</p>
74 │ │ <a
75 │ │ href="https://storybook.js.org/docs/react/configure/images-and-assets"
76 │ │ target="_blank"
77 │ │ >Learn more<RightArrow /></a>
78 │ │ </div>
79 │ │ </div>
80 │ │ </div>
81 │ │ </div>
82 │ ├─▶ <div className="sb-container">
· ╰─── ─────────
· ╰──── This is the expression part of an expression statement
83 │ <div className='sb-section-title'>
84 │ # Do more with Storybook
╰────
It seems like MDX is being interpreted as Javascript.
I set up a minimal reproduction example, see below. I setup the project using npm create vite@latest, selecting react and TS+SWC. I then ran npx storybook@latest init in the project. I then initialised Lingui in the project, using the @lingui/vite-plugin and the @vitejs/plugin-react-swc package.
Running storybook dev -p 6006 works fine. It's just the build that fails.
I don't know if the problem comes from storybook or vite or lingui, but I decided to open the issue here in hopes of someone smarter than me pointing me in the right direction.
The bug also happens when I pass an empty plugins array into @vitejs/plugin-react-swc like this:
Same issue on a run-of-the-mill Storybook. Removing the plugins option from Vite's react() block fixed it.
vite 5.1.1 (latest)
@storybook/react-vite 7.6.15 (latest)
@vitejs/plugin-react-swc 3.5.0
As a workaround, since Storybook builds with Vite mode === "production" && process.env.NODE_ENV === "production", you can add an if statement based on that to not set the plugins key in that case (assuming you only need the plugins in dev)
Describe the bug
When running
storybook build
, the process fails with error messages that lead me to believe that the MDX compilation package is not working correctly:It seems like MDX is being interpreted as Javascript.
This is what my
.storybook/main.ts
looks like:This is what my
vite.config.ts
looks like:Package versions (fresh install):
I set up a minimal reproduction example, see below. I setup the project using
npm create vite@latest
, selecting react and TS+SWC. I then rannpx storybook@latest init
in the project. I then initialised Lingui in the project, using the@lingui/vite-plugin
and the@vitejs/plugin-react-swc
package.Running
storybook dev -p 6006
works fine. It's just the build that fails.I don't know if the problem comes from storybook or vite or lingui, but I decided to open the issue here in hopes of someone smarter than me pointing me in the right direction.
The bug also happens when I pass an empty plugins array into @vitejs/plugin-react-swc like this:
That leads me to believe that somewhere someone is incorrectly merging the plugins and overwriting the MDX plugin, thus disabling MDX compilation.
To Reproduce
https://github.com/luke-m/storybook-vite-lingui-example
System
Additional context
No response
The text was updated successfully, but these errors were encountered: