Closed ihupoo closed 3 years ago
Cannot reproduce with latest version of Vite and this plugin.
i used <Demo test=“{test:’22’}” />
and
everything is ok...
seems that the “
and ‘
is different
Can you reproduce in this example? https://github.com/brillout/vite-plugin-mdx/blob/master/examples/react/src/Hello.mdx
i am confused...
follow the example in vite-plugin-mdx/examples/react
, it runs well when i use <Counter test='{"a":"dd"}' />
in Hello.mdx
。 Then i upgrade @mdx-js/mdx
to ^2.0.0-next.9
, it also runs well ...
I try to remove "vite-plugin-mdx": "file:../../"
and use npm version "vite-plugin-mdx": "^3.3.2"
, the error happens when i open the browser. However there seems no break changes between them
This is my environment
system: window10
/// package.json
"dependencies": {
"@mdx-js/mdx": "^2.0.0-next.9",
"@mdx-js/react": "^1.6.22",
"@vitejs/plugin-react-refresh": "^1.1.0",
"react": "^17.0.0",
"react-dom": "^17.0.0",
"vite": "^2.0.0-beta.65",
"vite-plugin-mdx": "^3.3.2"
}
/// Hellow.mdx
..... <Counter test='{"a":"dd"}' />
Your @mdx-js/react
version should match @mdx-js/mdx
version.
Sorry, i forgot to use the lastest https://github.com/brillout/vite-plugin-mdx.git
. I tried again by the following step.
yarn
in root and yarn build
to create a dist packagecd ./examples/react
and run yarn
to installHellow.mdx
--><Counter test='{"a":"dd"}' />
yarn dev
and open the browsersystem: window10
oh, i think i know why.
The @mdx-js/mdx
in "v2.0.0-next.8" transfer <Counter test='{sdf:"sdf"}' />
to <Counter test="{sdf:"sdf"}" mdxType="Counter" />
'/* @jsx mdx */\nimport { Counter } from './Counter.jsx';\n\nconst makeShortcode = name => function MDXDefaultShortcode(props) {\n console.warn("Component " + name + " was not imported, exported, or provided by MDXProvider as global scope")\n return <div {...props}/>\n};\n\nconst MDXLayout = "wrapper"\nexport default function MDXContent({\n components,\n ...props\n}) {\n return <MDXLayout {...props} components={components} mdxType="MDXLayout">\n <Counter test="{sdf:"sdf"}" mdxType="Counter" />\n </MDXLayout>;\n}\n\n;\nMDXContent.isMDXComponent = true;'
And in v2.0.0-next.9
, it changes to <Counter test="{sdf:\\"sdf\\"}" mdxType="Counter" />
'/* @jsxRuntime classic */\n/* @jsx mdx */\n/* @jsxFrag mdx.Fragment */\nimport {Counter} from './Counter.jsx';\nconst MDXLayout = "wrapper";\nfunction MDXContent({components, ...props}) {\n return <MDXLayout components={components} {...props}><Counter test="{sdf:\\"sdf\\"}" mdxType="Counter" /></MDXLayout>;\n}\nMDXContent.isMDXComponent = true;\nexport default MDXContent;\n'
Sadly, the esbuild does not think it is a correct string in loader 'jsx' and throw the error
Subscribe to https://github.com/evanw/esbuild/issues/1115
I add the following code in my mdx
and went to an error
is the bug between the esbuild transform and mdx-js ?