forked from emberjs/data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
addon-main.js
90 lines (81 loc) · 2.49 KB
/
addon-main.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const pkg = require('./package.json');
module.exports = {
name: pkg.name,
options: {
'@embroider/macros': {
setOwnConfig: {},
},
},
_emberDataConfig: null,
configureEmberData() {
if (this._emberDataConfig) {
return this._emberDataConfig;
}
const app = this._findHost();
const isProd = /production/.test(process.env.EMBER_ENV);
const hostOptions = app.options?.emberData || {};
const debugOptions = Object.assign(
{
LOG_PAYLOADS: false,
LOG_OPERATIONS: false,
LOG_MUTATIONS: false,
LOG_NOTIFICATIONS: false,
LOG_REQUEST_STATUS: false,
LOG_IDENTIFIERS: false,
LOG_GRAPH: false,
LOG_INSTANCE_CACHE: false,
},
hostOptions.debug || {}
);
let HAS_DEBUG_PACKAGE, HAS_META_PACKAGE;
try {
// eslint-disable-next-line node/no-missing-require
require.resolve('@ember-data/debug', { paths: [process.cwd(), __dirname] });
HAS_DEBUG_PACKAGE = true;
} catch {
HAS_DEBUG_PACKAGE = false;
}
try {
// eslint-disable-next-line node/no-missing-require
require.resolve('ember-data', { paths: [process.cwd(), __dirname] });
HAS_META_PACKAGE = true;
} catch {
HAS_META_PACKAGE = false;
}
const includeDataAdapterInProduction =
typeof hostOptions.includeDataAdapterInProduction === 'boolean'
? hostOptions.includeDataAdapterInProduction
: HAS_META_PACKAGE;
const includeDataAdapter = HAS_DEBUG_PACKAGE ? (isProd ? includeDataAdapterInProduction : true) : false;
const DEPRECATIONS = require('@ember-data/private-build-infra/src/deprecations')(hostOptions.compatWith || null);
const FEATURES = require('@ember-data/private-build-infra/src/features')(isProd);
// copy configs forward
const ownConfig = this.options['@embroider/macros'].setOwnConfig;
ownConfig.compatWith = hostOptions.compatWith || null;
ownConfig.debug = debugOptions;
ownConfig.deprecations = Object.assign(DEPRECATIONS, ownConfig.deprecations || {});
ownConfig.features = Object.assign({}, FEATURES);
ownConfig.includeDataAdapter = includeDataAdapter;
this._emberDataConfig = ownConfig;
return ownConfig;
},
included() {
this.configureEmberData();
return this._super.included.call(this, ...arguments);
},
treeForVendor() {
return;
},
treeForPublic() {
return;
},
treeForStyles() {
return;
},
treeForAddonStyles() {
return;
},
treeForApp() {
return;
},
};