withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
46.74k stars 2.48k forks source link

🐛 BUG: Astro MDX doesn't allow comments #3792

Closed okikio closed 2 years ago

okikio commented 2 years ago

What version of astro are you using?

^1.0.0-beta.61

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

pnpm

What operating system are you using?

Linux

Describe the Bug

Using this comment syntax causes bugs,

{/* comment */} 

image

Note: the MDX vscode extension by default uses <!-- comments -->

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-5mawuq?file=src/pages/index.mdx

Participation

okikio commented 2 years ago

cc @natemoo-re

natemoo-re commented 2 years ago

So I did look into this a bit. Looks like esbuild is stripping out comments but leaving the {} intact which is invalid JSX. Still thinking through a fix... esbuild doesn't allow comment preservation AFAICT.

okikio commented 2 years ago

This seems like a bug in esbuild

natemoo-re commented 2 years ago

Just picked this back up and it seems to be working, not sure what was going on in the older version.

https://stackblitz.com/edit/github-qfawez?file=src%2Fpages%2Findex.mdx