Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remark-mdx does not work with remark@13 #1341

Closed
MatthewCaseres opened this issue Nov 18, 2020 · 4 comments
Closed

remark-mdx does not work with remark@13 #1341

MatthewCaseres opened this issue Nov 18, 2020 · 4 comments
Labels
📦 area/deps This affects dependencies 💪 phase/solved Post is done 🧑 semver/major This is a change 🦋 type/enhancement This is great to have

Comments

@MatthewCaseres
Copy link

Subject of the issue

I am unable to replicate the "Transform Content section of the documentation. https://mdxjs.com/advanced/transform-content

Your environment

  • Windows 10
  • see package.json in repo
  • node v12.18.2

Steps to reproduce

https://github.com/MatthewCaseres/mdx-reproduction

Expected behaviour

I was trying to follow the example here: https://mdxjs.com/advanced/transform-content. I was expecting there to exist a leaf of type import as is shown in the docs

Actual behaviour

image

@MatthewCaseres MatthewCaseres added 🐛 type/bug This is a problem 🙉 open/needs-info This needs some more info labels Nov 18, 2020
@wooorm
Copy link
Member

wooorm commented Nov 18, 2020

Thanks for the reproduction, @MatthewCaseres!

remark@13 does not work with remark-mdx yet. You can either downgrade to use remark@12 for now. Or you can use @mdx-js/mdx directly, which includes remark-mdx and supports passing remarkPlugins.
What to do, depends on what you want to do!

@MatthewCaseres
Copy link
Author

Thanks! I'm trying to build a plugin and it seems like I can iterate and check my work faster with a node script. In my current nextjs project I have to stop and restart the server to rebuild the MDXAST and I can't output the transformed stuff to a file for inspection.

I might only need the markdown nodes (I'm modifying headers), I was just surprised I couldn't reproduce the docs. Thanks for the speedy reply!

@wooorm
Copy link
Member

wooorm commented Nov 18, 2020

A node script can also use mdx-js/mdx!

@wooorm wooorm changed the title Unable to replicate "Transform Content" section from documentation website. remark-mdx does not work with remark@13 Nov 18, 2020
@ChristianMurphy ChristianMurphy linked a pull request Dec 1, 2020 that will close this issue
1 task
wooorm added a commit that referenced this issue Dec 11, 2020
This updates MDX to use and support remark@13, which comes with a new internal
parser (micromark), and supports CommonMark.
See <https://github.com/remarkjs/remark/releases/tag/13.0.0> for more
information.
In short, this means MDX parses markdown closer to what folks expect.
And it means all latest plugins work (again).

But it also means that parsing MDX syntax (JSX, expressions, ESM) got an update.
See: <https://github.com/micromark/micromark-extension-mdxjs> and
<https://github.com/syntax-tree/mdast-util-mdx> for the syntax.
In short, this means MDX parsing is now JavaScript-aware: import/exports are
actually parsed for being valid JavaScript.
Expressions previously counted braces, but now can include braces in strings or
comments or whatnot.
This also means we can drop Babel (in a future PR) because we already have a
JavaScript AST.

This also deprecates the packages `remark-mdxjs` (which is now the default in
`remark-mdx`), `remark-mdx-remove-exports`, and `remark-mdx-remove-imports`.

Related to GH-704.
Related to GH-1041.

Closes GH-720.
Closes GH-1028.
Closes GH-1050.
Closes GH-1081.
Closes GH-1193.
Closes GH-1238.
Closes GH-1283.
Closes GH-1316.
Closes GH-1318.
Closes GH-1341.
wooorm added a commit that referenced this issue Dec 15, 2020
This updates MDX to use and support remark@13, which comes with a new internal
parser (micromark), and supports CommonMark.
See <https://github.com/remarkjs/remark/releases/tag/13.0.0> for more
information.
In short, this means MDX parses markdown closer to what folks expect.
And it means all latest plugins work (again).

But it also means that parsing MDX syntax (JSX, expressions, ESM) got an update.
See: <https://github.com/micromark/micromark-extension-mdxjs> and
<https://github.com/syntax-tree/mdast-util-mdx> for the syntax.
In short, this means MDX parsing is now JavaScript-aware: import/exports are
actually parsed for being valid JavaScript.
Expressions previously counted braces, but now can include braces in strings or
comments or whatnot.
This also means we can drop Babel (in a future PR) because we already have a
JavaScript AST.

This also deprecates the packages `remark-mdxjs` (which is now the default in
`remark-mdx`), `remark-mdx-remove-exports`, and `remark-mdx-remove-imports`.

Related to GH-704.
Related to GH-1041.

Closes GH-720.
Closes GH-1028.
Closes GH-1050.
Closes GH-1081.
Closes GH-1193.
Closes GH-1238.
Closes GH-1283.
Closes GH-1316.
Closes GH-1318.
Closes GH-1341.
Closes GH-1367.

Reviewed-by: Christian Murphy <[email protected]>
@wooorm
Copy link
Member

wooorm commented Dec 18, 2020

Hi all! I’m going to close this as it landed on the main, the (now default) branch we’re using to gear up to the MDX@2 release.

The reason is so that it’s more clear which issues still need to be solved already and don’t require further work.

Expect another next release soonish, which might include it, or maybe it’s already released as a beta!

For more info, see #1041.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 area/deps This affects dependencies 💪 phase/solved Post is done 🧑 semver/major This is a change 🦋 type/enhancement This is great to have
Development

Successfully merging a pull request may close this issue.

2 participants