Breaking change in v2.2.0 of MDX Loader
See original GitHub issueHave you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Prerequisites
- I’m using the latest version of Docusaurus.
- I have tried the
npm run clear
oryarn clear
command. - I have tried
rm -rf node_modules yarn.lock package-lock.json
and re-installing packages. - I have tried creating a repro with https://new.docusaurus.io.
- I have read the console error message carefully (if applicable).
Description
The 2.2.0 release for Mermaid introduced a breaking change to the type for Options
in @docusaurus/mdx-loader
.
This commit/line: https://github.com/facebook/docusaurus/commit/9c92a79d23533a61f3ad1bf3ea4d0889f0e2710f#diff-545a046200b390be351720ea1e83af42ec7ed096a4351213383e1550467d8cdcR66
markdownConfig
should be an optional type or have a default value assigned, to align with semver.
Reproducible demo
No response
Steps to reproduce
- Use
@docusaurus/mdx-loader
in a plugin/app pre 2.2.0 - Upgrade to 2.2.0
- Observe: Build breaks with error:
[ERROR] TypeError: Cannot read properties of undefined (reading 'mermaid')
at Object.mdxLoader (/Users/ben/flagsmith/docs/node_modules/@docusaurus/mdx-loader/lib/loader.js:115:43)
at LOADER_EXECUTION (/Users/ben/flagsmith/docs/node_modules/loader-runner/lib/LoaderRunner.js:132:14)
at runSyncOrAsync (/Users/ben/flagsmith/docs/node_modules/loader-runner/lib/LoaderRunner.js:133:4)
at iterateNormalLoaders (/Users/ben/flagsmith/docs/node_modules/loader-runner/lib/LoaderRunner.js:250:2)
at /Users/ben/flagsmith/docs/node_modules/loader-runner/lib/LoaderRunner.js:223:4
at /Users/ben/flagsmith/docs/node_modules/webpack/lib/NormalModule.js:834:15
at eval (eval at create (/Users/ben/flagsmith/docs/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:12:1)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
at runNextTicks (node:internal/process/task_queues:65:3)
at processImmediate (node:internal/timers:437:9)
Can be seen here: https://github.com/cloud-annotations/docusaurus-openapi/issues/222
Expected behavior
Breaking changes should be reserved for major release cycles. markdownConfig
should either be optional or have a default value assigned as its value.
Actual behavior
Build process breaks when upgrading to 2.2.0.
Your environment
- Docusaurus version used: v2.2.0
- Environment name and version (e.g. Chrome 89, Node.js 16.4): Chrome Version 107.0.5304.87 (Official Build) (arm64), Node.js v18.11.0
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): Mac OS 13.0
Self-service
- I’d be willing to fix this bug myself.
Issue Analytics
- State:
- Created 10 months ago
- Comments:8
Top Results From Across the Web
Migrating from v1 to v2 - MDX
You need to make changes when upgrading some mdx-js/* packages. In this section we will discuss the needed changes for each package. If...
Read more >feat(mdx-loader): upgrade to MDX 2.0 #8288 - GitHub
Public API breaking changes: Notable private API changes: mdx-loader requires the options.markdownConfig to be provided (see also docs: ...
Read more >MDX 2 Breaking changes and gatsby-plugin-mdx v4 (Content)
Both MDX 2 and v4 of the plugin are major releases and inline with semantic versioning guidelines, breaking changes are to be expected....
Read more >What's new in MDX v2 - LogRocket Blog
The long-awaited version 2 of MDX has been released — see what's new in ... Preact, and Vue apps to MDX v2; Possible...
Read more >@mdx-js/loader - npm
Webpack loader for MDX. Latest version: 2.2.1, last published: 8 days ago. Start using @mdx-js/loader in your project by running `npm i ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok cool. I think we can close out this issue then 👍 I have a viable change to the plugin and others that run into a similar issue can come across this issue as a reference.
Thanks for the quick follow-up!
handled in https://github.com/facebook/docusaurus/pull/8419
note this retro compatible change will be reverted in v3 (part of https://github.com/facebook/docusaurus/pull/8288) so make sure to upgrade your plugin code. In the future we want the loader to receive the global site markdown config so we do want an error if it’s not provided.