-
Notifications
You must be signed in to change notification settings - Fork 76
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
feat: switch to xdm #9
Conversation
Co-authored-by: Titus <tituswormer@gmail.com>
I couldn't figure out what was up with the |
Oh, and I tested this with remix and it totes works (when remix isn't compiling away the dynamic import, this has been reported). |
@all-contributors please add @wooorm for code |
I've put up a pull request to add @wooorm! 🎉 |
🎉 This PR is included in version 3.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@wooorm Using a I'm displaying it with this: (where const Component = useMemo(() => getMDXComponent(source), [source])
return <MDXProvider components={components}>
<Component />
</MDXProvider> Is bundling or the way the client creates the component causing some issues here? For completeness my const {code} = await bundleMDX(source, {
files,
xdmOptions: (input, options) => {
options.remarkPlugins = [
remarkHighlight
]
options.providerImportSource = '@mdx-js/react'
return options
}
}) |
If I understand it correctly, I think you could side-step the const Component = useMemo(() => getMDXComponent(source), [source])
return <Component components={components} /> |
@kentcdodds is correct here: in most cases, you don’t need to provider. I prefer being explicit and passing those components. Still, it should be possible to use a provider. “Is bundling or the way the client creates the component causing some issues here?” I think so. I’m guessing that esbuild is bundling |
@kentcdodds yep that works. Its a TypeScript issue as |
Yeah, I realized that yesterday as well. Need to fix the typings |
#12 fixes the typings |
What: switch to xdm
Why: It's better than mdx-js
How: use dynamic imports which is how you maintain your own CJS-ness but import native ESMs. This is desirable for now.
Checklist: