-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
54 lines (44 loc) · 1.5 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
/* eslint-env node */
'use strict';
const VersionChecker = require('ember-cli-version-checker');
let hasBeenWarned = false;
module.exports = {
name: 'ember-router-service-polyfill',
included() {
this._super.included.apply(this, arguments);
this._ensureThisImport();
var checker = new VersionChecker(this);
var emberVersion = checker.forEmber();
if (emberVersion.lt('2.16.0-alpha.1')) {
this.import('vendor/ember-router-service-polyfill/index.js');
} else if (this.parent === this.project && !hasBeenWarned && !this.project.isEmberCLIAddon()) {
this.ui.writeWarnLine('ember-router-service-polyfill is not required for Ember 2.16.0-beta.1 and later, please remove from your `package.json`.');
hasBeenWarned = true;
}
},
treeForVendor(rawVendorTree) {
let babelAddon = this.addons.find(addon => addon.name === 'ember-cli-babel');
let transpiledVendorTree = babelAddon.transpileTree(rawVendorTree, {
'ember-cli-babel': {
compileModules: false
}
});
return transpiledVendorTree;
},
_ensureThisImport: function() {
if (!this.import) {
this._findHost = function findHostShim() {
var current = this;
var app;
do {
app = current.app || app;
} while (current.parent.parent && (current = current.parent));
return app;
};
this.import = function importShim(asset, options) {
var app = this._findHost();
app.import(asset, options);
};
}
}
};