MDX app bundle bloating and global scope problems #25069
-
MDX currently shoehorns imports into the app bundle, and adds all imports to the global scope (causing imports to need to be namespaced to avoid clashing). When the new webpack APIs land we should leverage them to improve some of the rough edges around gatsby-plugin-mdx. This is also related to how Related issues reporting bugs
Related PRs for APIs |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 2 replies
-
Sounds great! Really excited for any and all improvements to MDX! Is this a |
Beta Was this translation helpful? Give feedback.
-
API is generic and other plugins (or sites directly) can use it (if there is need for it) - there are slightly more details / context / discussion about this in #18689 . But this issue is about
Not tied to MDX 2.0 functionally. We might bundle those if both MDX 2.0 and webpack api changes will require us to make breaking changes in plugin to do 1 major release instead of 2 in short period of times. |
Beta Was this translation helpful? Give feedback.
-
There is an issue when Steps to reproduce:
The build fails with the following error: /src/pages/page-2.mdx: pragma and pragmaFrag cannot be set when runtime is automatic.
> 1 | import * as React from 'react'
| ^
2 | /* @jsx mdx */
3 | import { mdx } from '@mdx-js/react';
4 | /* @jsx mdx */
File: src/pages/page-2.mdx This only effects mdx pages in |
Beta Was this translation helpful? Give feedback.
-
I think I'm hitting the prob described in #29122 I change this: To this: and the old import causes an error: Are there any way to disable the gatsby-plugin-mdx cache? or known workaround? Thanks! |
Beta Was this translation helpful? Give feedback.
-
The "bundle everything in mdx" issue is quite a big gotcha. I am migrating as much content as possible out of MDX to avoid getting a massive app bundle. |
Beta Was this translation helpful? Give feedback.
-
#27416 still not work |
Beta Was this translation helpful? Give feedback.
-
I was only considering image imports with #35028 but that commit could also do the same thing for .md files. |
Beta Was this translation helpful? Give feedback.
-
Hi! We merged #35650 which means that a new major version of The original issue is fixed 🎉
The new version splits bundles and thus supports all the niceties of tree-shaking and scoping. It uses the MDX webpack loader under the hood so it can split the components, scope etc. by MDX file. |
Beta Was this translation helpful? Give feedback.
Hi!
We merged #35650 which means that a new major version of
gatsby-plugin-mdx
will be released on August 16. You can already try it out by installinggatsby-plugin-mdx@next
&gatsby@next
.The original issue is fixed 🎉
The new version splits bundles and thus supports all the niceties of tree-shaking and scoping. It uses the MDX webpack loader under the hood so it can split the components, scope etc. by MDX file.