Skip to content

Commit

Permalink
Made pouch a peer dep
Browse files Browse the repository at this point in the history
  • Loading branch information
jglanz committed Dec 9, 2016
1 parent 53aa1c5 commit 58ce1d2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .idea/libraries/tsconfig_roots.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/libraries/typestore_node_modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/typestore-plugin-pouchdb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"test": "gulp ts-compile && mocha src/test/**/*.spec.js"
},
"dependencies": {
"peerDependencies": {
"pouchdb": "^5.4.5",
"pouchdb-find": "^0.10.3",
"pouchdb-quick-search": "^1.1.3"
Expand Down
15 changes: 12 additions & 3 deletions packages/typestore-plugin-pouchdb/src/PouchDBSetup.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
/**
* Import PouchDB
* Load a specific pouchdb module
*
* @param moduleName
* @returns {any}
*/
function loadPouchDBModule(moduleName) {
return (moduleName === 'pouchdb-browser') ? require('pouchdb-browser') : require('pouchdb')
}


/**
* Import PouchDB
*/
function loadPouchDB() {
const
g = global as any,
Expand All @@ -11,7 +19,8 @@ function loadPouchDB() {

console.log(`Loading PouchDB from Global`,g.PouchDB,PouchModuleName)

return g.PouchDB || require(PouchModuleName)
return g.PouchDB || loadPouchDBModule(PouchModuleName)

}


Expand Down

0 comments on commit 58ce1d2

Please sign in to comment.