forked from emberjs/data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
35 lines (27 loc) · 1.06 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
'use strict';
const addonBuildConfigForDataPackage = require('@ember-data/private-build-infra/src/addon-build-config-for-data-package');
const addonBaseConfig = addonBuildConfigForDataPackage(require('./package.json'));
module.exports = Object.assign({}, addonBaseConfig, {
__isEnabled: null,
treeFor() {
// Nested addons don't call isEnabled automatically,
// So this ensures that we return empty trees whenever
// we are not enabled.
if (this.isEnabled()) {
return this._super.treeFor.call(this, ...arguments);
}
},
isEnabled() {
if (this.__isEnabled !== null) {
return this.__isEnabled;
}
const options = this.getEmberDataConfig();
const env = process.env.EMBER_ENV;
const parentIsEmberDataAddon = this.parent.pkg.name === 'ember-data';
if (options.includeDataAdapterInProduction === undefined) {
options.includeDataAdapterInProduction = parentIsEmberDataAddon;
}
this.__isEnabled = env !== 'production' || options.includeDataAdapterInProduction === true;
return this.__isEnabled;
},
});