mdx-js / mdx

Markdown for the component era
https://mdxjs.com
MIT License
17.77k stars 1.14k forks source link

Fix playground AST views w/ clone #2315

Closed Jokcy closed 1 year ago

Jokcy commented 1 year ago
const capture = (name) => () => (tree) => {
        file.data[name] = tree
      }

In our playground page, we use capture in remarkPlugins and rehypePlugins to capture the ast on different step. But after generate the mdast or hast, the evaluate function will keep going and later plugins will do some mutation on the ast object, which result to what we showed to user of mdast/hast in not correct on that step. So I just structuredClone the ast as a snapshot when capture and then save to file.

When compile <A b={<B><C /></B>}></A>, this mr generate <C /> as JSXElement, the old version generate as CallExpression with callee of _jsx.

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mdx ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 26, 2023 4:33am
codecov-commenter commented 1 year ago

Codecov Report

Patch and project coverage have no change.

Comparison is base (7504cfb) 100.00% compared to head (94026da) 100.00%.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2315 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 22 22 Lines 2177 2177 ========================================= Hits 2177 2177 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

wooorm commented 1 year ago

Thank you! :)