-
Notifications
You must be signed in to change notification settings - Fork 72
/
index.js
60 lines (51 loc) · 1.27 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
'use strict';
module.exports = {
name: require('./package').name,
options: {
autoImport: {
webpack: {
module: {
rules: [
/* fixes issue with graphql-js's mjs entry */
/* see: https://github.com/graphql/graphql-js/issues/1272#issuecomment-393903706 */
{
test: /\.mjs$/,
include: /node_modules\/graphql/,
type: 'javascript/auto',
},
],
},
},
},
},
included(app) {
this._super.included.apply(this, arguments);
this.app = app;
},
getOptions() {
const hostOptions =
(this.parent && this.parent.options) ||
(this.app && this.app.options) ||
{};
return (
hostOptions.emberApolloClient || {
keepGraphqlFileExtension: true,
}
);
},
setupPreprocessorRegistry(type, registry) {
const options = this.getOptions();
if (type === 'parent') {
registry.add('js', {
name: require('./package').name,
ext: 'graphql',
toTree(tree) {
const GraphQLFilter = require('broccoli-graphql-filter');
return new GraphQLFilter(tree, {
keepExtension: options.keepGraphqlFileExtension,
});
},
});
}
},
};