nextra icon indicating copy to clipboard operation
nextra copied to clipboard

Skip `compileMdx` step for regular `md` files

Open dj-stormtrooper opened this issue 3 years ago • 3 comments

Hi, first of all thanks for the great framework, really enjoyed it!

Issue

At the moment both md and mdx files are treated as MDX and get prepared by compileMdx (@mdx-js) process. This leads to 2 problems:

  1. increased memory consumption. For ~2000 small md files (sample file) we need over 8GB for next build which make it impossible to build on Vercel for example
  2. we have a lot of black-listed words and symbols in md (e.g. import, export, {, <) which make it hard to develop or migrate documentation

Solution

Opt-out / opt-in option for skipping MDX processing for md files and use simple md-html convertion byremark-html instead

-- OR --

Workaround to get this to work. Perhaps custom webpack loader for different types of files (might be too abtract IMO) or any other way to exclude md files from MDX processing and apply simple md-html conversion without extracting a lot of internal implementation details of Nextra

Thanks!

dj-stormtrooper avatar Aug 18 '22 14:08 dj-stormtrooper

An option to configure extensions sounds good to me, by default it can be ["md", "mdx"] but you can set it to ["mdx"] only.

shuding avatar Aug 18 '22 14:08 shuding

Sounds good, can we keep the other Nextra features applied to md-files with this approach? (layouts, ssg, etc.)

dj-stormtrooper avatar Aug 18 '22 14:08 dj-stormtrooper

Oh I misunderstood what you meant — but that makes total sense still. The layouts and built-in components still rely on MDX compiler but we can look into a more performant solution for Markdown files.

shuding avatar Aug 18 '22 14:08 shuding