-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
pouchdb-browser fails importing from 'events' #8641
Comments
Please assign me this issue, very much excited to mark may first contribution to this. |
Thanks for the issue and the work in progress.
|
This may be caused by calvinmetcalf/immediate#39. |
This solved it for me, seems the events package is needed |
Fixed by #8849 |
Issue
I just started on my project and still haven't actually used pouchdb at all yet. I'm in the middle of trying to upgrade a bunch of dependencies that are a few years old and don't even have the app running yet. One such update was migrating from webpack to vite as the build tool and I've come across a few issues.
We're using pouchdb-browser.
As defined in the documentation under the plugins section, says that pouchdb comes default with the pouchdb-replication plugin. pouchdb-replication however imports EE from 'events' which isn't available in the browser. It's throwing an error for me when the Changes class attempts to extend EE, because EE is null or not a constructor. Maybe this could be resolved by replacing imports for 'events' with something like 'eventemitter3'.
I also initially ran into an issue where the
immediate
lib (one of pouchdb-browser's dependencies) was throwing an error because themutation
lib within it attempts to initialize aMutation
variable toglobal.MutationObserver
and vite doesn't provide shims for node like webpack does (reference: vitejs/vite#2778 (comment)). This can be resolved by importing a module that setswindow.global = window
and make it your first import. I know this is outside the scope of pouchdb, but if someone is running into these issues, they're potentially doing something similar and wanted to document the cause.Info
Reproduce
I didn't go make a base case for this but I would think it should be easily reproducible by creating a new vite project and importing pouchdb-browser
The text was updated successfully, but these errors were encountered: