-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Vite 4 to Vite 5 causes @supabase/node-fetch to use server module in browser - leads to global is not defined
error
#15274
Comments
I posted this link in the supabase issue, but it's most likely how they're incorrectly exporting in their package.json. |
Seems like this is a bug that you'd need the latest version (v3) of I'd suggest waiting for SvelteKit to support Vite 5 first, or you can try overriding
|
@bluwy I sort of thought I might be jumping the gun. Sure, I'll just wait for SvelteKit to come along with support for Vite 5. Thanks for the quick answer! |
Thank you for doing that! I had not known of that tool before and hopefully that will also help improve things. |
I can confirm that there is no bug when using Vite 5 with SvelteKit 2 and @sveltejs/vite-plugin-svelte v3 - https://stackblitz.com/edit/sveltejs-kit-template-default-x9ybq2?file=package.json |
Describe the bug
I'm updating a SvelteKit project from Vite 4 to 5 and Supabase throws an error once the client hydrates
global is not defined
. I'm not sure if this is a Vite bug, a SvelteKit bug, or a Supabase bug. But it's a bug relating to how Vite chooses which server or browser file to serve up. For reference, in Vite 4, @supabse/node-fetch loads a browser version (browser.js) client-side:But in Vite 5 it loads the server version (index.js) on the client thus causing the problem:
I've also posted this in Supabase: supabase/postgrest-js#465 - I hope it's just a simple issue of Supabase needing to update a few lines in how they define imports in a package.json.
Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-8hs1lt?file=package.json
Steps to reproduce
Works with Vite 4: https://stackblitz.com/edit/sveltejs-kit-template-default-tnrxgs?file=package.json
Doesn't work with Vite 5: https://stackblitz.com/edit/sveltejs-kit-template-default-8hs1lt?file=package.json
npm i -D @supabase/supabase-js
npm run dev
System Info
System: OS: Linux 5.0 undefined CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 0 Bytes / 0 Bytes Shell: 1.0 - /bin/jsh Binaries: Node: 18.18.0 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 9.4.2 - /usr/local/bin/npm pnpm: 8.10.5 - /usr/local/bin/pnpm npmPackages: vite: ^5.0.6 => 5.0.6
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: