Skip to content

Add support for nuxt 3 #715

New issue

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

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

Already on GitHub? # to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

WolfgangDrescher
Copy link

@WolfgangDrescher WolfgangDrescher commented Sep 22, 2022

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)

@rigor789
Copy link
Owner

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.

@WolfgangDrescher
Copy link
Author

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.

@rigor789 rigor789 mentioned this pull request Oct 4, 2022
@eoinom
Copy link

eoinom commented May 29, 2023

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!

@WolfgangDrescher
Copy link
Author

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 WolfgangDrescher changed the title WIP: Add support for nuxt 3 Add support for nuxt 3 May 30, 2023
@WolfgangDrescher WolfgangDrescher marked this pull request as draft May 30, 2023 20:23
@WolfgangDrescher
Copy link
Author

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

@eoinom
Copy link

eoinom commented May 30, 2023

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!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants