Solution:
I installed latest Ionic App Scripts build tools (which uses Webpack instead of Rollup) with this command:
npm install @ionic/app-scripts@beta
Then run npm run build
to test the new build process. Source topic
And then imported PouchDB like this:
import * as PouchDB from 'pouchdb';
// no need to use require()
anymore
Then tried this in a simple class:
private _db;
private _record;
ionViewDidLoad() { // WARNING: tutorial uses old "ionViewLoaded" which is not working anymore
console.log('starting db');
this._db = new PouchDB('birthday2');
this._record = { name: 'emre' };
this._db.post(this._record);
console.log("record ok");
}
And voila! Hope this helps someone
Note: I’ve also added typings of PouchDB, i’m not sure if it was necessary:
typings install --global --save dt~pouchdb dt~pouchdb-adapter-websql dt~pouchdb-browser dt~pouchdb-core dt~pouchdb-http dt~pouchdb-mapreduce dt~pouchdb-node dt~pouchdb-replication