This repository has been archived by the owner on Sep 21, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.js
59 lines (41 loc) · 1.54 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
'use strict';
let VersionChecker = require('ember-cli-version-checker');
module.exports = {
name: require('./package').name,
init() {
this._super.init.apply(this, arguments);
let checker = new VersionChecker(this);
let emberVersion = checker.forEmber();
this.shouldInclude = emberVersion.gte('2.0.0-beta.1');
},
included() {
this._super.included.apply(this, arguments);
if (!this.shouldInclude) { return; }
// grab the original _findHost, before ember-engines can muck with it
let proto = Object.getPrototypeOf(this);
let host = proto._findHost.call(this);
// using `app.import` here because we need to ensure this ends up in the
// top level vendor.js (not engine-vendor.js as would happen with
// this.import inside an engine)
host.import('vendor/patch-generate-controller/index.js');
let config = this.project.config(process.env.EMBER_ENV);
this.hasLegacyViewSupport = config.EmberENV._ENABLE_LEGACY_VIEW_SUPPORT;
if (this.hasLegacyViewSupport) {
host.import('vendor/legacy-each-view-item-controller-support/index.js');
}
},
treeFor(name) {
if (!this.shouldInclude) { return; }
return this._super.treeFor.call(this, name);
},
treeForVendor(rawVendorTree) {
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;
},
};