electric-sql / pglite

Lightweight WASM Postgres with real-time, reactive bindings.
https://pglite.dev
Apache License 2.0
8.38k stars 165 forks source link

Polyfill CustomEvent in Node.js #1

Closed d3lm closed 7 months ago

d3lm commented 7 months ago

I noticed that it fails to run in Node.js because it relied on CustomEvent as a global which isn't exposed in Node.js unless you pass --experimental-global-customevent.

This PR adds a polyfill for CustomEvent when in Node.js. I tested this and it now works both on local Node.js as well as in WebContainer (which you could test once a new version is released). If you wanna try it yourself, you can fork this project and update the version once there's a new one that includes the fix.

samwillis commented 7 months ago

Thanks! Yep, I think CustomEvent is only in Node >= v20.