From ce1676b5910e843f445cd89a670640198c77c3c9 Mon Sep 17 00:00:00 2001 From: Stanley Stuart Date: Sat, 30 Jan 2016 21:09:21 -0600 Subject: [PATCH] add fastboot support for ember-pouch --- index.js | 35 +++++++++++++++------- package.json | 8 +++-- vendor/ember-pouch/ember-pouch-fastboot.js | 13 ++++++++ 3 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 vendor/ember-pouch/ember-pouch-fastboot.js diff --git a/index.js b/index.js index cff2ff5..ad5cced 100644 --- a/index.js +++ b/index.js @@ -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'; +} diff --git a/package.json b/package.json index cf67bc3..3e2c4ea 100644 --- a/package.json +++ b/package.json @@ -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"] } } diff --git a/vendor/ember-pouch/ember-pouch-fastboot.js b/vendor/ember-pouch/ember-pouch-fastboot.js new file mode 100644 index 0000000..d287587 --- /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; + }); + +})();