I use the following workaround:
In package.json, add the following dependency, devDependencies and config:
{
...
"dependencies": {
...
"pouchdb": "^6.0.6",
...
},
"devDependencies": {
...
"rollup-plugin-json": "^2.0.2",
"rollup-plugin-node-builtins": "^1.2.1",
"rollup-plugin-node-globals": "^1.0.9",
...
},
...
"config": {
"ionic_rollup": "./config/rollup.config.js"
},
...
}
Add a file config/rollup.config.js:
var ngTemplate = require('../node_modules/@ionic/app-scripts/dist/plugins/ng-template').ngTemplate;
var nodeResolve = require('rollup-plugin-node-resolve');
var builtins = require('rollup-plugin-node-builtins');
var commonjs = require('rollup-plugin-commonjs');
var globals = require('rollup-plugin-node-globals');
var json = require('rollup-plugin-json');
// https://github.com/rollup/rollup/wiki/JavaScript-API
var rollupConfig = {
/**
* entry: The bundle's starting point. This file will
* be included, along with the minimum necessary code
* from its dependencies
*/
entry: './.tmp/app/main.dev.js',
/**
* sourceMap: If true, a separate sourcemap file will
* be created.
*/
sourceMap: true,
/**
* format: The format of the generated bundle
*/
format: 'iife',
/**
* dest: the output filename for the bundle in the buildDir
*/
dest: 'main.js',
/**
* plugins: Array of plugin objects, or a single plugin object.
* See https://github.com/rollup/rollup/wiki/Plugins for more info.
*/
plugins: [
ngTemplate(),
builtins(),
json(),
nodeResolve({
main: true,
module: true,
jsnext: true,
browser: true,
extensions: ['.js', '.json']
}),
commonjs({
namedExports: {
'node_modules/js-extend/extend.js': ['extend']
}
}),
globals()
]
};
if (process.env.IONIC_ENV == 'prod') {
// production mode
rollupConfig.entry = '.tmp/app/main.prod.js';
}
module.exports = rollupConfig;
And change the following:
import * as PouchDB from 'pouchdb'
into:
import PouchDB from 'pouchdb'
You still have a typescript error when linting, but for me this worked and I can use the PouchDB.