-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
Copy pathindex.js
114 lines (95 loc) · 3.01 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
'use strict';
const fs = require('fs');
const path = require('path');
const resolve = require('resolve');
const paths = {};
const absolutePaths = {};
function add(paths, name, path) {
Object.defineProperty(paths, name, {
configurable: false,
get: function() {
return path;
},
});
}
add(paths, 'prod', 'vendor/ember/ember.prod.js');
add(paths, 'debug', 'vendor/ember/ember.debug.js');
add(paths, 'testing', 'vendor/ember/ember-testing.js');
add(paths, 'jquery', 'vendor/ember/jquery/jquery.js');
add(
absolutePaths,
'templateCompiler',
path.join(__dirname, '..', 'dist', 'ember-template-compiler.js')
);
module.exports = {
init: function() {
this._super.init && this._super.init.apply(this, arguments);
if ('ember' in this.project.bowerDependencies()) {
// TODO: move this to a throw soon.
this.ui.writeWarnLine(
'Ember.js is now provided by node_module `ember-source`, please remove it from bower'
);
}
// resets `this.root` to the correct location by default ember-cli
// considers `__dirname` here to be the root, but since our main entry
// point is within a subfolder we need to correct that
this.root = path.join(__dirname, '..');
},
name: 'ember-source',
paths: paths,
absolutePaths: absolutePaths,
treeForVendor: function() {
let Funnel = require('broccoli-funnel');
let MergeTrees = require('broccoli-merge-trees');
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: 'ember/jquery',
files: ['jquery.js'],
});
let emberSourceDistPath = path.join(__dirname, '..', 'dist');
let emberCliBabel = this.addons.find(a => a.name === 'ember-cli-babel');
let needsLegacyBuild = [
'transform-template-literals',
'transform-literals',
'transform-arrow-functions',
'transform-destructuring',
'transform-spread',
'transform-parameters',
'transform-computed-properties',
'transform-shorthand-properties',
'transform-block-scoping',
].some(p => emberCliBabel.isPluginRequired(p));
if (needsLegacyBuild) {
emberSourceDistPath = path.join(emberSourceDistPath, 'legacy');
}
let emberFiles = [
'ember-template-compiler.js',
'ember-testing.js',
'ember.debug.js',
'ember.min.js',
'ember.prod.js',
]
.map(function(file) {
return [file, file.replace('.js', '.map')];
})
.reduce(function(flat, jsAndMap) {
return flat.concat(jsAndMap);
}, [])
.filter(function(file) {
let fullPath = path.join(emberSourceDistPath, file);
return fs.existsSync(fullPath);
});
let ember = new Funnel(emberSourceDistPath, {
destDir: 'ember',
files: emberFiles,
});
return new MergeTrees([ember, jquery]);
},
};