-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
54 lines (42 loc) · 1.79 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
'use strict';
const SilentError = require('silent-error');
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);
const parentChecker = new VersionChecker(this.parent);
const babelVersion = parentChecker.for('ember-cli-babel');
if (babelVersion.lt('7.20.0')) {
throw new SilentError('ember-cache-primitive-polyfill requires [email protected] or higher in order to function properly, please update your ember-cli-babel version');
}
let glimmerTrackingVersion = parentChecker.for('@glimmer/tracking');
if (glimmerTrackingVersion.lt('1.0.2')) {
this.ui.writeWarnLine(`Using ${this.name} with \`@glimmer/tracking\` versions prior to 1.0.2 may not work correctly, please update to at least \`@glimmer/[email protected]\``);
}
const projectChecker = new VersionChecker(this.project);
const emberVersion = projectChecker.for('ember-source');
if (emberVersion.lt(NATIVE_SUPPORT_VERSION)) {
this.import('vendor/ember-cache-primitive-polyfill.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(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;
},
};