diff --git a/src/runtime/hydrate.js b/src/runtime/hydrate.js index 580ec7b630..f2c55592c8 100644 --- a/src/runtime/hydrate.js +++ b/src/runtime/hydrate.js @@ -3,18 +3,18 @@ import { hydrateWhenVisible } from 'vue3-lazy-hydration'; const isDev = process.env.NODE_ENV === 'development'; export default component => { - if (isDev || import.meta.server) { - if (typeof component === 'function') { - component = defineAsyncComponent(component); - } - return component; - } - const runtimeConfig = useRuntimeConfig(); - return hydrateWhenVisible(component, { + return hydrateWhenVisible(wrapComponent(component), { observerOptions: { rootMargin: runtimeConfig.public.booster.lazyOffsetComponent || '0%' } }); }; + +const wrapComponent = component => { + if (!(isDev || import.meta.server) && typeof component === 'function') { + return defineAsyncComponent(component); + } + return component; +};