-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
64 lines (54 loc) · 1.6 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
60
61
62
63
64
'use strict';
const VersionChecker = require('ember-cli-version-checker');
const InElementTransform = require('./lib/in-element-transform');
const debug = require('debug')('ember-in-element-polyfill');
const MINIMUM_PUBLIC_IN_ELEMENT_EMBER_VERSION = '3.20.0-beta.0';
module.exports = {
name: require('./package').name,
setupPreprocessorRegistry(type, registry) {
if (this.hasPublicInElement()) {
return;
}
let inElementPolyfillPlugin = this._buildPlugin();
inElementPolyfillPlugin.parallelBabel = {
requireFile: __filename,
buildUsing: '_buildPlugin',
params: {}
};
registry.add('htmlbars-ast-plugin', inElementPolyfillPlugin);
debug(`adding AST transform ember-in-element-polyfill`);
},
_buildPlugin() {
return {
name: 'ember-in-element-polyfill',
plugin: InElementTransform,
baseDir() {
return __dirname;
},
cacheKey() {
return 'ember-in-element-polyfill';
}
};
},
treeForAddon() {
if (!this.hasPublicInElement()) {
return this._super.treeForAddon.apply(this, arguments);
}
},
treeForApp() {
if (!this.hasPublicInElement()) {
return this._super.treeForApp.apply(this, arguments);
}
},
hasPublicInElement() {
this.ensureEmberVersion();
return this.emberVersion.gte(MINIMUM_PUBLIC_IN_ELEMENT_EMBER_VERSION);
},
ensureEmberVersion() {
if (!this.emberVersion) {
let checker = new VersionChecker(this.project);
this.emberVersion = checker.for(`ember-source`);
debug(`Detected Ember version ${this.emberVersion.version}`);
}
}
};