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 <[email protected]>
This commit is contained in:
FernandoJVideiraandClaude Fable 5.1 committed 2026-09-16 13:58:23 +01:00
1 parent 39678f3ea6
commit 1dcc135094
2 files changed
+39 -2

No files matched your search

+38 -1
View File
@@ -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)