nuxt-auth icon indicating copy to clipboard operation
nuxt-auth copied to clipboard

Issue with module augmentation seems to be happening again

Open trc-mathieu opened this issue 1 year ago • 4 comments

Environment


  • Operating System: Linux
  • Node Version: v20.13.1
  • Nuxt Version: 3.12.2
  • CLI Version: 3.12.0
  • Nitro Version: 2.9.6
  • Package Manager: [email protected]
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

You can simply clone this repository, open in VS code and navigate to playground-authjs/pages/index.vue and mouse over on auth key. The type is not correctly augmented.

Describe the bug

The MiddlewareMeta is not recognized by definePageMeta macro. This issue happened in the past and it is happening to me now. The modification that was made here does fix the issue: #397 but it was rolled back by @danielroe here #582

I have this issue on other modules as well and augmenting from #app/../pages/runtime/composables does work.

@danielroe, do you mind trying again the latest version of this repo?

using #app Screenshot 2024-07-16 at 9 58 55 AM Screenshot 2024-07-16 at 9 59 05 AM

using #app/../pages/runtime/composables Screenshot 2024-07-16 at 9 59 29 AM Screenshot 2024-07-16 at 9 59 47 AM

Additional context

No response

Logs

No response

trc-mathieu avatar Jul 16 '24 14:07 trc-mathieu

It would be a good idea to add a type test to this repo if this is occurring, to ensure it doesn't happen in future.

I suspect the issue is that rightly or wrongly we are augmenting it in Nuxt like this:

https://github.com/nuxt/framework/pull/2858/files#diff-df395205486536ffc90235a4d30334e7d53ea5519d778996ac209cdc5e26a53dR106

I can investigate whether we can update this in Nuxt to augment PageMeta from #app instead. Would you provide a minimal reproduction outside of this repo (without using sidebase auth), and raise it in https://github.com/nuxt/nuxt directly? 🙏

danielroe avatar Jul 16 '24 16:07 danielroe

@danielroe I will open a repro, thank you.

trc-mathieu avatar Jul 16 '24 19:07 trc-mathieu

Hi @trc-mathieu

Thanks for (re) opening an issue for this! I would love to follow along with the issue created in the Nuxt repo and then follow-up and fix the issue in our module based on the outcome.

Otherwise, we can always revert the change to ensure the types work correctly again, but I would propose to wait a bit and see if any news happen 🤗

zoey-kaiser avatar Jul 16 '24 21:07 zoey-kaiser

Let's wait for Nuxt 3.12.5 and do a version bump to close the issue

phoenix-ru avatar Jul 25 '24 09:07 phoenix-ru

This should no longer be a problem due to module using addTypeTemplate. This helper handles references correctly. https://github.com/sidebase/nuxt-auth/blob/4b3a5904c9e0d3bce6a6334bf4a463d4835d4a48/src/module.ts#L184-L185

phoenix-ru avatar Apr 24 '25 14:04 phoenix-ru