This repository has been archived by the owner on Jun 10, 2022. It is now read-only.
forked from Addepar/ember-table
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
70 lines (58 loc) · 1.81 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
65
66
67
68
69
70
'use strict';
const VersionChecker = require('ember-cli-version-checker');
const replace = require('broccoli-string-replace');
module.exports = {
name: 'ember-table',
options: {
babel: {
plugins: [
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/plugin-proposal-numeric-separator',
'@babel/plugin-proposal-optional-catch-binding',
],
},
},
included() {
this._super.included.apply(this, arguments);
this.checker = new VersionChecker(this.project).forEmber();
let importOptions;
// If `ember-cli-fastboot` is being used in the root project, use the
// fastboot transform when importing
if (this.project.findAddonByName('ember-cli-fastboot')) {
importOptions = {
using: [
{
transformation: 'fastbootShim',
},
],
};
}
this.import('node_modules/css-element-queries/src/ResizeSensor.js', importOptions);
this.import('node_modules/hammerjs/hammer.js', importOptions);
},
isDevelopingAddon() {
// this prevents templates from being cached before we can strip them out
// they get cached by jshintAddonTree before we can intervene
if (this.checker.gte('2.3.0')) {
return this._super.isDevelopingAddon.apply(this, arguments);
}
return false;
},
treeForAddon(tree) {
// strip out contextual components in versions that don't support them
if (!this.checker.gte('2.3.0')) {
tree = replace(tree, {
files: ['**/*.hbs'],
patterns: [
{
match: /\w*=\(component.*?\)/gm,
replacement: '',
},
],
});
}
return this._super.treeForAddon.apply(this, [tree]);
},
};