-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
56 lines (47 loc) · 1.51 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
'use strict';
const VersionChecker = require('ember-cli-version-checker');
const NATIVE_SUPPORT_VERSION = '3.22.0-alpha.1';
let hasBeenWarned = false;
module.exports = {
name: require('./package').name,
included() {
this._super.included.apply(this, arguments);
this._ensureThisImport();
const checker = new VersionChecker(this.project);
const emberVersion = checker.for('ember-source');
if (emberVersion.lt(NATIVE_SUPPORT_VERSION)) {
this.import('vendor/ember-destroyable-polyfill/index.js');
} else if (this.parent === this.project && !hasBeenWarned) {
this.ui.writeWarnLine(
`${this.name} is not required for Ember ${NATIVE_SUPPORT_VERSION} and later, please remove from your 'package.json'.`
);
hasBeenWarned = true;
}
},
treeForVendor(tree) {
const babel = this.addons.find((a) => a.name === 'ember-cli-babel');
return babel.transpileTree(tree, {
babel: this.options.babel,
'ember-cli-babel': {
compileModules: false,
},
});
},
_ensureThisImport() {
if (!this.import) {
this._findHost = function findHostShim() {
let current = this;
let app;
do {
app = current.app || app;
// eslint-disable-next-line no-cond-assign
} while (current.parent.parent && (current = current.parent));
return app;
};
this.import = function importShim(asset, options) {
const app = this._findHost();
app.import(asset, options);
};
}
},
};