Skip to content

WIP: Add API for making it possible to block loading of SSR only static content components with vue-lazy-hydration #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

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