supabase / realtime-js

An isomorphic Javascript client for Supabase Realtime server.
https://supabase.com
MIT License
323 stars 58 forks source link

Issues with types and ESM/CJS module resolution in Node.js #424

Closed ericallam closed 2 months ago

ericallam commented 2 months ago

Bug report

Describe the bug

There are a number of different issues around type resolution & module resolution with this library in Node.js. As this package is a dependency of @supabase/supabase-js, and is imported in the main @supabase/supabase-js barrel file, then anyone trying to use @supabase/supabase-js in Node.js will face these issues unless they use a bundler that papers over these issues (I'm not sure how?).

To Reproduce

I've created a repo that reproduces the different issues that I've come across here:

https://github.com/ericallam/supabase-realtime-js-esbuild

Please refer to the README for reproduction steps.

Expected behavior

The types should resolve correctly in Node16/NodeNext, and the module resolution should as well.

System information

Additional context

We discovered these issues from user reports in Trigger.dev, as we use esbuild and have a new build system coming out shortly that outputs ESM.

ericallam commented 2 months ago

I've just updated the reproduction repo with how most of the module resolution problems go away if "type": "module" is removed from the package.json.

ericallam commented 2 months ago

It does look like this was recently added here: https://github.com/supabase/realtime-js/commit/95ab09e47ed7732eb21ac31eac743704bacc29aa

filipecabaco commented 2 months ago

change merged and fix released. thank you for reporting it 🙏