-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Latest released version fails to build .mdx stories #557
Comments
This should be fixed by #556, there are just some details I need to work out regarding |
fixes #557 I found that mdx was not working correctly here, and @valentinpalkovic realized my fallback in Storybook 7 wasn't either (storybookjs/storybook#20823). It was because we used to inject the mdx compiler into the source code that we get back from the `@storybook/mdx1-csf` compiler, but we lost that in https://github.com/storybookjs/builder-vite/pull/548/files#diff-f2dfc4dfa9074d77a728a88e6629a1d66be8a0765cab8562526cd00fbae910e5L6. This re-introduces it, with a bit better of a guarantee that the correct version is going to be loaded, by starting from inside `@storybook/mdx1-csf`. I've also pinned mdx1-csf here, in case the import is moved from the loader to the compiler, as @shilman has suggested doing. We'll need to adjust this if that happens.
Released in 0.4.1 |
Hi @IanVS , thanks for the quick fix! The stories now indeed render, but is still seems not entirely ok. Also seeing an error that React is not defined when I'm using a custom React component in the mdx story:
I've updated my branch in https://github.com/gvdp/builder-vite/tree/fixed-example-version/examples/react-18 with an example of what breaks in our Storybook. The story |
Hi it looks like your branch might be a bit behind, I'd suggest updating it with the changes I released last night in 0.4.2, and please let me know if the react issue is fixed. I do need to look into the styles, though. |
Hi @IanVS! Thanks for this fix for .mdx files. In dev it works correctly, with small error about React version. But we are getting an error in published storybook. The .MDX story is default and comes with storybook And full error message is: |
You're right I didn't look at the updated examples, my bad. Updated the branch now though and initially it failed because the
then I changed it to use |
@flysubmarina that could potentially be caused by multiple versions of react being used on the page. You can try searching your node_modules for I might suggest trying out mdx2 in this case. You can follow this guide: https://gist.github.com/shilman/6ff2d7e18db8846e8fc552fb432ae4f6 (the |
@gvdp I'm not sure this is the best way to troubleshoot this, since this repo is a bit awkward with the use of yarn portals and whatnot. Are you still having problems in your main app when upgrading to version 0.4.2? If so, maybe you can create a new project similar to your own that reproduces the issue? |
@IanVS yes still having the problem. I created a separate reproduction in a clean repo where I copied the react-18 example but only kept the failing story: https://github.com/gvdp/reproduction-react-18-builder-issue If you run |
Thanks, I see what you mean. I'll try to look into it as soon as I can. If anyone else wants to help out that would also be appreciated, because I don't have a lot of time right now to devote to this. |
Thanks a lot, it helped.Yes, I had several react packages. After migration to 7 Beta, I can confirm that MDX works in production.I 🎉🎉🎉 |
I am also having issues with latest Storybook and Vite. It would fail to render Configure.mdx complaining about a line in the css. Installed @mdx-js/react and now i get this. Failed to fetch dynamically imported module: http://localhost:6006/src/stories/Configure.mdx |
What version of
vite
are you using?4.0.4
System info and storybook versions
System:
OS: macOS 12.5.1
CPU: (10) arm64 Apple M1 Pro
Binaries:
Node: 16.15.0 - ~/.volta/tools/image/node/16.15.0/bin/node
Yarn: 3.1.1 - ~/.volta/tools/image/yarn/1.22.17/bin/yarn
npm: 8.5.5 - ~/.volta/tools/image/node/16.15.0/bin/npm
Browsers:
Chrome: 109.0.5414.119
Firefox: 109.0
Safari: 15.6.1
npmPackages:
@storybook/addon-a11y: ^6.5.9 => 6.5.16
@storybook/addon-docs: ^6.5.9 => 6.5.16
@storybook/addon-essentials: ^6.5.9 => 6.5.16
@storybook/builder-vite: 0.4.0 => 0.4.0
@storybook/react: ^6.5.9 => 6.5.16
@storybook/test-runner: 0.1.0 => 0.1.0
Describe the Bug
I upgraded my Storybook to
"@storybook/builder-vite": "0.4.0"
and noticed an error with with my Mdx stories:I tried to look at the example for react in the repo here but that also doesn't work for me. I reproduced the bug by forking this repo and using the npm released version
0.4.0
instead of the linked package.On the branch in my forked repo if I just run
yarn install
and thenyarn storybook
I get the error message that the incorrect react plugin is used:If I then change the
@vitejs/plugin-react-swc
dependency to just@vitejs/plugin-react
I can start the storybook, the "main" stories work fine but if I open the Introduction page I get the following error:I assume this has something to do with the latest release and the changes in #548 , but I don't know if maybe I've configured something wrong or if it's really a bug.
Link to Minimal Reproducible Example
https://github.com/gvdp/builder-vite/tree/fixed-example-version/examples/react-18
Participation
The text was updated successfully, but these errors were encountered: