supabase / postgrest-js

Isomorphic JavaScript client for PostgREST.
https://supabase.com
MIT License
964 stars 128 forks source link

1.8.1 @supabase/node-fetch dependencies breaks browser builds #465

Closed NiklasPor closed 10 months ago

NiklasPor commented 10 months ago

Bug report

Describe the bug

After installing the latest dependencies (upgrading to version 1.8.1 of this package), browser builds (plain react app), start breaking because global is undefined. This is a classic error when node modules, in this case @supabase/node-fetch, are imported in a browser context.

The errors are thrown from this file: ../node_modules/.pnpm/@supabase+node-fetch@2.6.13/node_modules/@supabase/node-fetch/lib/index.mjs

Expected behavior

Not breaking

Workaround

Pin your @supabase/postgrest-js version to 1.8.0.

E.g. with pnpm:

// package.json
  "resolutions": {
    "@supabase/postgrest-js": "1.8.0"
  }

Screenshots

image image

System information

Additional context

silentworks commented 10 months ago

I've reported this to the team and we will get a fix out soon.

arxpoetica commented 7 months ago

This seems to be broken again with the latest release.

silentworks commented 7 months ago

@arxpoetica can you provide some steps to reproduce this please? or provide a minimal reproducible example repo.

arxpoetica commented 7 months ago

Hey, yes—might not come back to it for a while, but I will.

jacob-8 commented 6 months ago

@arxpoetica can you provide some steps to reproduce this please? or provide a minimal reproducible example repo.

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

Steps to repro:

I think there's something deeper here to figure out related to how Vite 5 handles file vs. Vite 4 - I'm not sure if this is a Vite bug, or a SvelteKit bug, or a Supabase bug. For reference, in Vite 4, @supabse/node-fetch loads a browser version client-side:

image

But in Vite 5 it loads the server version on the client: image

mkilpatrick commented 6 months ago

https://publint.dev/@supabase/postgrest-js@1.9.0

jacob-8 commented 6 months ago

Circling back, just wanted to update that there is no bug when using Vite 5 with SvelteKit 2 which also uses @sveltejs/vite-plugin-svelte v3 - https://stackblitz.com/edit/sveltejs-kit-template-default-x9ybq2?file=package.json

JTCorrin commented 5 months ago

I've got this issue with sveltekit 2 and vite 5

bates64 commented 5 months ago

I ran into this bug following Creating a Supabase client for SSR | Supabase Docs.

@supabase/ssr 0.0.10 @supabase/supabase-js 2.32.0 @supabase/node-fetch 2.6.15

gpaiva985 commented 4 months ago

I've got this issue with supabase using sveltekit 2 and vite 5. In my case, it was possible to fix it by updating PNPM to the latest version (v8.15.3). After that, I deleted the pnpm-lock.yaml file, the .svelte-kit and node_modules folders and ran pnpm install and everything worked.

matrixOperator commented 4 months ago

I've got this issue with supabase using sveltekit 2 and vite 5. In my case, it was possible to fix it by updating PNPM to the latest version (v8.15.3). After that, I deleted the pnpm-lock.yaml file, the .svelte-kit and node_modules folders and ran pnpm install and everything worked.

Had exactly the same condition as you, and this solution worked. Thank you so much!!!

weicheng95 commented 2 months ago

I've got this issue with supabase using sveltekit 2 and vite 5. In my case, it was possible to fix it by updating PNPM to the latest version (v8.15.3). After that, I deleted the pnpm-lock.yaml file, the .svelte-kit and node_modules folders and ran pnpm install and everything worked.

If you are generating project using npm create svelte@latest my-app, remember to run pnpm update

RyannGalea commented 2 months ago

I ran into this bug following Creating a Supabase client for SSR | Supabase Docs.

@supabase/ssr 0.0.10 @supabase/supabase-js 2.32.0 @supabase/node-fetch 2.6.15

Were you able to resolve it?