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

Vite: Use mdx2 babel pre-processing #20241

Merged
merged 1 commit into from
Dec 14, 2022
Merged

Vite: Use mdx2 babel pre-processing #20241

merged 1 commit into from
Dec 14, 2022

Conversation

IanVS
Copy link
Member

@IanVS IanVS commented Dec 14, 2022

Issue:

What I did

This incorporates storybookjs/mdx2-csf#30 into the vite builder, removing the use of the vite react-plugin, freeing us to support vite 3 and 4!

Note: we'll want to update the version of mdx2-csf once the referenced PR is merged / released.

How to test

I tested this out by creating a react sandbox, and testing both build and dev. HMR even seems to work in dev!

@IanVS IanVS added maintenance User-facing maintenance tasks builder-vite labels Dec 14, 2022
@ndelangen
Copy link
Member

This is awesome!

@@ -46,33 +30,16 @@ export function mdxPlugin(options: Options): Plugin {
},
});

const mdxCode = String(
const code = String(
await compile(src, {
skipCsf: !isStorybookMdx(id),
...mdxLoaderOptions,
Copy link
Member

Choose a reason for hiding this comment

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

You're missing jsxOptions

Copy link
Member Author

Choose a reason for hiding this comment

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

Where should they come from? Is this something we want the user to be able to set? If so, why?

Copy link
Member

@ndelangen ndelangen Dec 14, 2022

Choose a reason for hiding this comment

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

Yeah, I recon we want to get them from a similar place as mdxCompilerOptions: from a preset value.

Would you like me to pick that up? I can likely get that done by end-of-day.

@shilman
Copy link
Member

shilman commented Dec 14, 2022

@IanVS @ndelangen this is great. merging this for now and @ndelangen you can take that in a separate PR

@shilman shilman merged commit ed10c5e into next Dec 14, 2022
@shilman shilman deleted the vite/mdx-2-without-plugin branch December 14, 2022 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builder-vite maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants