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'));