-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
51 lines (39 loc) · 1.09 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
'use strict';
const VersionChecker = require('ember-cli-version-checker');
const { cacheKeyForStableTree } = require('calculate-cache-key-for-tree');
module.exports = {
name: require('./package').name,
cacheKeyForTree: cacheKeyForStableTree,
init() {
this._super.init && this._super.init.apply(this, arguments);
let checker = new VersionChecker(this.project);
let emberVersion = checker.forEmber();
this.shouldPolyfill = emberVersion.lt('3.11.0-alpha.1');
},
setupPreprocessorRegistry(type, registry) {
if (this.shouldPolyfill) {
let pluginObj = this._buildPlugin();
pluginObj.parallelBabel = {
requireFile: __filename,
buildUsing: '_buildPlugin',
params: {},
};
registry.add('htmlbars-ast-plugin', pluginObj);
}
},
_buildPlugin() {
return {
name: 'fn-helper-polyfill',
plugin: require('./lib/ast-transform'),
baseDir() {
return __dirname;
},
};
},
treeFor() {
if (!this.shouldPolyfill) {
return;
}
return this._super.treeFor.apply(this, arguments);
},
};