Skip to content

Commit

Permalink
add fastboot support for ember-pouch
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanley Stuart committed Jan 31, 2016
1 parent 25c3866 commit ce1676b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
35 changes: 25 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,30 @@ module.exports = {
},

included: function included(app) {
var bowerDir = app.bowerDirectory;

app.import(bowerDir + '/pouchdb/dist/pouchdb.js');
app.import(bowerDir + '/relational-pouch/dist/pouchdb.relational-pouch.js');
app.import('vendor/ember-pouch/shim.js', {
type: 'vendor',
exports: {
'pouchdb': [ 'default' ]
}
});
if (isFastBoot()) {
app.import('vendor/ember-pouch/ember-pouch-fastboot.js');
} else {
var bowerDir = app.bowerDirectory;

app.import(bowerDir + '/pouchdb/dist/pouchdb.js');
app.import(bowerDir + '/relational-pouch/dist/pouchdb.relational-pouch.js');
app.import('vendor/ember-pouch/shim.js', {
type: 'vendor',
exports: {
'pouchdb': [ 'default' ]
}
});
}
}
};

// Steal *all the things* from github.com/tomdale/ember-network !

var funnel = require('broccoli-funnel');

// Checks to see whether this build is targeting FastBoot. Note that we cannot
// check this at boot time--the environment variable is only set once the build
// has started, which happens after this file is evaluated.
function isFastBoot() {
return process.env.EMBER_CLI_FASTBOOT === 'true';
}
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@
"ember-try": "~0.0.8"
},
"dependencies": {
"broccoli-funnel": "^1.0.1",
"ember-cli-babel": "^5.1.5",
"ember-cli-version-checker": "1.1.5"
"ember-cli-version-checker": "1.1.5",
"pouchdb": "^5.2.1",
"relational-pouch": "^1.4.0"
},
"ember-addon": {
"configPath": "tests/dummy/config"
"configPath": "tests/dummy/config",
"fastbootBootDependencies": ["pouchdb", "relational-pouch"]
}
}
13 changes: 13 additions & 0 deletions vendor/ember-pouch/ember-pouch-fastboot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
;(function() {
'use strict';

define('pouchdb', ['exports'], function (__exports__) {
var PouchDB = FastBoot.require('pouchdb');

// Register plugins!
PouchDB.plugin(FastBoot.require('relational-pouch'));

__exports__['default'] = PouchDB;
});

})();

0 comments on commit ce1676b

Please sign in to comment.