diff --git a/index.js b/index.js index cff2ff5..cac4013 100644 --- a/index.js +++ b/index.js @@ -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 @@ -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'; +} diff --git a/package.json b/package.json index cf67bc3..ee824b6 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/vendor/ember-pouch/ember-pouch-fastboot.js b/vendor/ember-pouch/ember-pouch-fastboot.js new file mode 100644 index 0000000..c5d0e9a --- /dev/null +++ b/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; + }); + +}();