supabase-js icon indicating copy to clipboard operation
supabase-js copied to clipboard

supabase-js doesn't re-export types correctly when using pnpm

Open evelant opened this issue 2 years ago • 3 comments

Bug report

  • [X ] I confirm this is a bug with Supabase, not with my own application.
  • [X ] I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

Using pnpm 7.29.1 and typescript 5.0.2 re-exported types don't resolve correctly from @supabase/supabase-js. See this screenshot

image

Reproduction here: https://github.com/evelant/supabase-pnpm-bug pnpm install then open index.ts with vscode to see the problem. I'm not sure if this also happens with npm/yarn or if it's a resolution issue due to pnpm's stricter (more correct) package organization.

To Reproduce

  1. pnpm add @supabase/supabase-js
  2. add import type { RealtimeChannel, RealtimePostgresChangesPayload } from "@supabase/supabase-js" in any .ts file
  3. Observe Module '"@supabase/supabase-js"' has no exported member 'RealtimeChannel'.

Expected behavior

If supabase-js is going to re-export types from @supabase/gotrue-js, @supabase/realtime-js, and @supabase/functions-js they should resolve correctly in all typescript versions with all major package managers (pnpm, npm, yarn, deno).

Screenshots

image

System information

  • OS: macOS
  • Browser (if applies) N/A
  • Version of supabase-js: 2.13.1
  • Version of Node.js: 16.19.0
  • Version of typescript: 5.0.2
  • Version of pnpm: 7.29.1

Additional context

I'm not exactly sure what's going wrong here. There are so many configurations and quirks with module resolution in typescript it's practically impossible to keep track of them all. I'm pretty sure other packages use a similar technique of bundling several sub-libraries together and re-exporting them like supabase-js does with the other @supabase packages so this is likely a small config issue.

evelant avatar Mar 31 '23 00:03 evelant

Also of note, if I manually install the other packages (@supabase/realtime-js @supabase/functions-js @supabase/postgrest-js etc of the same version as depended upon by supabase-js) then the types seem to clash. I understand the desire for simplicity by putting everything in one package, but it might be more usable to make those other packages peer dependencies so they can be installed and used without these re-exporting issues.

evelant avatar Apr 01 '23 16:04 evelant

Can confirm, same issue happens when using npm. Would love if the typescript integration was smoother!

chelshaw avatar Aug 06 '23 18:08 chelshaw

Yep, I can also confirm that this issue does show up when I use pnpm.

  • OS: Linux (Fedora 38)
  • Version of supabase-js: 2.33.1
  • Version of pnpm: 8.6.12
  • Version of TypeScript: 5.0.4
  • Version of Node: v18.17.1

ironheart122 avatar Aug 29 '23 10:08 ironheart122