You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This particular example was created using the following code, which you can use to reproduce the issue:
importparserfrom"rehype-parse"import{unified}from"unified"import{select}from"hast-util-select"import{bundleMDX}from"mdx-bundler"/** * Takes some html string and returns the hast equivalent */consttoHast=(html)=>unified().use(parser).parse(html).children[0].children[1].children[0]/** * Rehype plugin that injects the following html inside * a <p> node: * `<data-lsp />` */constplugin=()=>{return(root)=>{consthastNode=toHast("<data-lsp />")constnode=select("p",root)node.children.push(hastNode)}}construn=async()=>{constmd=`Example mdx`const{ code }=awaitbundleMDX({source: md,xdmOptions: (options)=>{options.rehypePlugins=[plugin]returnoptions},})console.log(code)}awaitrun()
Problem description:
I tried to compile the above code using just xdm and it faced no issues, so it may be something that happens after that.
Suggested solution:
I'm not sure. The error message is a bit cryptic, so it's hard to tell if the issue is with the code that esbuild receives or somewhere else.
I should also point out that replacing - with _ or other characters "solves" the issue.
The text was updated successfully, but these errors were encountered:
mdx-bundler
version: 8.0.0node
version: v16.13.0yarn
version: 1.22.17Hast nodes with
-
in theirtagName
causesmdx-bundler
to crash.What you did
I created a rehype plugin that injects hast elements into the tree. These elements happen to have
tagName
s with slashes in them (e.g.<my-tag />
).What happened
mdx-bundler
crashes with the following error:Reproducing the error
The following Hast tree is an example that causes it to crash:
This particular example was created using the following code, which you can use to reproduce the issue:
Problem description:
I tried to compile the above code using just
xdm
and it faced no issues, so it may be something that happens after that.Suggested solution:
I'm not sure. The error message is a bit cryptic, so it's hard to tell if the issue is with the code that
esbuild
receives or somewhere else.I should also point out that replacing
-
with_
or other characters "solves" the issue.The text was updated successfully, but these errors were encountered: