Skip to content

Commit adac73a

Browse files
committed
chore: warn about NuxtLayout
1 parent 522fcdd commit adac73a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/module.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,17 @@ export default defineNuxtModule<ModuleOptions>({
458458
})
459459
}
460460
})
461-
nuxt.hook('app:resolve', (app) => {
461+
nuxt.hook('app:resolve', async (app) => {
462462
if (app.mainComponent?.includes('@nuxt/ui-templates')) {
463463
app.mainComponent = resolveRuntimeModule('./app.vue')
464+
} else {
465+
const appContent = await fs.promises.readFile(app.mainComponent!, { encoding: 'utf-8' })
466+
if (appContent.includes('<NuxtLayout') || appContent.includes('<nuxt-layout')) {
467+
logger.warn([
468+
'Using `<NuxtLayout>` inside `app.vue` will cause unwanted layout shifting in your application.',
469+
'Consider removing `<NuxtLayout>` from `app.vue` and using it in your pages.'
470+
].join(''))
471+
}
464472
}
465473
})
466474
}

0 commit comments

Comments
 (0)