vue-scrollto icon indicating copy to clipboard operation
vue-scrollto copied to clipboard

Add support for nuxt 3

Open WolfgangDrescher opened this issue 2 years ago • 6 comments

Todos:

  • [ ] set meta.compatibility to nuxt v3.0.0 once it is released
  • [ ] find a ways to pass module options or options from configKey to the plugin and the VueScrollTo installation
  • [ ] test if proper ESM support is needed for the new nuxt 3 files (.mjs file extensions)
  • [ ] test if the plugin really needs to be active on server side to prevent the getSSRProps error once nuxt v3.0.0 is released
  • [ ] replace the current nuxt directory with the new nuxt3 folder?
  • [ ] maybe expose the nuxt/nuxt3 directory with exports in package.json (probably a breaking change)

WolfgangDrescher avatar Sep 22 '22 10:09 WolfgangDrescher

Hi, thanks for starting this!

I do have one question, which I couldn't find a clear answer to in the nuxt docs, is @nuxt/kit really necessary as a dependency, or could it be a peerDependency (optional)? For anyone using this in non-nuxt projects, that just installs extra unnecessary dependencies, so just want to make sure it's really necessary.

rigor789 avatar Sep 24 '22 08:09 rigor789

Good question. In my understanding this seems to be necessary. Have a look at https://nuxt.new/s/module or at what e.g. VueUse is doing: https://github.com/vueuse/vueuse/tree/main/packages/nuxt. They both import directly from @nuxt/kit. But in the template of nuxt.new you will find this:

import { defineNuxtPlugin } from '#app'

Maybe there will be an import like this as well for defineNuxtModule once it's released in v3.0.0? Also note that there is a nuxt-module-build command from @nuxt/module-builder. I tried this on StackBlitz but it does not look like this command will build the module without the @nuxt/kit dependency.

Also note that VueUse is releasing a custom package for its nuxt integration, maybe because of that reason. I wonder how they make to module compatible with nuxt 2 and nuxt 3 according to https://modules.nuxtjs.org/?q=vueuse.

WolfgangDrescher avatar Sep 24 '22 11:09 WolfgangDrescher

Hi @rigor789 / @WolfgangDrescher,

I'm just wondering if either of you guys are still working on support for Nuxt 3? I really enjoyed using this package in my Vue 2 project and am in the process of migrating it to Nuxt 3 and so am really hoping it will have Nuxt 3 support sometime soon. I see there are quite a few others in the Issues also looking for this.

Thanks!

eoinom avatar May 29 '23 22:05 eoinom

I was not able to improve support for Nuxt 3 for this plugin as I'm not sure how to remove the @nuxt/kit dependency. So for now I stopped working on this as it was not so important in my project to have this functionality. If anyone knows Nuxt 3 modules better than I do, feel free to give me feedback on the current implementation and the open todos in my initial comment.

WolfgangDrescher avatar May 30 '23 20:05 WolfgangDrescher

As a workaround you could add https://github.com/rigor789/vue-scrollto/blob/7feaccc327a45b54be93783f245b57ee4fed4448/nuxt3/plugin.js as a nuxt plugin.

WolfgangDrescher avatar May 30 '23 20:05 WolfgangDrescher

As a workaround you could add https://github.com/rigor789/vue-scrollto/blob/7feaccc327a45b54be93783f245b57ee4fed4448/nuxt3/plugin.js as a nuxt plugin.

Thanks @WolfgangDrescher, that worked like a charm!

eoinom avatar May 30 '23 22:05 eoinom