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
Nuxt 3 Support #351
Comments
Thank you for bringing this to my attention! I'll release support for Nuxt 3 in the next |
Hi @justintaddei, how is the progress going on supporting Nuxt 3? |
@DamianGlowala delayed, but not forgotten. I haven't had a chance to work on this yet, but I plan to soon. |
If anyone knows how to make this change with backwards compatibility for Nuxt 2 please let me know. |
@justintaddei It's better you create another git repo for NuxT 3+ versions. |
After some research, it seems impossible to support both Nuxt 2 and 3 in the same package. Going forward:
Migration to Nuxt 3 will take place sometime in the next few weeks, depending on my schedule. |
Nice ! I am impatient to see that, your plugin is really usefull for me ! Thx for your work ❤️ |
@razorness |
@yldshv I am not using Nuxt. Sorry. But take a short look into the example. You can access the Vue app instance via Since v-shared-element is a little stingy with exports, I think you need to trick the install method by mocking an object which looks like a Vue 3 app instance to catch
|
Thank you @razorness. I will give it a shot :D |
Hey everyone! I just wanted to leave an update here. I haven't forgotten about this :) Nuxt 3 support is still planned but I cannot give an ETA at this time. As soon as my schedule clears up, I will begin working on it. |
Hi @justintaddei ! |
@NtchPlayer tentatively planned for the first week of November! |
Hi everyone! I've had an idea that would allow for nuxt2 and nuxt3 installs with the same version of v-wave. This removes the necessity of the breaking change detailed in this comment. I came up with this approach after not having much luck creating a nuxt module that can exist alongside a vanilla vue plugin. That is, I don't want to use nuxt's module builder because this isn't a nuxt module... it's a vue plugin with nuxt support. If anyone has more experience working with modules in nuxt 3 and knows how to achieve the same behavior that exists for nuxt 2, please enlighten me :) !!! I'm not sure if this is a good solution. Please provide feedback if you don't like this approach !!!
When installing The file that registers the plugin (this will also be where global // v-wave.client.ts
import vWave, { type IVWavePluginOptions } from 'v-wave'
export const options: Partial<IVWavePluginOptions> = {
// Place any global v-wave options here
}
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(vWave, options)
}) And a stub that is needed when registering directives:
// v-wave.server.ts
import { options } from './v-wave.client';
export default defineNuxtPlugin(({ vueApp }) => {
vueApp.directive(options.directive ?? 'wave', {});
vueApp.directive(`${options.directive ?? 'wave'}-trigger`, {});
}); A fresh nuxt 3 project with v-wave installed: So far the install script is as follows (this will need to be more robust before it's ready for a stable release, but it gets the point across at least): const fs = require('fs')
const path = require('path')
const pkg = require(path.join(process.env.INIT_CWD, 'package.json'))
const nuxtVersion = pkg.dependencies?.nuxt ?? pkg.devDependencies?.nuxt
if (!nuxtVersion || /2\.\d+\.\d+/.test(nuxtVersion)) {
process.exit(0)
}
if (!fs.existsSync(path.join(process.env.INIT_CWD, 'plugins'))) {
fs.mkdirSync(path.join(process.env.INIT_CWD, 'plugins'))
}
try {
fs.copyFileSync(
path.join(__dirname, 'v-wave.client.ts'),
path.join(process.env.INIT_CWD, 'plugins', 'v-wave.client.ts'),
fs.constants.COPYFILE_EXCL
)
fs.copyFileSync(
path.join(__dirname, 'v-wave.server.ts'),
path.join(process.env.INIT_CWD, 'plugins', 'v-wave.server.ts'),
fs.constants.COPYFILE_EXCL
)
} catch (e) {
process.exit(0)
} |
However, on second thought, the better approach might just be to provide the boilerplate for nuxt in the readme instead of dealing with the complexity of auto-generating the file. What do you guys think? |
Hum, I have any experience with Nuxt module creation :'( A create some directive for me (image lazy loading as exemple). I never take time to try to create my own plugin. I don't know if you can get more help on the [nuxt official discord server] ? (https://discord.com/invite/nuxt) (oh, I just see that you already join it today ^^) I can say that, I use vue masonry on my project, and I have two configuration (one for the server side and one for client side like you suggest) because vue masonry works only on client side. // @/plugins/vue-masonry.js
export default defineNuxtPlugin(async (nuxtApp) => {
if (process.server) {
nuxtApp.vueApp.directive('masonry', {})
nuxtApp.vueApp.directive('masonry-tile', {})
}
if (process.client) {
const { VueMasonryPlugin } = await import('vue-masonry')
nuxtApp.vueApp.use(VueMasonryPlugin)
}
}) |
Thanks @NtchPlayer. Yeah, I joined the discord and asked around but nothing useful has come of that yet. |
Currently, what works for me perfectly fine is the following plugin:
What about creating a Nuxt module which would inject a plugin file with the above content?
|
is this a guide on how to setup v-wave in Nuxt 3 ? I dont get the last code that is in your reply, If you could add some instructions for nuxt 3 to the document would be a very big help :) |
@amirsafaricg it's not a guide... just an idea for how I might move forward with the upgrade. I have a working solution for Nuxt 3 that I finished today. It should be backwards compatible with Nuxt 2 as well but I need to wait until tomorrow before I can test that. Either way, expect a release with Nuxt 3 support tomorrow or Wednesday! |
@amirsafaricg in the mean time this will get you up and running with v-wave in Nuxt 3: All other steps are the same as is described in the current docs |
That's really great to hear ! Thanks really ! |
Nuxt 3 support added in #593. Release The breaking change is due If you have any issues getting it to work in your project, please feel free to open another issue! |
I just install version 2.0.0 and it's work perfectly ! Thx you for your work 😄 |
For people who are struggling using VWave with Nuxt 3
There are two problems with the current implementation:
getSSRProps
.serialize
does not exist in/nuxt/plugin.js
:v-wave/nuxt/plugin.js
Line 4 in 34f26b6
So here is a workaround
plugins
folder, fe:plugins/vWave.directive.ts
That's it. Touching
nuxt.config.ts
is not needed.The text was updated successfully, but these errors were encountered: