forked from emberjs/data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
addon-main.js
94 lines (81 loc) · 3.02 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
91
92
93
94
const requireModule = require('@ember-data/private-build-infra/src/utilities/require-module');
const getEnv = require('@ember-data/private-build-infra/src/utilities/get-env');
const detectModule = require('@ember-data/private-build-infra/src/utilities/detect-module');
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_REQUESTS: false,
LOG_REQUEST_STATUS: false,
LOG_IDENTIFIERS: false,
LOG_GRAPH: false,
LOG_INSTANCE_CACHE: false,
},
hostOptions.debug || {}
);
const HAS_DEBUG_PACKAGE = detectModule(require, '@ember-data/debug', __dirname, pkg);
const HAS_META_PACKAGE = detectModule(require, 'ember-data', __dirname, pkg);
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);
const ALL_PACKAGES = requireModule('@ember-data/private-build-infra/virtual-packages/packages.js');
const MACRO_PACKAGE_FLAGS = Object.assign({}, ALL_PACKAGES.default);
delete MACRO_PACKAGE_FLAGS['HAS_DEBUG_PACKAGE'];
Object.keys(MACRO_PACKAGE_FLAGS).forEach((key) => {
MACRO_PACKAGE_FLAGS[key] = detectModule(require, MACRO_PACKAGE_FLAGS[key], __dirname, pkg);
});
// copy configs forward
const ownConfig = this.options['@embroider/macros'].setOwnConfig;
ownConfig.polyfillUUID = hostOptions.polyfillUUID ?? false;
ownConfig.compatWith = hostOptions.compatWith || null;
ownConfig.debug = debugOptions;
ownConfig.deprecations = Object.assign(DEPRECATIONS, ownConfig.deprecations || {}, hostOptions.deprecations || {});
ownConfig.features = Object.assign({}, FEATURES);
ownConfig.includeDataAdapter = includeDataAdapter;
ownConfig.packages = MACRO_PACKAGE_FLAGS;
ownConfig.env = getEnv(ownConfig);
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;
},
};