Skip to content

Commit c27b3f0

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

File tree

3 files changed

+44
-12
lines changed

3 files changed

+44
-12
lines changed

index.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,30 @@ module.exports = {
2626
},
2727

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

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,14 @@
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": {
59-
"configPath": "tests/dummy/config"
62+
"configPath": "tests/dummy/config",
63+
"fastBootDependencies": ["pouchdb", "relational-pouch"]
6064
}
6165
}
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)