-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Info
- Environment: Browser, ESM, vite
- Platform: Chrome/FF
- Adapter: (pouchdb-adapter-memory + default idb?)
- Server: (vite)
Issue
I have a project and want to use PouchDB initially only in the browser with in-memory DB persisting to IndexedDB. As my starting point for figuring pouchDB out, introduce servers later.
Using pouchdb-browser, I've been getting the same issue from #8641 that was marked resolved in #8849: Uncaught TypeError: import_events.default is not a constructor
I saw that index.es.js has import EE from 'events'; but using events triggers Uncaught TypeError: setImmediate is not a function, so I used eventemitter3 and aliased it to events in vite.
Then I saw this familiar error: Uncaught ReferenceError: process is not defined, which I was not expecting given that I want to use this in the browser and that pouchdb-browser and pouchdb-adapter-memory both say they work in the browser. This seems to be raised by leveldb-adapter related code.
Patching process and global in vite leads us to:
Uncaught TypeError: superCtor.prototype is not an object or null from inherits/inherits.browser.js which appears to be this 2022 issue from the inherits package dependency. To fix this, I removed the Object.create version of the polyfill and used the other option.
Now, I'm left with Uncaught TypeError: this.setMaxListeners is not a function in LevelUP levelup.js:37
I couldn't find anything in the documentation about this, so is this a bug or is the 'works in the browser' part of pouchdb-adapter-memory conditional on polyfilling a load of Node APIs in the browser in your bundler?
Thank you for developing this project and I'd appreciate your comments.