From e4a372e12c5878192e9a17e4e046a9e2aefce2d6 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Sun, 29 Dec 2024 23:18:55 +0000 Subject: [PATCH] fix(nuxt): pass `nuxt` instance to `resolvePagesRoutes` --- packages/nuxt/src/pages/module.ts | 6 +++--- packages/nuxt/src/pages/utils.ts | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/nuxt/src/pages/module.ts b/packages/nuxt/src/pages/module.ts index b702453271..b222de186d 100644 --- a/packages/nuxt/src/pages/module.ts +++ b/packages/nuxt/src/pages/module.ts @@ -75,7 +75,7 @@ export default defineNuxtModule({ return true } - const pages = await resolvePagesRoutes() + const pages = await resolvePagesRoutes(nuxt) if (pages.length) { if (nuxt.apps.default) { nuxt.apps.default.pages = pages @@ -93,7 +93,7 @@ export default defineNuxtModule({ } nuxt.hook('app:templates', async (app) => { - app.pages = await resolvePagesRoutes() + app.pages = await resolvePagesRoutes(nuxt) if (!nuxt.options.ssr && app.pages.some(p => p.mode === 'server')) { logger.warn('Using server pages with `ssr: false` is not supported with auto-detected component islands. Set `experimental.componentIslands` to `true`.') @@ -173,7 +173,7 @@ export default defineNuxtModule({ logs: nuxt.options.debug, async beforeWriteFiles (rootPage) { rootPage.children.forEach(child => child.delete()) - const pages = nuxt.apps.default?.pages || await resolvePagesRoutes() + const pages = nuxt.apps.default?.pages || await resolvePagesRoutes(nuxt) if (nuxt.apps.default) { nuxt.apps.default.pages = pages } diff --git a/packages/nuxt/src/pages/utils.ts b/packages/nuxt/src/pages/utils.ts index 1cff988c63..4d4141b26b 100644 --- a/packages/nuxt/src/pages/utils.ts +++ b/packages/nuxt/src/pages/utils.ts @@ -42,9 +42,7 @@ interface ScannedFile { absolutePath: string } -export async function resolvePagesRoutes (): Promise { - const nuxt = useNuxt() - +export async function resolvePagesRoutes (nuxt = useNuxt()): Promise { const pagesDirs = nuxt.options._layers.map( layer => resolve(layer.config.srcDir, (layer.config.rootDir === nuxt.options.rootDir ? nuxt.options : layer.config).dir?.pages || 'pages'), )