-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Vite: Support legacyMdx1 fallback flag #20823
Conversation
@@ -17,6 +17,7 @@ | |||
- [Babel mode v7 exclusively](#babel-mode-v7-exclusively) | |||
- [Importing plain markdown files with `transcludeMarkdown` has changed](#importing-plain-markdown-files-with-transcludemarkdown-has-changed) | |||
- [7.0 feature flags removed](#70-feature-flags-removed) | |||
- [Story context is prepared before for supporting fine grained updates](#story-context-is-prepared-before-for-supporting-fine-grained-updates) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This did not have a TOC before my vscode addon picked it up and added it. But I think this change isn't the most general for all users, so I moved it from the top to lower on the list. I honestly have a bit of a hard time understanding what users need to do based on the migration instructions, but maybe others do.
# Conflicts: # code/lib/builder-vite/src/plugins/mdx-plugin.ts # code/yarn.lock
@valentinpalkovic I've fixed the conflicts here. Let me know if you have any concerns, it would be great to get this in soon, to achieve parity with the Webpack flag. |
@IanVS I followed the test instructions in the other PR for a vite sandbox. I have adjusted the name of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Guess I should have. :( I did things the same way as webpack, so I'm confused why it's not working, but I'll take a look. Thanks. |
I'm seeing that the mdx1-csf transform is adding pragmas of ' return mdx(MDXLayout, _extends({}, layoutProps, props, {\n' +
' components: components,\n' +
' mdxType: "MDXLayout"\n' +
' }), mdx(Meta, {\n' +
' title: "Example/Introduction",\n' +
' mdxType: "Meta"\n' +
' }), mdx("style", null, `\n' + Which results in a |
OK, I figured this out. the MDX1 compiler for Webpack uses a loader which injects the mdx compiler (https://github.com/storybookjs/mdx1-csf/blob/d58cb032a8902b3f24ad487b6a7aae11ba8b33f6/loader.js#L12-L16), which we used to do in the vite plugin too, but removed for mdx2 because it was no longer necessary. So, this re-introduces the injecting of the mdx compiler, being sure to grab it from the right version of |
@IanVS does the fix of adding the MDX compiler belong in the |
I think ideally you're right, adding the mdx import should probably be done in the |
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.
# Conflicts: # code/yarn.lock
It is handled internally to mdx1-csf now.
Issue: #
What I did
Pair to #20747, adds support for legacyMdx1 feature flag to vite projects.
How to test
Same as webpack projects listed in the PR above. Note I didn't actually test it myself.
Checklist
MIGRATION.MD
Maintainers
make sure to add the
ci:merged
orci:daily
GH label to it.["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]