-
Notifications
You must be signed in to change notification settings - Fork 83
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
Webpack: Promise is not a constructor #81
Comments
Thanks so much for posting the results f your investigation on this. I'm sure I'm not the only one you've saved loads of debugging time for. Here's a slightly sorter config without the const path = require('path');
const webpackConfig = require('@ionic/app-scripts/config/webpack.config.js');
module.exports = function () {
webpackConfig[process.env.IONIC_ENV].resolve.alias = {
"@environment": path.resolve(__dirname + '/../../src/config/config.' + process.env.IONIC_ENV + '.ts'),
'pouchdb-promise$': "pouchdb-promise/lib/index.js"
};
return webpackConfig;
}; |
Hi, I have problems. I am new to this and I have the same error, where I paste this code that they have put. Help me please |
@davidspalaciof You need to add a file somewhere in your project that contains the code above. Then reference that file in your package.json as follows:
In the example above I have a folder named "config" at the root of my project that contains a file named webpack.config.js. |
@silverbackdan Your solution works very nicely - thank you. @cah-ricksuggs thanks to you for the original solution. |
Hi, I get the same issue using pouchdb-replication-stream. |
Is there an explanation for why this works? |
Great library, I am really getting into the pouchdb ecosystem!
I received a error message stating that "Promise is not a constructor." After investigating the issue, I noticed that pouch-quick-search depends on an outdated version of pouchdb-promise, which created a version conflict in my webpack bundle.
Someone proposed just modifying pouch-utils to
require('pouchdb-promise').default
but that would break when running in nodejs.I was able to workaround the issue by augmenting the webpack configuration of my angular app, by adding a resolve alias to always pull in the newer version of pouchdb-promise, and using the index.js rather than index.es.js
Is there an easy way to update this library to distribute a ES6 module version for webpack to use, and a ES5 (CommonJS?) version for nodejs to use? I noticed other pouchdb libraries are using the "main" and "module" package.json properties to achieve this. I'd be happy to open a pull request after getting some direction.
The text was updated successfully, but these errors were encountered: