vue-scrollto
vue-scrollto copied to clipboard
Add support for nuxt 3
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
inpackage.json
(probably a breaking change)
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.
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.
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!
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.
As a workaround you could add https://github.com/rigor789/vue-scrollto/blob/7feaccc327a45b54be93783f245b57ee4fed4448/nuxt3/plugin.js as a nuxt plugin.
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!