-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(nuxt3): support auto-loading lazy and custom-resolved components #3814
Conversation
β Deploy Preview for nuxt3-docs ready! π¨ Explore the source changes: a8854e7 π Inspect the deploy log: https://app.netlify.com/sites/nuxt3-docs/deploys/62386aa3a0da830008bd46ce π Browse the preview: https://deploy-preview-3814--nuxt3-docs.netlify.app |
Instead of re-intorducing |
@pi0 So instead of: <template>
<LazyTheFooter v-if="someCondition" />
</template> we would do: <template>
<component is="LazyTheFooter" v-if="someCondition" />
</template>
<script setup>
const LazyTheFooter = resolveAsyncComponent('TheFooter')
</script> Initially I think this is more verbose without need. We can use the |
There are mainly two use cases for lazy loading components:
I assume your example is the first case. When a file name ends with Second is I guess what you mentioned as:
<template>
<component :is="clickable ? MyButton : 'div'" />
</template>
<script setup>
const MyButton = resolveComponent('MyButton')
</script> This could be: <template>
<component :is="clickable ? MyButton : 'div'" />
</template>
<script setup>
const MyButton = resolveAsyncComponent('MyButton')
</script> |
This PR is not introducing new functionality - the usage with framework/packages/nuxt3/src/components/templates.ts Lines 38 to 43 in 87eb7d0
While I think |
π Linked issue
for example, nuxt/nuxt#13483 - though not marking as resolving it as we may also wish to globally register
NuxtLink
β Type of change
π Description
This PR:
nuxt.config
documentationLazy
-prefixed componentsLazy
-prefixed componentsresolveComponent
(to allow users to do more elaborate dynamic components without needing to setglobal: true
, which can have a negative performance effect). See Dynamically creating <NuxtLink> with <Component> no longer worksΒ nuxt#13483 for example.π Checklist