Closed jannikbuscha closed 3 years ago
xdm works now with vue 3: https://github.com/wooorm/xdm#vue. This project will support it in ± 4 weeks maybe.
xdm works now with vue 3: https://github.com/wooorm/xdm#vue. This project will support it in ± 4 weeks maybe.
Thank you 👍
i saw that you have customized the docs and i wanted to test now already and i get this error with the vue.config.js configuration currently:
and i wanted to test now already
The docs have been updated but the code has not been published.
Are you using Vue 3 with Vue CLI?
Can you swap out @mdx-js/loader
with xdm/webpack.cjs
to see if that still fails, and if so, make a reproduction?
and i wanted to test now already
The docs have been updated but the code has not been published.
Are you using Vue 3 with Vue CLI?
Can you swap out
@mdx-js/loader
withxdm/webpack.cjs
to see if that still fails, and if so, make a reproduction?
i still get the error.
I use vue cli with this configuration:
@jannikbuscha could you share a complete example of what you tried in a codesandbox? https://vue.new
@jannikbuscha could you share a complete example of what you tried in a codesandbox? https://vue.new
https://codesandbox.io/s/cool-breeze-e66xz?file=/src/App.vue
I have found the config error. You have to use end() when working with multiple loaders:
However, the MDXProvider does not work completely:
Nice catch. Can I interest you in a fix for the docs? And can you elaborate on the vue context API not working?
For the second part: that’s because you have not configured @mdx-js/loader
to use @mdx-js/vue
:
.options({jsx: true, providerImportSource: '@mdx-js/vue' /* otherOptions… */})
For the second part: that’s because you have not configured
@mdx-js/loader
to use@mdx-js/vue
:.options({jsx: true, providerImportSource: '@mdx-js/vue' /* otherOptions… */})
In my ide i get this error:
and codesandbox (https://codesandbox.io/s/heuristic-lovelace-rim55?file=/src/App.vue):
here my repo: https://github.com/jannikbuscha/mdx-vue3
Trying out your repo works perfectly for me, no errors.
Even if I add Post
to the template or both Post
and MDXProvider
:
diff --git a/src/App.vue b/src/App.vue
index eee837e..1bcf76e 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,5 +1,6 @@
<template>
<h1>Test</h1>
+ <MDXProvider v-bind:components="components"><Post /></MDXProvider>
</template>
<script lang="ts">
@@ -9,6 +10,9 @@ import {MDXProvider} from '@mdx-js/vue'
import Post from './post.mdx'
@Options({
+ data() {
+ return { components: { h1: "h2" } };
+ },
components: {
MDXProvider, Post
},
If your IDE is breaking, that’s likely due to it not supporting ESM. See: https://v2.mdxjs.com/docs/troubleshooting-mdx/#problems-integrating-mdx. It’s a problem they should fix.
For codesandbox, something is going wrong there indeed. You can add a console.log(Post)
under its import, and see that it’s just a plain text string.
I am guessing that it is due to another integration?
Trying out your repo works perfectly for me, no errors. Even if I add
Post
to the template or bothPost
andMDXProvider
:diff --git a/src/App.vue b/src/App.vue index eee837e..1bcf76e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,5 +1,6 @@ <template> <h1>Test</h1> + <MDXProvider v-bind:components="components"><Post /></MDXProvider> </template> <script lang="ts"> @@ -9,6 +10,9 @@ import {MDXProvider} from '@mdx-js/vue' import Post from './post.mdx' @Options({ + data() { + return { components: { h1: "h2" } }; + }, components: { MDXProvider, Post },
If your IDE is breaking, that’s likely due to it not supporting ESM. See: https://v2.mdxjs.com/docs/troubleshooting-mdx/#problems-integrating-mdx. It’s a problem they should fix.
For codesandbox, something is going wrong there indeed. You can add a
console.log(Post)
under its import, and see that it’s just a plain text string. I am guessing that it is due to another integration?
yes it seems like my ide is causing some problems. I have now tested the whole thing with gitpod and so far everything works. The question I have now is, how do I build something like gfm with the MDXProvider component? if I do that as in the vue example then I get the following error:
You’re attempting to run Vue inside Vue and MDX inside MDX. You don’t have to!
You’re using MDX through [@mdx-js/loader
](https://v2.mdxjs.com/packages/loader/. You can configure that. Pass remarkGfm
there. In the place where you’re using @mdx-js/loader
.
You’re attempting to run Vue inside Vue and MDX inside MDX. You don’t have to! You’re using MDX through [
@mdx-js/loader
](https://v2.mdxjs.com/packages/loader/. You can configure that. PassremarkGfm
there. In the place where you’re using@mdx-js/loader
.
I don't think I really understand this yet. Where exactly does this need to be configured? I have now tried the two things in my vue.config.js:
Before, you tried to import it. That’s what you have to do again. That’s what’s shown in the guide: https://v2.mdxjs.com/guides/gfm/.
import remarkGfm from 'remark-gfm'
// ...
.options({jsx: true, remarkPlugins: [remarkGfm]})
If you removed that because you were getting errors that you were not allowed to import things, then you can see the ESM troubleshooting I linked to earlier for more info and ask Vue CLI folks for help. ESM in vue.config.js
seems to be supported since April already, though maybe it’s in beta: https://v2.mdxjs.com/docs/extending-mdx/#using-plugins
Before, you tried to import it. That’s what you have to do again. That’s what’s shown in the guide: https://v2.mdxjs.com/guides/gfm/.
import remarkGfm from 'remark-gfm' // ... .options({jsx: true, remarkPlugins: [remarkGfm]})
If you removed that because you were getting errors that you were not allowed to import things, then you can see the ESM troubleshooting I linked to earlier for more info and ask Vue CLI folks for help. ESM in
vue.config.js
seems to be supported since April already, though maybe it’s in beta: https://v2.mdxjs.com/docs/extending-mdx/#using-plugins
Thank you very much for your detailed help. I have now opened a stackoverflow question regarding to the ESM story, because after a few hours I have not yet come to a solution.
@jannikbuscha have you seen https://github.com/vuejs/vue-cli/issues/4477 and https://github.com/vuejs/vue-cli/pull/6405? It looks like vue.config.mjs should be supported.
@jannikbuscha have you seen vuejs/vue-cli#4477 and vuejs/vue-cli#6405? It looks like vue.config.mjs should be supported.
i get this error:
https://github.com/vuejs/vue-cli/issues/6592#issuecomment-883942258 might help? It looks like the loader isn't being applied.
vuejs/vue-cli#6592 (comment) might help? It looks like the loader isn't being applied.
Then i get this error:
and with vue.config.mjs + export default {}
Your last screenshot is very close. However, as I mentioned before, while vue-cli added support for .mjs
files, they have not released it. They are in beta.
Here’s how I can make your project work for me locally.
diff --git a/package.json b/package.json
index 884779f..d2f602d 100644
--- a/package.json
+++ b/package.json
@@ -9,7 +9,6 @@
},
"dependencies": {
"@mdx-js/loader": "^2.0.0-rc.1",
- "@mdx-js/mdx": "^2.0.0-rc.1",
"@mdx-js/vue": "^2.0.0-rc.1",
"core-js": "^3.6.5",
"remark-gfm": "^3.0.0",
@@ -17,16 +16,16 @@
"vue-class-component": "^8.0.0-0"
},
"devDependencies": {
- "@typescript-eslint/eslint-plugin": "^4.18.0",
- "@typescript-eslint/parser": "^4.18.0",
+ "@typescript-eslint/eslint-plugin": "^5.1.0",
+ "@typescript-eslint/parser": "^5.1.0",
"@vue/babel-plugin-jsx": "^1.1.1",
- "@vue/cli-plugin-babel": "~4.5.0",
- "@vue/cli-plugin-eslint": "~4.5.0",
- "@vue/cli-plugin-typescript": "~4.5.0",
- "@vue/cli-service": "~4.5.0",
+ "@vue/cli-plugin-babel": "5.0.0-beta.6",
+ "@vue/cli-plugin-eslint": "5.0.0-beta.6",
+ "@vue/cli-plugin-typescript": "5.0.0-beta.6",
+ "@vue/cli-service": "5.0.0-beta.6",
"@vue/compiler-sfc": "^3.0.0",
- "@vue/eslint-config-typescript": "^7.0.0",
- "eslint": "^6.7.2",
+ "@vue/eslint-config-typescript": "^8.0.0",
+ "eslint": "^8.0.0",
"eslint-plugin-vue": "^7.0.0",
"typescript": "~4.1.5"
}
yarn
in your terminalvue.config.js
in your repo to vue.config.mjs
yarn serve
runs the development server which shows that autolink literals, footnotes, strikethrough, tables, and tasklists are supported!Your last screenshot is very close. However, as I mentioned before, while vue-cli added support for
.mjs
files, they have not released it. They are in beta.Here’s how I can make your project work for me locally.
- First, let’s update dependencies. It’s always good when adding new dependencies (such as the this new MDX 2 RC), to make sure the rest is up to date:
diff --git a/package.json b/package.json index 884779f..d2f602d 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ }, "dependencies": { "@mdx-js/loader": "^2.0.0-rc.1", - "@mdx-js/mdx": "^2.0.0-rc.1", "@mdx-js/vue": "^2.0.0-rc.1", "core-js": "^3.6.5", "remark-gfm": "^3.0.0", @@ -17,16 +16,16 @@ "vue-class-component": "^8.0.0-0" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^4.18.0", - "@typescript-eslint/parser": "^4.18.0", + "@typescript-eslint/eslint-plugin": "^5.1.0", + "@typescript-eslint/parser": "^5.1.0", "@vue/babel-plugin-jsx": "^1.1.1", - "@vue/cli-plugin-babel": "~4.5.0", - "@vue/cli-plugin-eslint": "~4.5.0", - "@vue/cli-plugin-typescript": "~4.5.0", - "@vue/cli-service": "~4.5.0", + "@vue/cli-plugin-babel": "5.0.0-beta.6", + "@vue/cli-plugin-eslint": "5.0.0-beta.6", + "@vue/cli-plugin-typescript": "5.0.0-beta.6", + "@vue/cli-service": "5.0.0-beta.6", "@vue/compiler-sfc": "^3.0.0", - "@vue/eslint-config-typescript": "^7.0.0", - "eslint": "^6.7.2", + "@vue/eslint-config-typescript": "^8.0.0", + "eslint": "^8.0.0", "eslint-plugin-vue": "^7.0.0", "typescript": "~4.1.5" }
- Next, make sure those updates are installed by running
yarn
in your terminal- Then, rename
vue.config.js
in your repo tovue.config.mjs
- Now, running
yarn serve
runs the development server which shows that autolink literals, footnotes, strikethrough, tables, and tasklists are supported!
OMG! Thank you so much! 😄
Not working with Vue 3
When I create a Project like this: https://github.com/mdx-js/mdx/tree/master/examples/vue with Vue 3, I get this warning:
Also nothing happens