Skip to content
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

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

Open
2 tasks done
aldebout opened this issue Aug 8, 2024 · 9 comments
Open
2 tasks done

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

aldebout opened this issue Aug 8, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@aldebout
Copy link

aldebout commented Aug 8, 2024

Bug report

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

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

  • OS: macOS
  • Version of supabase-js: 2.45.1
  • Version of Node.js: 20.16.0

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
Copy link

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

@filipecabaco
Copy link
Contributor

now that we have native ws support I do think that we can remove ws which seems to be the source of the issue.

#426 here's a branch for us to use for testing to see if we can fix it by removing ws from realtime-js dependencies.

but after removing it I keep getting the same issue and the only dependency that uses it's node_modules/@expo/cli 😞 . what could be the way to fix it?

@aldebout
Copy link
Author

@filipecabaco I'm not sure what the next step is, how can I help you?

@filipecabaco
Copy link
Contributor

@aldebout maybe. it seems that the main issue was the fact that we had the ws dependency which created issues with expo. the PR #426 removes said dependency.

could you try to checkout the repo, checkout the branch fix/remove-ws-lib and override the dependency to check if it's not something related to my environment?

@aldebout
Copy link
Author

aldebout commented Oct 7, 2024

I tried using the branch but I'm having issues because package.json references the build outputs (/dist/...) and they're not in the github source code :/
When you tested locally, did you use npm with overrides or a local link? I've had issues with npm overrides in the past, it might work better with yarn or pnpm.

@filipecabaco
Copy link
Contributor

I need to try it again but if I'm not mistaken I did use overrides... maybe I should just make an example with just realtime-js and expo to make it easier to test out without overrides and just importing the "fix branch"

@DanielVolchek
Copy link

DanielVolchek commented Nov 27, 2024

Any update? Currently running into this issue as well

@filipecabaco

@filipecabaco
Copy link
Contributor

filipecabaco commented Nov 28, 2024

sorry not yet as we were tackling other issues on the server side. I also need to do another fix in realtime-js and then I will pick this one up again

as mentioned above I'm going to create a new repo with realtime-js so we can test this in a more consistent way to find a fix 👀

@DanielVolchek
Copy link

@filipecabaco

OK, no problem. I can confirm that by using patch package to imitate your pr like so it solved the issue for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants