-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.js
57 lines (46 loc) · 1.48 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
54
55
56
57
'use strict';
module.exports = {
name: require('./package').name,
included() {
this._super.included.apply(this, arguments);
let app = this._findHost();
if (!app.vendorFiles || !app.vendorFiles['jquery.js']) {
app.import('vendor/jquery/jquery.js', { prepend: true });
}
app.import('vendor/shims/jquery.js');
let optionalFeatures = app.project.findAddonByName(
'@ember/optional-features'
);
let integrationTurnedOff =
optionalFeatures &&
!optionalFeatures.isFeatureEnabled('jquery-integration');
if (!integrationTurnedOff) {
app.import('vendor/jquery/component.dollar.js');
}
},
treeForVendor: function (tree) {
const BroccoliMergeTrees = require('broccoli-merge-trees');
const Funnel = require('broccoli-funnel');
const resolve = require('resolve');
const path = require('path');
let jqueryPath;
try {
jqueryPath = path.dirname(
resolve.sync('jquery/package.json', { basedir: this.project.root })
);
} catch (error) {
jqueryPath = path.dirname(require.resolve('jquery/package.json'));
}
let jquery = new Funnel(jqueryPath + '/dist', {
destDir: 'jquery',
files: ['jquery.js'],
});
let babelAddon = this.project.findAddonByName('ember-cli-babel');
let transpiledTree = babelAddon.transpileTree(tree, {
'ember-cli-babel': {
compileModules: false,
},
});
return new BroccoliMergeTrees([jquery, transpiledTree]);
},
};