@@ -4,7 +4,7 @@ import { addBuildPlugin, addComponent, addPlugin, addTemplate, addVitePlugin, ad
4
4
import { dirname , join , relative , resolve } from 'pathe'
5
5
import { genImport , genObjectFromRawEntries , genString } from 'knitwork'
6
6
import { joinURL } from 'ufo'
7
- import type { NuxtApp , NuxtPage } from 'nuxt/schema'
7
+ import type { Nuxt , NuxtApp , NuxtPage } from 'nuxt/schema'
8
8
import { createRoutesContext } from 'unplugin-vue-router'
9
9
import { resolveOptions } from 'unplugin-vue-router/options'
10
10
import type { EditableTreeNode , Options as TypedRouterOptions } from 'unplugin-vue-router'
@@ -339,8 +339,8 @@ export default defineNuxtModule({
339
339
340
340
addTemplate ( {
341
341
filename : 'types/middleware.d.ts' ,
342
- getContents : ( { app } : { app : NuxtApp } ) => {
343
- const composablesFile = resolve ( runtimeDir , 'composables' )
342
+ getContents : ( { nuxt , app } : { nuxt : Nuxt , app : NuxtApp } ) => {
343
+ const composablesFile = relative ( join ( nuxt . options . buildDir , 'types' ) , resolve ( runtimeDir , 'composables' ) )
344
344
const namedMiddleware = app . middleware . filter ( mw => ! mw . global )
345
345
return [
346
346
'import type { NavigationGuard } from \'vue-router\'' ,
@@ -356,8 +356,8 @@ export default defineNuxtModule({
356
356
357
357
addTemplate ( {
358
358
filename : 'types/layouts.d.ts' ,
359
- getContents : ( { app } : { app : NuxtApp } ) => {
360
- const composablesFile = resolve ( runtimeDir , 'composables' )
359
+ getContents : ( { nuxt , app } : { nuxt : Nuxt , app : NuxtApp } ) => {
360
+ const composablesFile = relative ( join ( nuxt . options . buildDir , 'types' ) , resolve ( runtimeDir , 'composables' ) )
361
361
return [
362
362
'import { ComputedRef, MaybeRef } from \'vue\'' ,
363
363
`export type LayoutKey = ${ Object . keys ( app . layouts ) . map ( name => genString ( name ) ) . join ( ' | ' ) || 'string' } ` ,
0 commit comments