sidebase / nuxt-auth

Authentication built for Nuxt 3! Easily add authentication via OAuth providers, credentials or Email Magic URLs!
https://auth.sidebase.io
MIT License
1.18k stars 143 forks source link

Warning on Build: Dynamic and Static Import Conflict #669

Open tberk opened 5 months ago

tberk commented 5 months ago

Environment

Reproduction

No response

Describe the bug

I've encountered a warning during the build process. I get this error both on Vercel and Ubuntu node server Auth works as intended on Vercel but I have some problems on node server I dont know if they are related to this.

WARN  [plugin:vite:reporter]
(!) /home/ubuntu/projects/******.com/node_modules/.pnpm/@sidebase+nuxt-auth@0.6.7_next-auth@4.22.5_vue@3.4.19/node_modules/@sidebase/nuxt-auth/dist/runtime/middleware/auth.mjs is dynamically imported by virtual:nuxt:/home/ubuntu/projects/******.com/.nuxt/middleware.mjs but also statically imported by /home/ubuntu/projects/******.com/node_modules/.pnpm/@sidebase+nuxt-auth@0.6.7_next-auth@4.22.5_vue@3.4.19/node_modules/@sidebase/nuxt-auth/dist/runtime/plugin.mjs, dynamic import will not move module into another chunk.

Additional context

No response

Logs

No response

phoenix-ru commented 5 months ago

Thanks for your report. This is likely caused by middleware being added differently in these two places:

1: https://github.com/sidebase/nuxt-auth/blob/0bc80f7ecd52e5fac856104249ea98f45fddf974/src/runtime/plugin.ts#L2 https://github.com/sidebase/nuxt-auth/blob/0bc80f7ecd52e5fac856104249ea98f45fddf974/src/runtime/plugin.ts#L93-L95

2: https://github.com/sidebase/nuxt-auth/blob/0bc80f7ecd52e5fac856104249ea98f45fddf974/src/module.ts#L215-L218

The task would really be to unify the approach (use same addRouteMiddleware in both).

MelvinIdema commented 4 months ago

We've encountered the same issue. Has there been any solutions so far?

joaltoroc commented 4 months ago

I've the same issue, any solution?

(!) /node_modules/@sidebase/nuxt-auth/dist/runtime/middleware/auth.mjs is dynamically imported by virtual:nuxt:/.nuxt/middleware.mjs but also statically imported by /node_modules/@sidebase/nuxt-auth/dist/runtime/plugin.mjs, dynamic import will not move module into another chunk.
blorbis-fpg commented 3 months ago

Any update on this? Still facing the same error in version 0.7.1

youkei-zzz commented 3 months ago

This problem also exists in 0.7.2😅😅🥲

phoenix-ru commented 2 months ago

Please stop bumping, we know the issue exists (and we acknowledged it). If someone has a fix or better understanding how to unify middleware imports mentioned here https://github.com/sidebase/nuxt-auth/issues/669#issuecomment-1959424920, it would be much more useful to get this issue fixed