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
Global MDX components do not work when MDX is used via a theme with NPM. #26541
Comments
can confirm i face same issue components are not getting mounted in build on github pages with actions please check build logs on the theme repository Chronoblog/gatsby-theme-chronoblog#56 |
I have the same issue, I'm pretty sure it's because of different versions of mdx co-living: gatsby uses the pre-release of mdx (2.0.0) while my theme uses 1.x.. The mdx components context is probably not the same (inspecting the renderer shows an empty components context). |
ccing @laurieontech and @pieh, they might know what's going on here! |
It is a wild guess, but this seems related: system-ui/theme-ui#1130 I hade a similar issue and fixed it by adding the following to "resolutions": {
"@mdx-js/react": "1.6.16"
} My dependencies currently contain: "dependencies": {
"@mdx-js/mdx": "^1.6.16",
"@mdx-js/react": "^1.6.16",
} |
My current workaround is to copy Here is what is really happening otherwise:
|
Think that is the use, I will check around in my repository and theme, I just left it like it because I couldn't see the issue only when deploying on GitHub pages. As I tested with my local package-lock.json file and also a yarn-lock file with deployments on render it worked fine so I just pushed a yarn-lock and left to worry about it another day. |
Thanks for opening the issue! This is in fact a resolution problem related to multiple versions of MDX. It's a problem we're aware of but limited in solving because it's really up to the package manager. The options are to use I'm going to close this for now but please let me know if you're still seeing this issue after trying the above. |
The issue isn't about us not using yarn, it's about the users of gatsby themes using mdx that are really confused because there is no error showing. I do think there are solutions:
Both would make sure only one mdx version is used. I don't think this issue should be closed like this. It's a pretty big deal, especially since mdx@2 isn't released yet. |
You're absolutely right that it's a papercut in its current state. The best solution may be to prevent the version of MDX that comes with gatsby now from being used/potentially clashing. The PR I've opened should be sufficient. |
I also managed to resolve this by making |
I'm unsure if this is a Gatsby or MDX issue so it is cross posted with MDX mdx-js/mdx#1223
Description
I'm running into an issue where we add components to MDX global scope but those components don't render in the page if the theme is installed via NPM, the compnents work fine if the theme is installed via Yarn.
We publish a theme (
gatsby-theme-minimal
) to a tag on Github viagitpkg
. This theme configures MDX viagatsby-plugin-mdx
, configures pages and provides a component for rendering MDX files.Several additional components are added to the
<MDXProvider>
in the theme:However when we install with
npm
in thereproduction
folder we see this on the/test/
page:We also see the following message in the console:
Installing with
yarn
in the reproduction folder produces this on the/test/
page:Steps to reproduce
I have created a minimal reproduction at https://github.com/patrickarlt/gatsby-mdx-theme-reproduction-issue
cd reproduction
npm install
gatsby develop
/test/
gatsby clean
package-lock.json
andnode_modules
yarn install
gatsby develop
/test/
The theme is published via
gitpkg
to a tag on the reproduction repo.Actual/Expected result
The MDX page should render the same regardless on installation via Yarn/NPM.
Environment
The text was updated successfully, but these errors were encountered: