Skip to content

Conversation

maoberlehner
Copy link

So this is a very rough proof-of-concept of an API for vue-lazy-hydration to register static components that should not be prefetched and loaded on the client.

I'm aware that this probably can't be the final implementation of this but I'd be happy to get feedback and further improve the pull request!

In Nuxt 3 I made the following changes to make this work:

 // app/plugins/preload.server.ts
 export default <Plugin> function preload ({ app }) {
   app.mixin({
     beforeCreate () {
-      const { _registeredComponents } = this.$nuxt.ssrContext
-      const { __moduleIdentifier } = this.$options
-      _registeredComponents.push(__moduleIdentifier)
+      const { _registeredComponents, _staticComponents } = this.$nuxt.ssrContext
+      const { __moduleIdentifier, __lazyHydrationTiming } = this.$options

+      if (!__lazyHydrationTiming) {
+        _registeredComponents.push(__moduleIdentifier)
+      } else if (__lazyHydrationTiming === 'NEVER') {
+        _staticComponents.push(__moduleIdentifier)
+      }
     }
   })
 }

This adds the necessary API for vue-lazy-hydration to register static
components.
@danielroe
Copy link
Member

danielroe commented Sep 24, 2024

closing as I think this is still a work in progress

if there's an ongoing need or you have any updates please feel free to reopen 🙏

@danielroe danielroe closed this Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants