From 389133b1fc84b086d09f012cf459729b0079de33 Mon Sep 17 00:00:00 2001 From: Robert Soriano Date: Fri, 20 Dec 2024 04:44:59 -0800 Subject: [PATCH] fix(nuxt): Optimize `@clerk/vue` (#4820) --- .changeset/shy-mangos-visit.md | 5 +++++ packages/nuxt/src/module.ts | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/shy-mangos-visit.md diff --git a/.changeset/shy-mangos-visit.md b/.changeset/shy-mangos-visit.md new file mode 100644 index 0000000000..b57d839d71 --- /dev/null +++ b/.changeset/shy-mangos-visit.md @@ -0,0 +1,5 @@ +--- +"@clerk/nuxt": patch +--- + +Fix Vite optimization issue that caused duplicate versions of @clerk/vue to be created on first load, resulting in the Vue plugin losing context. diff --git a/packages/nuxt/src/module.ts b/packages/nuxt/src/module.ts index bc606a1e4a..114b4918c7 100644 --- a/packages/nuxt/src/module.ts +++ b/packages/nuxt/src/module.ts @@ -79,6 +79,11 @@ export default defineNuxtModule({ // Handle Nuxt-specific imports (e.g #imports) nuxt.options.build.transpile.push(resolver.resolve('./runtime')); + // Optimize @clerk/vue to avoid missing injection Symbol key errors + nuxt.options.vite.optimizeDeps = nuxt.options.vite.optimizeDeps || {}; + nuxt.options.vite.optimizeDeps.include = nuxt.options.vite.optimizeDeps.include || []; + nuxt.options.vite.optimizeDeps.include.push('@clerk/vue'); + // Add the `@clerk/vue` plugin addPlugin(resolver.resolve('./runtime/plugin'));