From 1dcc135094f4d38742da2e8020dd3ab36b8d172c Mon Sep 17 00:00:00 2001 From: FernandoJVideira <03.pleaser-minster@icloud.com> Date: Wed, 16 Sep 2026 13:58:23 +0100 Subject: [PATCH] Generated clients: exclude vue-ui-kit from Vite pre-bundling, /signup route Generated projects never got the optimizeDeps exclusion the template's own configs carry - the Nuxt config is patched from nuxi's output and the Vue one from create-vue's - so Vite bundled vue-ui-kit's index.ts with reka-ui inlined while the kit's .vue files imported reka-ui from source. Two module instances, mismatched provide/inject Symbols: a fresh Vue client rendered a blank /login ("Injection Symbol(TabsRootContext) not found") and a fresh Nuxt one crashed SSR on any page with a Dialog. Both config patches now add the exclusion. The Nuxt patch also adds the pages:extend hook that gives pages/login.vue a second /signup record, matching the template's auth card whose tabs now drive the URL (project-template#5). Submodule bumped to that commit. Co-Authored-By: Claude Fable 5.1 --- assets/testdata/template | 2 +- cmd/client.go | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/assets/testdata/template b/assets/testdata/template index 4143dea..40f5025 160000 --- a/assets/testdata/template +++ b/assets/testdata/template @@ -1 +1 @@ -Subproject commit 4143dea0b3e4865f19c771ba3be1598ba371c003 +Subproject commit 40f5025169450ec110ba11dc39577f5ff1fb041a diff --git a/cmd/client.go b/cmd/client.go index f048a27..8897a5d 100644 --- a/cmd/client.go +++ b/cmd/client.go @@ -128,6 +128,25 @@ func patchNuxtConfig(projectDir, serviceName string) error { css: ['~/assets/css/main.css'], vite: { plugins: [tailwindcss()], + // vue-ui-kit ships raw .vue/.ts source. Left to Vite's dependency + // pre-bundler, its index.ts gets bundled with reka-ui inlined while its + // .vue files import reka-ui from source - two module instances, so + // reka-ui's provide/inject contexts (Dialog, Tabs, Select...) can't find + // each other. Excluding it keeps every import on the one reka-ui. + optimizeDeps: { + exclude: ['@fernandojvideira/vue-ui-kit'], + }, + }, + hooks: { + // /login and /signup are the two tabs of one auth card, served by the + // same page file. A second route record (not an alias - the router + // would treat switching between a route and its alias as a duplicate + // navigation and drop it) lets the tab change the URL while NuxtPage + // keeps the same component instance thanks to the page's fixed key. + 'pages:extend'(pages) { + const login = pages.find((page) => page.path === '/login') + if (login) pages.push({ ...login, name: 'signup', path: '/signup' }) + }, }, app: { @@ -299,13 +318,31 @@ func patchViteConfigForTailwind(projectDir string) error { ) newContent = strings.Replace(newContent, "vueDevTools(),", "vueDevTools(),\n tailwindcss(),", 1) - if newContent == string(content) { + // create-vue's config ends with the resolve.alias block; hang the + // optimizeDeps exclusion off its closing brace. + newContent = strings.Replace(newContent, + " '@': fileURLToPath(new URL('./src', import.meta.url)),\n },\n },\n})", + " '@': fileURLToPath(new URL('./src', import.meta.url)),\n },\n },\n"+viteOptimizeDepsExclude+"})", + 1, + ) + + if newContent == string(content) || !strings.Contains(newContent, "optimizeDeps") { return fmt.Errorf("could not find expected anchors in vite.config.ts") } return os.WriteFile(configPath, []byte(newContent), 0644) } +// vue-ui-kit ships raw .vue/.ts source. Left to Vite's dependency pre-bundler, +// its index.ts gets bundled with reka-ui inlined while its .vue files import +// reka-ui from source - two module instances, so reka-ui's provide/inject +// contexts (Dialog, Tabs, Select...) can't find each other. Excluding it keeps +// every import on the one reka-ui. +const viteOptimizeDepsExclude = ` optimizeDeps: { + exclude: ['@fernandojvideira/vue-ui-kit'], + }, +` + func patchTsconfigAlias(projectDir string) error { configPath := filepath.Join(projectDir, "tsconfig.json") content, err := os.ReadFile(configPath) -- 2.54.0