Closed Ayc0 closed 2 years ago
Correct, those are not supported. It's a small deviation from jsx that not a lot of people know even exists, and not a lot of people use, that significantly makes parsing jsx harder.
Closing as this is not planned, and rather complex. If you (or anyone stumbling on this) is interested in working on it, I can help advise, the work will have to be done in https://github.com/micromark/micromark-extension-mdx-jsx. You’d need to test a bit how different parsers (TS, Babel) handle comments in JSX, but essentially I believe it’s similar to whitespace, which is allowed almost everywhere. Some examples in the Babel playground.
Even more complex is that we retain comments in the tree, but we can’t do that for comments in JSX tags. Can that be solved? This is also a good reason not to support them: if they could be parsed, people would try to use // eslint-ignore ...
comments in there, but we can likely not make that work.
Initial checklist
Affected packages and versions
MDX 2
Link to runnable example
No response
Steps to reproduce
If you open https://mdxjs.com/playground/ and try this code:
The compiler will crash with this error:
And if you try:
it'll crash with
Expected behavior
In MDX 1, the block comment syntax wasn't supported, but line one was (it followed JSX's spec):
Would it be possible add back this syntax in MDX 2?
Actual behavior
It crashes for all form of comments
Runtime
Not relevant
Package manager
Not relevant
OS
Not relevant
Build and bundle tools
Not relevant