From e073f5ad8fa51d5847fee9198b79785c968402db Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Tue, 22 Nov 2022 16:13:51 +0800 Subject: [PATCH] feat: dedupe the `vue` in client bundle by default Fixes #2443 Fixes #7454 It's already been set by default in Nuxt 3 for a while now https://github.com/nuxt/framework/pull/6735 So I think this change should be harmless. And technically it could be considered a fix than a feat. Nevertheless, it's better to ship it in v4 to minimize disruptions on the user side. Things that are not covered in this PR: 1. SSR, because `resolve.dedupe` doesn't work for ESM build outputs, and the CommonJS version is kinda hacky, I think it's better to skip the config for SSR completely. Besides, most related issues are from the client side. 2. #5958 isn't fixed by this PR. --- packages/plugin-vue/src/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/plugin-vue/src/index.ts b/packages/plugin-vue/src/index.ts index d1067b5811f5f3..76809f0d69a5b2 100644 --- a/packages/plugin-vue/src/index.ts +++ b/packages/plugin-vue/src/index.ts @@ -128,6 +128,9 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin { config(config) { return { + resolve: { + dedupe: config.build?.ssr ? [] : ['vue'] + }, define: { __VUE_OPTIONS_API__: config.define?.__VUE_OPTIONS_API__ ?? true, __VUE_PROD_DEVTOOLS__: config.define?.__VUE_PROD_DEVTOOLS__ ?? false