-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
68 lines (56 loc) · 1.55 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
'use strict';
const Funnel = require('broccoli-funnel');
module.exports = {
name: require('./package').name,
_getOptions() {
return (this.parent && this.parent.options) || (this.app && this.app.options) || {};
},
setupPreprocessorRegistry(type, registry) {
let app = this._findHost();
let addonOptions = this._getOptions()[this.name];
if (!addonOptions?.allow?.includes(app.env)) {
const plugin = this._buildPlugin();
plugin.parallelBabel = {
requireFile: __filename,
buildUsing: '_buildPlugin',
params: {},
};
registry.add('htmlbars-ast-plugin', plugin);
}
},
_buildPlugin() {
const emberTemplateDebugTransform = require('./lib/ast-transform');
return {
name: 'ember-debug-component',
plugin: emberTemplateDebugTransform,
baseDir: emberTemplateDebugTransform.baseDir,
cacheKey: emberTemplateDebugTransform.cacheKey,
};
},
_filterAssertHelper(tree) {
let app = this._findHost();
let addonOptions = this._getOptions()[this.name];
if (addonOptions?.allow?.includes(app.env)) {
return tree;
}
return new Funnel(tree, {
exclude: [
'components/debug.js',
'components/debug.hbs',
'services/debug-dev-tools.js',
],
});
},
treeForApp(tree) {
return this._super.treeForApp.call(
this,
this._filterAssertHelper(tree, 'app tree')
);
},
treeForAddon(tree) {
return this._super.treeForAddon.call(
this,
this._filterAssertHelper(tree, 'addon tree')
);
},
};