mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
fix(nuxt): use relative paths when augmenting types (#22633)
This commit is contained in:
parent
a16edba2f5
commit
bb83ab5b3f
@ -4,7 +4,7 @@ import { addBuildPlugin, addComponent, addPlugin, addTemplate, addVitePlugin, ad
|
|||||||
import { dirname, join, relative, resolve } from 'pathe'
|
import { dirname, join, relative, resolve } from 'pathe'
|
||||||
import { genImport, genObjectFromRawEntries, genString } from 'knitwork'
|
import { genImport, genObjectFromRawEntries, genString } from 'knitwork'
|
||||||
import { joinURL } from 'ufo'
|
import { joinURL } from 'ufo'
|
||||||
import type { NuxtApp, NuxtPage } from 'nuxt/schema'
|
import type { Nuxt, NuxtApp, NuxtPage } from 'nuxt/schema'
|
||||||
import { createRoutesContext } from 'unplugin-vue-router'
|
import { createRoutesContext } from 'unplugin-vue-router'
|
||||||
import { resolveOptions } from 'unplugin-vue-router/options'
|
import { resolveOptions } from 'unplugin-vue-router/options'
|
||||||
import type { EditableTreeNode, Options as TypedRouterOptions } from 'unplugin-vue-router'
|
import type { EditableTreeNode, Options as TypedRouterOptions } from 'unplugin-vue-router'
|
||||||
@ -339,8 +339,8 @@ export default defineNuxtModule({
|
|||||||
|
|
||||||
addTemplate({
|
addTemplate({
|
||||||
filename: 'types/middleware.d.ts',
|
filename: 'types/middleware.d.ts',
|
||||||
getContents: ({ app }: { app: NuxtApp }) => {
|
getContents: ({ nuxt, app }: { nuxt: Nuxt, app: NuxtApp }) => {
|
||||||
const composablesFile = resolve(runtimeDir, 'composables')
|
const composablesFile = relative(join(nuxt.options.buildDir, 'types'), resolve(runtimeDir, 'composables'))
|
||||||
const namedMiddleware = app.middleware.filter(mw => !mw.global)
|
const namedMiddleware = app.middleware.filter(mw => !mw.global)
|
||||||
return [
|
return [
|
||||||
'import type { NavigationGuard } from \'vue-router\'',
|
'import type { NavigationGuard } from \'vue-router\'',
|
||||||
@ -356,8 +356,8 @@ export default defineNuxtModule({
|
|||||||
|
|
||||||
addTemplate({
|
addTemplate({
|
||||||
filename: 'types/layouts.d.ts',
|
filename: 'types/layouts.d.ts',
|
||||||
getContents: ({ app }: { app: NuxtApp }) => {
|
getContents: ({ nuxt, app }: { nuxt: Nuxt, app: NuxtApp }) => {
|
||||||
const composablesFile = resolve(runtimeDir, 'composables')
|
const composablesFile = relative(join(nuxt.options.buildDir, 'types'), resolve(runtimeDir, 'composables'))
|
||||||
return [
|
return [
|
||||||
'import { ComputedRef, MaybeRef } from \'vue\'',
|
'import { ComputedRef, MaybeRef } from \'vue\'',
|
||||||
`export type LayoutKey = ${Object.keys(app.layouts).map(name => genString(name)).join(' | ') || 'string'}`,
|
`export type LayoutKey = ${Object.keys(app.layouts).map(name => genString(name)).join(' | ') || 'string'}`,
|
||||||
|
Loading…
Reference in New Issue
Block a user