Closed jlaramie closed 2 years ago
I think you might need to set providerImportSource:
const { code } = await bundleMDX(source, {
...,
xdmOptions: (input, options) => ({
....options,
providerImportSource: '@mdx-js/react'
})
})
I think you might need to set providerImportSource:
const { code } = await bundleMDX(source, { ..., xdmOptions: (input, options) => ({ ....options, providerImportSource: '@mdx-js/react' }) })
@souporserious I had tried this and I just updated my setup to try again and it still doesn't work. I'll update the description of this issue to include the newer versions and sample. I also tried manually wrapping the code with MDXProvider.
Also I updated the repo linked in the description with my latest test. If someone could take a look it has few direct dependencies and shows my issue.
I found the root of the issue https://github.com/mdx-js/mdx/pull/2050
After that pull request got closed I opened another one and had a bigger discussion on it all https://github.com/mdx-js/mdx/pull/2052.
If you want to override native HTML elements you'll need to provide a custom plugin that ensures they get wrapped in the components check.
{
rehypePlugins: [
() => (tree) => {
visit(tree, "mdxJsxTextElement", (node) => {
if (node.data) {
delete node.data._mdxExplicitJsx;
}
});
},
],
}
Relevant code or config
What you did:
I tried to provide my own custom components to override the default ones. Specifically these are MDX / React components like
p
andimg
and not md paragraphs and![]()
img links as these types of conversions work.What happened:
It does not seem possible to directly override a JSX native component like
img
. If I name itImg
and pass anImg
component that works.Reproduction repository:
https://github.com/jlaramie/mdx-bundler-components-override
Problem description:
Native components like
img
should be replaceable with custom componentsSuggested solution:
Not sure and still haven't figured out why this works in next-remote-mdx and not mdx-bundler
Related to: