question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Breaking change in v2.2.0 of MDX Loader

See original GitHub issue

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I’m using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn 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

  1. Use @docusaurus/mdx-loader in a plugin/app pre 2.2.0
  2. Upgrade to 2.2.0
  3. 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:closed
  • Created 10 months ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
sean-perkinscommented, Nov 8, 2022

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!

0reactions
slorbercommented, Dec 7, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found