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 522e727
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 11 deletions.
37 changes: 27 additions & 10 deletions index.js
Expand Up @@ -2,6 +2,7 @@
'use strict';

var VersionChecker = require('ember-cli-version-checker');
var funnel = require('broccoli-funnel')

// We support Ember-Data 1.13.x and 2.x. Checking for this is complicated
// because the effective version of ember-data is controlled by bower for
Expand All @@ -26,15 +27,31 @@ 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 path = require('path');
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';
}
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -52,8 +52,11 @@
"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"
Expand Down
13 changes: 13 additions & 0 deletions vendor/ember-pouch/ember-pouch-fastboot.js
@@ -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 522e727

Please sign in to comment.