Skip to content

Commit 522e727

Browse files
author
Stanley Stuart
committed
add fastboot support for ember-pouch
1 parent 25c3866 commit 522e727

File tree

3 files changed

+44
-11
lines changed

3 files changed

+44
-11
lines changed

index.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
'use strict';
33

44
var VersionChecker = require('ember-cli-version-checker');
5+
var funnel = require('broccoli-funnel')
56

67
// We support Ember-Data 1.13.x and 2.x. Checking for this is complicated
78
// because the effective version of ember-data is controlled by bower for
@@ -26,15 +27,31 @@ module.exports = {
2627
},
2728

2829
included: function included(app) {
29-
var bowerDir = app.bowerDirectory;
30-
31-
app.import(bowerDir + '/pouchdb/dist/pouchdb.js');
32-
app.import(bowerDir + '/relational-pouch/dist/pouchdb.relational-pouch.js');
33-
app.import('vendor/ember-pouch/shim.js', {
34-
type: 'vendor',
35-
exports: {
36-
'pouchdb': [ 'default' ]
37-
}
38-
});
30+
if (isFastBoot()) {
31+
app.import('vendor/ember-pouch/ember-pouch-fastboot.js');
32+
} else {
33+
var bowerDir = app.bowerDirectory;
34+
35+
app.import(bowerDir + '/pouchdb/dist/pouchdb.js');
36+
app.import(bowerDir + '/relational-pouch/dist/pouchdb.relational-pouch.js');
37+
app.import('vendor/ember-pouch/shim.js', {
38+
type: 'vendor',
39+
exports: {
40+
'pouchdb': [ 'default' ]
41+
}
42+
});
43+
}
3944
}
4045
};
46+
47+
// Steal *all the things* from github.com/tomdale/ember-network !
48+
49+
var path = require('path');
50+
var funnel = require('broccoli-funnel');
51+
52+
// Checks to see whether this build is targeting FastBoot. Note that we cannot
53+
// check this at boot time--the environment variable is only set once the build
54+
// has started, which happens after this file is evaluated.
55+
function isFastBoot() {
56+
return process.env.EMBER_CLI_FASTBOOT === 'true';
57+
}

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@
5252
"ember-try": "~0.0.8"
5353
},
5454
"dependencies": {
55+
"broccoli-funnel": "^1.0.1",
5556
"ember-cli-babel": "^5.1.5",
56-
"ember-cli-version-checker": "1.1.5"
57+
"ember-cli-version-checker": "1.1.5",
58+
"pouchdb": "^5.2.1",
59+
"relational-pouch": "^1.4.0"
5760
},
5861
"ember-addon": {
5962
"configPath": "tests/dummy/config"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
;(function() {
2+
'use strict';
3+
4+
define('pouchdb', ['exports'], function (__exports__) {
5+
var PouchDB = FastBoot.require('pouchdb');
6+
7+
// Register plugins!
8+
PouchDB.plugin(FastBoot.require('relational-pouch'));
9+
10+
__exports__['default'] = PouchDB;
11+
});
12+
13+
}();

0 commit comments

Comments
 (0)