gatsby
gatsby copied to clipboard
BREAKING CHANGE(gatsby-plugin-mdx): MDX v2
This PR replaces the old gatsby-plugin-mdx
with a new version that is powered by MDX v2.
We won't be 100% backwards compatible, but most use cases will be covered. Simplification and better performance is the overall goal.
Separate PRs
- https://github.com/gatsbyjs/gatsby/pull/35751
- https://github.com/gatsbyjs/gatsby/pull/35752
- https://github.com/gatsbyjs/gatsby/pull/35753
- https://github.com/gatsbyjs/gatsby/pull/35888
- https://github.com/gatsbyjs/gatsby/pull/35873
- https://github.com/gatsbyjs/gatsby/pull/35983
- https://github.com/gatsbyjs/gatsby/pull/35893
- https://github.com/gatsbyjs/gatsby/pull/36009
- https://github.com/gatsbyjs/gatsby/pull/36201
- https://github.com/gatsbyjs/gatsby/pull/36118
Changes:
This is a complete rewrite of the plugin, so some old features might be gone.
New features
- [x] Upgraded all dependencies including MDX to v2
- [x] Per file tree-shaking and chunking via webpack
- [x]
MDXRenderer
is no more needed. - [x] Similar or better performance than old plugin. (First tests on complex projects show similar performance)
- [x] Extended e2e tests
- [x] Simplified plugin configuration
- [x] Via the
mdxOptions
config option you can pass any configuration to@mdx-js/js
compile likeremarkPlugins
,rehypePlugins
,recmaPlugins
and more. - [x] Move away from react-test-renderer in tests
- [x] Authored in TS
Kept features
- [x]
.mdx
files fromsrc/pages
are turned into real pages - [x]
.mdx
files loaded viagatsby-source-filesystem
or as component viacreatePage
can be turned into real pages - [x] support for frontmatter (via GraphQL and page context)
- [x] excerpt & table of contents support https://github.com/gatsbyjs/gatsby/pull/35873
- [x] support for remark, rehype and most
gatsby-remark-*
plugins #35751
Removed features
- [x] (compiled) MDX code won't be available anymore within GraphQL
- [x] MD nodes are no more automatically turned into MDX
- [x] config option
defaultLayouts
is gone - [x] config option
lessBabel
is gone - [x] config option
mediaTypes
is gone - [x] config option
shouldBlockNodeFromTransformation
is gone - [x] some GraphQL data is no more available in core and have to be implemented on project level (like time to read)
Post Release ToDos
- Investigate if we could/should replace gray-matter with the recommended approach by MDX via remark-mdx-frontmatter
Closes #25068 Closes #34421 Closes #35733 Closes #35732
TODOs from other PR:
- https://github.com/gatsbyjs/gatsby/pull/35751#issuecomment-1141859593
- https://github.com/gatsbyjs/gatsby/pull/35751#discussion_r885381904
- https://github.com/gatsbyjs/gatsby/pull/35751#discussion_r885662293
I'm so excited about this! Great work @axe312ger 👏 👏
I'm so excited about this! Great work @axe312ger 👏 👏
Thanks, not easy but we are getting there 🙈
As some might follow just here: The RC is out! 🎉
https://github.com/gatsbyjs/gatsby/discussions/25068#discussioncomment-3100249