forked from html-next/ember-gestures
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
53 lines (39 loc) · 1.34 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
'use strict';
const path = require('path');
const Funnel = require('broccoli-funnel');
const MergeTrees = require('broccoli-merge-trees');
const map = require('broccoli-stew').map;
module.exports = {
name: 'ember-gestures',
included(app) {
this._super.apply(this, arguments);
// see: https://github.com/ember-cli/ember-cli/issues/3718
while (typeof app.import !== 'function' && app.app) {
app = app.app;
}
if (typeof app.import !== 'function') {
throw new Error('ember-gestures is being used within another addon or engine '
+ 'and is having trouble registering itself to the parent application.');
}
app.import('vendor/hammer.js');
app.import('vendor/AnimationFrame.js');
},
treeForVendor(vendorTree) {
let trees = [];
let hammerTree = new Funnel(path.dirname(require.resolve('hammerjs')), {
files: ['hammer.js']
});
hammerTree = map(hammerTree, (content) => `if (typeof FastBoot === 'undefined') { ${content} }`);
let animationFrameTree = new Funnel(path.dirname(require.resolve('animation-frame/AnimationFrame.js')), {
files: ['AnimationFrame.js'],
});
if (vendorTree !== undefined) {
trees.push(vendorTree);
}
trees.push(hammerTree, animationFrameTree);
return new MergeTrees(trees);
},
isDevelopingAddon() {
return false;
}
};