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

failed to use pglite as driver with expo web #1423

Closed
MJRT opened this issue Jul 7, 2024 · 4 comments
Closed

failed to use pglite as driver with expo web #1423

MJRT opened this issue Jul 7, 2024 · 4 comments

Comments

@MJRT
Copy link

MJRT commented Jul 7, 2024

I'm tried to pick up examples/web-pglite merge to examples/expo but failed.

console output:

AppEntry.bundle:87829 
Uncaught Syntax Error: Cannot use 'import.meta' outside a module

version: expo sdk51, react-native-web 0.19.10, electric-sql 0.12.0, pglite 0.1.5

Here are my modification steps:

  1. I'm used examples/expo as basement, and mkdir ./src/ElectricProvider
  2. move ./ElectricProvider.tsx to ./src/ElectricProvider/index.tsx
  3. move web-pglite-ElectricProvider.tsx to ./src/ElectricProvider/index.web.tsx
  4. change ./* to ../* in index.tsx and index.web.tsx
  5. install expo web dependences: npx expo install react-native-web react-dom @expo/metro-runtime
  6. set "target": "es2020", "module": "esnext", in tsconfig.json

After coded, expo go is still right on my android phone, but web page is blank page with console error.

I tried some solutions from chatgpt and Google but they are still not work,
and would like to know how to use it on expo web.

Copy link

linear bot commented Jul 7, 2024

@MJRT
Copy link
Author

MJRT commented Jul 8, 2024

After investigated, expo web (sdk51) use metro as bundler, but metro is not support ESM now (Support ESM react-native.config files · Issue #2167 · react-native-community/cli (github.com))

I tried use babel-plugin-transform-import-meta and transform-dirname-filename as babel transform plugin, but it's still failed.

Does anyone know how to make it compatible with CommonJS? I think this could further enhance Electric-sql's influence in the community.

@MJRT
Copy link
Author

MJRT commented Jul 10, 2024

this repo can reproduce easily, https://github.com/MJRT/import-meta-url-error-on-web

@KyleAMathews
Copy link
Contributor

👋 we've been working the last month on a rebuild of the Electric server over at a temporary repo https://github.com/electric-sql/electric-next/

You can read more about why we made the decision at https://next.electric-sql.com/about

We're really excited about all the new possibilities the new server brings and we hope you'll check it out soon and give us your feedback.

We're now moving the temporary repo back here. As part of that migration we're closing all the old issues and PRs. We really appreciate you taking the time to investigate and report the bug!

@KyleAMathews KyleAMathews closed this as not planned Won't fix, can't repro, duplicate, stale Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants