pouchdb-community / pouchdb-replication-stream

Replicate PouchDB/CouchDB databases with Node.js-style streams
Apache License 2.0
189 stars 58 forks source link

es modules issue #69

Open oliviertassinari opened 7 years ago

oliviertassinari commented 7 years ago

I have noticed the following issue in my console:

TypeError: Promise is not a constructor at PouchDB$3.eval (pouch-utils.js:51) at PouchDB$3.eval [as dump] (pouch-utils.js:31) at eval (API.js:125) at

https://github.com/pouchdb-community/pouchdb-replication-stream/blob/223344f03b8cc924f490d7893dae4131a782b3b2/lib/pouch-utils.js#L3

Applying the following diff in pouchdb-replication-stream/lib/pouch-utils.js fix my issue:

'use strict';

var Promise = require('pouchdb-promise');
+
+Promise = Promise.default
oliviertassinari commented 7 years ago

The semver of pouchdb-promise seems not to have been respected. I think that it's the root of the issue. The latest version is 6.3.4, the export must have been changed along the way.

https://github.com/pouchdb-community/pouchdb-replication-stream/blob/223344f03b8cc924f490d7893dae4131a782b3b2/package.json#L42

isumix commented 5 years ago

There is solution to resolve alias in webpack config:

    resolve: {
      alias: {
        'pouchdb-promise$': "pouchdb-promise/lib/index.js"
      }
    }

see here: https://github.com/pouchdb-community/pouchdb-quick-search/issues/81

But I could't find how to resolve alias in create-react-app without ejecting. So I've just imported plugin from dist like: var replicationStream = require('pouchdb-replication-stream/dist/pouchdb.replication-stream.min.js'); Hope this helps someone. Is there any better way of doing it?