supabase / supabase-js

An isomorphic Javascript client for Supabase. Query your Supabase database, subscribe to realtime events, upload and download files, browse typescript examples, invoke postgres functions via rpc, invoke supabase edge functions, query pgvector.
https://supabase.com
MIT License
3.24k stars 268 forks source link

Can't use with unstable_enablePackageExports metro option (expo) #1258

Open aldebout opened 2 months ago

aldebout commented 2 months ago

Cross-posting https://github.com/supabase/realtime-js/issues/415 because I'm not sure you're monitoring the issues on the other repo :)

Bug report

Describe the bug

When using @supabase/supabase-js in an expo react native project, if I use the unstable_enablePackageExports with the metro bundler, bundling fails with the following error:

To Reproduce

  1. Generate a new expo app
  2. Add @supabase/supabase-js as a dependency
  3. Create a supabase client in the main _layout.tsx file
  4. Run npx expo customize metro.config.js
  5. Add config.resolver.unstable_enablePackageExports = true; to metro.config.js
  6. Add ios.bundleIdentifier to app.json
  7. Run npx expo run:ios

Repro repo: https://github.com/aldebout/supabase-expo-exports-issue

Expected behavior

No crash

Screenshots

image

System information

Additional information

Opening here because the error message I got in my actual project was

The package at "../../node_modules/@supabase/realtime-js/node_modules/ws/lib/stream.js" attempted to import the Node standard library module "stream".
It failed because the native React runtime does not include the Node standard library.
practiv-wamci commented 1 month ago

Is there any update on this? I've run into the same issue

adamwett commented 4 weeks ago

I've also run into this when trying to use Storybook and Expo.

marcocondrache commented 1 week ago

I'm able to run it by manually specifying nodeModulesPaths and setting disableHierarchicalLookup to true (in a monorepo setup).