vitepress
vitepress copied to clipboard
feat: add vue to `resolve.dedupe`
Developers who wants to extend the theme may use libraries depending on different versions of vue, causing client errors. Adding vue to resolve.dedupe can avoid such conditions.
I don't think resolve.dedupe will work for us as we are using SSR + ESM builds. Also, I suppose one can create a vite.config.ts themselves and add this option there (along with SSR + CJS settings).
I don't think resolve.dedupe will work for us as we are using SSR + ESM builds.
Multiple instances of vue may cause failure in development and result in multiple chunks in the bundle.
I suppose one can create a vite.config.ts themselves and add this option there (along with SSR + CJS settings).
So does vitepress support vite config out of the box? (One may would like to use vitepress together with other component libraries.)
Multiple instances of vue may cause failure in development and result in multiple chunks in the bundle.
Yeah, I understood that part. But according to Vite's docs, that doesn't work on SSR + ESM builds (<-- that's what we are using here). One needs to use CJS mode for SSR for it to work. And regarding Vite config, yes it is supported.
But according to Vite's docs, that doesn't work on SSR + ESM builds.
Well I see. So should I just remove resolve.dedupe from SSR builds and keep the others?
Developers who wants to extend the theme may use libraries depending on different versions of vue
I think we should simply discourage users from using different versions of Vue...? What is the reason why you can't update the Vue version?
@kiaking It is not about updating the vue version. Adding dependencies in a composite project may result in multiple instances of vue, something like root > vue and root > @vueuse/core > vue. This problem can be fixed but is sometimes hard to find out.
So, seems like Vite 4 still has same behavior at the moment. Maybe we should simple document about this issue...? It might be simpler.
@brc-dd Do you happen to have any news on this topic? 👀
@shigma Evan is currently looking into this problem. It's also an issue in Nuxt as well. While adding this option to Vite config is one way of solving it, but we're trying to fix the issues by looking into the problem deeper.
We're trying gather as much as reproduction here to see the actual cases. If you have reproduction code, please share. It would be super helpful 🙇
Maybe only dedupe for client-side builds?
vue plugin already dedupes this for client builds now - https://github.com/vitejs/vite-plugin-vue/blob/69fb8c811d8fdbc7bdc968033834ddede59ee885/packages/plugin-vue/src/index.ts#L163