forked from emberjs/ember-cli-babel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (32 loc) · 1000 Bytes
/
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
module.exports = {
name: 'ember-cli-babel',
included: function(app) {
this._super.included.apply(this, arguments);
var options = getOptions(app.options['babel']);
var plugin = {
name: 'ember-cli-babel',
ext: 'js',
toTree: function(tree) {
return require('broccoli-babel-transpiler')(tree, options);
}
};
app.registry.add('js', plugin);
}
};
function getOptions(options) {
options = options || {};
// Ensure modules aren't compiled unless explicitly set to compile
options.blacklist = options.blacklist || ['es6.modules'];
if (options.compileModules === true) {
if (options.blacklist.indexOf('es6.modules') >= 0) {
options.blacklist.splice(options.indexOf('es6.modules'), 1);
}
} else {
if (options.blacklist.indexOf('es6.modules') < 0) {
options.blacklist.push('es6.modules');
}
}
// Ember-CLI inserts its own 'use strict' directive
options.blacklist.push('useStrict');
return options;
}