'A module cannot import itself' error when bundling pouchdb-adapter-websql & Pouchy with Rollup
tabrindle opened this issue · comments
Issue
This was crosspost to PouchDB - pouchdb/pouchdb#6345
There seems to be a new bug between PouchDB release 6.1.1 and 6.1.2 where the websql adapter will cause rollup to crash while bundling with Pouchy.
A module cannot import itself (/Users/tabrindle/Developer/media-hybrid/node_modules/pouchdb-adapter-websql/node_modules/pouchdb-utils/lib/index-browser.es.js)
Error: A module cannot import itself (/Users/tabrindle/Developer/media-hybrid/node_modules/pouchdb-adapter-websql/node_modules/pouchdb-utils/lib/index-browser.es.js)
at /Users/tabrindle/Developer/media-hybrid/node_modules/rollup/src/Bundle.js:335:14
The error suggests this is the culprit: import { nextTick } from 'pouchdb-utils';
from inside pouchdb-utils/lib/index-browser.es.js
This file is not present in 6.1.1.
Here is my rollup config:
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';
import builtins from 'rollup-plugin-node-builtins';
import globals from 'rollup-plugin-node-globals';
import { minify } from 'uglify-js';
export default {
entry: 'resources/libs/index-rollup.js',
dest: 'resources/libs/bundle.js',
format: 'iife',
moduleName: 'bundle',
plugins: [
builtins(),
resolve({
jsnext: true,
main: true,
browser: true,
preferBuiltins: false
}),
commonjs({
include: 'node_modules/**'
}),
globals(),
uglify({
compress: {
unused: false
}
}, minify)
]
};
Based on the resolves I have configured, I realize that rollup will select this new file over the old, but what I dont understand is why rollup has an issue with it.
Just a shot in the dark, I'm guessing this may have to do with @nolanlawson 's pulls #6162 (Make polyfills extractable) or #6170 (dont expost src to npm) based on the commit logs to these files, and the changelog from this release.
This may not actually be a bug, just an unintended side effect of how I am using the package - Of note, I am using Pouchy 11.0.3, which uses pouchdb-core 6.0.6. Will also crosspost this issue to Pouchy.
Info
- Environment: Node.js v6.10.0
- Adapter: WebSQL
Reproduce
Install Pouchy 11.0.3 and pouchdb-adapter-websql@6.1.2 and attempt to bundle them with rollup