-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.js
49 lines (37 loc) · 1.23 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
'use strict';
const VersionChecker = require('ember-cli-version-checker');
module.exports = {
name: require('./package').name,
init() {
this._super.init && this._super.init.apply(this, arguments);
let checker = new VersionChecker(this.project);
let emberVersion = checker.forEmber();
let emberDataVersion = checker.for('ember-data');
this._shouldPolyfillEmber = emberVersion.lt('3.10.0-alpha.0')
this._shouldPolyfillData = emberDataVersion.exists() && emberDataVersion.lt('3.13.0-alpha.0');
},
included() {
this._super.included.apply(this, arguments);
if (this._shouldPolyfillEmber) {
this.import('vendor/ember-decorators-polyfill/ember-fix.js');
}
if (this._shouldPolyfillData) {
this.import('vendor/ember-decorators-polyfill/data-fix.js');
}
},
treeForVendor(rawVendorTree) {
if (!this._shouldPolyfillEmber && !this._shouldPolyfillData) {
return;
}
let babelAddon = this.addons.find(
addon => addon.name === 'ember-cli-babel'
);
let transpiledVendorTree = babelAddon.transpileTree(rawVendorTree, {
babel: this.options.babel,
'ember-cli-babel': {
compileModules: false,
},
});
return transpiledVendorTree;
},
};