Skip to content
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

Support MDXv2 #377

Merged
merged 5 commits into from
Jun 29, 2022
Merged

Support MDXv2 #377

merged 5 commits into from
Jun 29, 2022

Conversation

joshwooding
Copy link
Collaborator

@joshwooding joshwooding commented May 14, 2022

Fixes #234
Fixes #391
Fixes #398

To enable experimental MDX2 in a project, follow this guide: https://gist.github.com/shilman/6ff2d7e18db8846e8fc552fb432ae4f6

@joshwooding joshwooding requested a review from IanVS May 14, 2022 19:14
@joshwooding joshwooding marked this pull request as draft May 14, 2022 19:14
@@ -68,6 +68,7 @@ const INCLUDE_CANDIDATES = [
'react-is',
'react-textarea-autosize',
'react',
'react/jsx-runtime',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MDX2 needed this

async transform(code, id, ssr) {
if (id.endsWith('.mdx')) {
// @ts-ignore
const { compile } = await import('@storybook/mdx2-csf');
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the "main" file is used the types don't match

Copy link
Member

@IanVS IanVS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. I tested out preact with both mdx1 and 2, and both worked. I also doublechecked that transclusion of other mdx files into mdx stories is working.

I pushed up a few small changes:

  • Fixed prettier formatting that was failing in CI
  • Removed the explicit mdx dependency from preact
  • Added @storybook/mdx2-csf to the examples using it, to avoid confusion if anyone else uses those as a guide.
  • Removed the force-install workarounds from the readme, since those are no longer needed. \o/

@IanVS IanVS merged commit 345b942 into main Jun 29, 2022
@IanVS IanVS deleted the support-mdx2 branch June 29, 2022 03:00
noFouc(),
injectExportOrderPlugin,
// We need the react plugin here to support MDX.
Copy link

@emosheeep emosheeep Aug 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshwooding @IanVS Sorry for bothering, but i just found an inevitable exception when i start my vue3 project without using any mdx file with @storybook/builer-vite@1.0.38 or laster.
截屏2022-08-26 13 00 26
the web page crashed due to this problem, which was fixed by adding some lines in main.js:

async viteFinal(config) {
  // ignore react plugins
  config.plugins = config.plugins.flat().filter(p => !p.name.includes('react'))
  return config
}

i didn't use any mdx features. but I need to ignore the react plugins, which made me confused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants