How to use @mdx-js/rollup with Vite? #1981
-
My file import mdx from '@mdx-js/rollup'
import react from '@vitejs/plugin-react'
import Unocss from 'unocss/vite'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [
react(),
mdx(),
Unocss()
],
}) When I run Does anyone know how to fix this? Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This appears to be the same as #1973 ? The issue is that, mdx is native ESM and your project is not native ESM. From vite's documentation.
https://vitejs.dev/config/#config-file-resolving Here pre-processing to CJS will cause an error. |
Beta Was this translation helpful? Give feedback.
This appears to be the same as #1973 ?
The issue is that, mdx is native ESM and your project is not native ESM.
From vite's documentation.
https://vitejs.dev/config/#config-file-resolving
Here pre-processing to CJS will cause an error.
Add
"type": "module"
to yourpackage.json
to ensure it is native ESM.