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.

Forwarding options to remarkPlugins/rehypePlugins can break them

See original GitHub issue

Subject of the issue

Currently @mdx-js/mdx forwards its options to every plugin in remarkPlugins and rehypePlugins, which can easily lead to some of them breaking. Is there a specific reason why we’re doing this? If it’s a behavior left over from something else, I can remove it.

Your environment

  • Name and version of operating system: macOS 10.14.4
  • Names and version of required packages: 1.0.18
  • Version of node, npm, yarn, or names and versions of browser: yarn 1.16.0

Steps to reproduce

import mdx from '@mdx-js/mdx'
import detectFrontmatter from 'remark-frontmatter'

const content = `
---
title: Hello World!
---
`

mdx(content, {
  remarkPlugins: [
    detectFrontmatter,
  ],
})

Expected behaviour

remark-frontmatter shouldn’t be getting unexpected options.

Actual behaviour

Options from the mdx() call get forwarded to remark-frontmatter, which thinks we’re passing the definition for detecting frontmatter, but the shape of the object doesn’t satisfy its criteria so it crashes.

Temporary workaround

Passing undefined as an option to all plugins, which results in default, i.e. expected behavior.

mdx(content, {
  remarkPlugins: [
    [detectFrontmatter, undefined],
  ],
})

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
wooormcommented, May 13, 2019

I suspect there is a teeny tiny extremely slim chance someone depends and we’d break something if we patch it up. If we do a major (or wait for one) the chance of someone being on ^1.0.0 and trying to use a plugin that breaks is much much much larger.

I also think @silvenon has a good enough understanding of remark and MDX that he can figure out what happened rather easily, but I don’t think many other persons using MDX can figure out what’s failing, resulting in a pretty bad debugging experience.

Therefore I propose patching this up instead of a major release. We can add a note about this in releases though.

0reactions
johnocommented, May 13, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

Transforming Markdown with Remark & Rehype - ryanfiller.com
Writing custom plugins to give extra powers to Markdown syntax using the Unified ecosystem.
Read more >
Improving My Next.js MDX Blog - Lee Robinson
MDX Plugins. mdx-bundler allows you to extend remark and rehype, providing external plugins to hook into the compilation process. Some plugins I ...
Read more >
mdast-util-to-hast - npm
It turns HTML into markdown. The remark plugin remark-rehype wraps this utility to also turn markdown to HTML at a higher-level (easier) ...
Read more >
markdown – CSS-Tricks
Mermaid goes well with Markdown because it presents itself as just another fenced code block, only using the mermaid language syntax set.
Read more >
Rewriting my blog with Next.js - Dimitrios Lytras
I've been using Gatsby since v0, and it's perfect for my use case. ... I just don't like the GraphQL layer and its...
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