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.

Using mdx in @next

See original GitHub issue

I think many CRA users like myself are using mdx-js/mdx. The mdx docs for CRA setup use create-react-app-rewired, but I’ve managed just fine in CRA v1.x without ejecting or rewiring by inlining webpack loader and eslint overrides:

/* eslint-disable import/no-webpack-loader-syntax */
import Content from '!babel-loader!@mdx-js/loader!./Content.mdx';

I tried the same course of action in @2.0.0 but its not working for reasons I haven’t looked into yet. (I’ll leave details in a comment below. Raising at mdx-js may be appropriate.)

THE REASON I’m submitting this issue is to identify MDX usage as a likely reason for ejecting/rewiring in response to @Timer’s comment https://github.com/timarney/react-app-rewired/issues/162#issuecomment-418708200. The future support outlook for rewired and missing workaround for CRA@next is unfortunate for MDX users.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
jamesknelsoncommented, Dec 7, 2018

One issue with supporting MDX in the same way that SCSS is supported is that it’s rare that you’ll want to use vanilla MDX. At minimum, you’re probably going to want to add plugins to improve typography, add emoji support, and handle front matter – but you can go further and do things like add id props to titles for deep linking, generate a table of contents, etc.

I’ve tried putting together an MDX macro with all this, but can’t find a way to get recompile-on-save working, which is a bummer.

I do have MDX working with CRA@2 though, using import('!babel-loader!mdx-loader!./tutorial/make-a-blog.md') and the following .babelrc:

{
  "presets": ["react-app"]
}

Even if this isn’t supported, I feel like it’s probably the most pragmatic approach atm.

1reaction
Timercommented, Sep 29, 2018

We should ask for a @mdx-js/macro or mdx.macro package!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Features: Using MDX - Next.js
MDX is a superset of markdown that lets you write JSX directly in your markdown files. It is a powerful way to add...
Read more >
Create a Next.js and MDX blog - LogRocket Blog
Learn how to build a blog in Next.js using MDX to allow for the creation of interactive content, along with adding styles and...
Read more >
Building a Blog With Next.js and MDX | The WebStorm Blog
We're going to learn about Next.js and MDX by building a blog. We'll learn how to set up Next.js apps, generate dynamic URLs,...
Read more >
How to setup MDX in Next.js - jmagrippis
The library we'll be using is next-mdx-enhanced. It is not the official plugin by the Nextjs team, which is workable but has you...
Read more >
How to Build Your Own Blog with Next.js and MDX
next -mdx-remote does the background compilation of the MDX files by allowing them to be loaded within Next.js' getStaticProps or ...
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