@ember-data/legacy-compat 4.12.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/addon-main.js ADDED
@@ -0,0 +1,117 @@
1
+ const requireModule = require('@ember-data/private-build-infra/src/utilities/require-module');
2
+
3
+ const pkg = require('./package.json');
4
+
5
+ // do our best to detect being present
6
+ // Note: when this is not enough, consuming apps may need
7
+ // to "hoist" peer-deps or specify us as a direct dependency
8
+ // in order to deal with peer-dep bugs in package managers
9
+ function detectModule(moduleName) {
10
+ try {
11
+ // package managers have peer-deps bugs where another library
12
+ // bringing a peer-dependency doesn't necessarily result in all
13
+ // versions of the dependent getting the peer-dependency
14
+ //
15
+ // so we resolve from project as well as from our own location
16
+ //
17
+ // eslint-disable-next-line node/no-missing-require
18
+ require.resolve(moduleName, { paths: [process.cwd(), __dirname] });
19
+ return true;
20
+ } catch {
21
+ try {
22
+ // ember-data brings all packages so if present we are present
23
+ //
24
+ // eslint-disable-next-line node/no-missing-require
25
+ require.resolve('ember-data', { paths: [process.cwd(), __dirname] });
26
+ return true;
27
+ } catch {
28
+ return false;
29
+ }
30
+ }
31
+ }
32
+
33
+ module.exports = {
34
+ name: pkg.name,
35
+
36
+ options: {
37
+ '@embroider/macros': {
38
+ setOwnConfig: {},
39
+ },
40
+ },
41
+
42
+ _emberDataConfig: null,
43
+ configureEmberData() {
44
+ if (this._emberDataConfig) {
45
+ return this._emberDataConfig;
46
+ }
47
+ const app = this._findHost();
48
+ const isProd = /production/.test(process.env.EMBER_ENV);
49
+ const hostOptions = app.options?.emberData || {};
50
+ const debugOptions = Object.assign(
51
+ {
52
+ LOG_PAYLOADS: false,
53
+ LOG_OPERATIONS: false,
54
+ LOG_MUTATIONS: false,
55
+ LOG_NOTIFICATIONS: false,
56
+ LOG_REQUEST_STATUS: false,
57
+ LOG_IDENTIFIERS: false,
58
+ LOG_GRAPH: false,
59
+ LOG_INSTANCE_CACHE: false,
60
+ },
61
+ hostOptions.debug || {}
62
+ );
63
+
64
+ const HAS_DEBUG_PACKAGE = detectModule('@ember-data/debug');
65
+ const HAS_META_PACKAGE = detectModule('ember-data');
66
+
67
+ const includeDataAdapterInProduction =
68
+ typeof hostOptions.includeDataAdapterInProduction === 'boolean'
69
+ ? hostOptions.includeDataAdapterInProduction
70
+ : HAS_META_PACKAGE;
71
+
72
+ const includeDataAdapter = HAS_DEBUG_PACKAGE ? (isProd ? includeDataAdapterInProduction : true) : false;
73
+ const DEPRECATIONS = require('@ember-data/private-build-infra/src/deprecations')(hostOptions.compatWith || null);
74
+ const FEATURES = require('@ember-data/private-build-infra/src/features')(isProd);
75
+
76
+ const ALL_PACKAGES = requireModule('@ember-data/private-build-infra/addon/available-packages.ts');
77
+ const MACRO_PACKAGE_FLAGS = Object.assign({}, ALL_PACKAGES.default);
78
+ delete MACRO_PACKAGE_FLAGS['HAS_DEBUG_PACKAGE'];
79
+
80
+ Object.keys(MACRO_PACKAGE_FLAGS).forEach((key) => {
81
+ MACRO_PACKAGE_FLAGS[key] = detectModule(MACRO_PACKAGE_FLAGS[key]);
82
+ });
83
+
84
+ // copy configs forward
85
+ const ownConfig = this.options['@embroider/macros'].setOwnConfig;
86
+ ownConfig.compatWith = hostOptions.compatWith || null;
87
+ ownConfig.debug = debugOptions;
88
+ ownConfig.deprecations = Object.assign(DEPRECATIONS, ownConfig.deprecations || {});
89
+ ownConfig.features = Object.assign({}, FEATURES);
90
+ ownConfig.includeDataAdapter = includeDataAdapter;
91
+ ownConfig.packages = MACRO_PACKAGE_FLAGS;
92
+
93
+ this._emberDataConfig = ownConfig;
94
+ return ownConfig;
95
+ },
96
+
97
+ included() {
98
+ this.configureEmberData();
99
+ return this._super.included.call(this, ...arguments);
100
+ },
101
+
102
+ treeForVendor() {
103
+ return;
104
+ },
105
+ treeForPublic() {
106
+ return;
107
+ },
108
+ treeForStyles() {
109
+ return;
110
+ },
111
+ treeForAddonStyles() {
112
+ return;
113
+ },
114
+ treeForApp() {
115
+ return;
116
+ },
117
+ };
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@ember-data/legacy-compat",
3
+ "description": "Compatibility Shims for Older EmberData",
4
+ "version": "4.12.0-alpha.10",
5
+ "license": "MIT",
6
+ "author": "Chris Thoburn <runspired@users.noreply.github.com>",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+ssh://git@github.com:emberjs/data.git",
10
+ "directory": "packages/legacy-compat"
11
+ },
12
+ "homepage": "https://github.com/emberjs/data",
13
+ "bugs": "https://github.com/emberjs/data/issues",
14
+ "engines": {
15
+ "node": "14.* || 16.* || >= 18"
16
+ },
17
+ "keywords": [
18
+ "ember-addon"
19
+ ],
20
+ "volta": {
21
+ "extends": "../../package.json"
22
+ },
23
+ "dependencies": {
24
+ "ember-cli-babel": "^7.26.11",
25
+ "@ember-data/private-build-infra": "4.12.0-alpha.10",
26
+ "@embroider/macros": "^1.10.0"
27
+ },
28
+ "files": [
29
+ "addon-main.js",
30
+ "addon"
31
+ ],
32
+ "ember-addon": {
33
+ "main": "addon-main.js",
34
+ "type": "addon",
35
+ "version": 1
36
+ },
37
+ "dependenciesMeta": {
38
+ "@ember-data/private-build-infra": {
39
+ "injected": true
40
+ }
41
+ },
42
+ "peerDependencies": {},
43
+ "devDependencies": {
44
+ "@embroider/addon-dev": "^3.0.0",
45
+ "rollup": "^3.19.1",
46
+ "@babel/core": "^7.21.3",
47
+ "@babel/cli": "^7.21.0",
48
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
49
+ "@babel/plugin-proposal-decorators": "^7.21.0",
50
+ "@babel/plugin-proposal-private-methods": "^7.18.6",
51
+ "@babel/plugin-transform-typescript": "^7.21.3",
52
+ "@babel/plugin-transform-runtime": "^7.21.0",
53
+ "@babel/preset-typescript": "^7.21.0",
54
+ "@babel/preset-env": "^7.20.2",
55
+ "@babel/runtime": "^7.21.0",
56
+ "@rollup/plugin-babel": "^6.0.3",
57
+ "@rollup/plugin-node-resolve": "^15.0.1",
58
+ "tslib": "^2.5.0",
59
+ "walk-sync": "^3.0.0",
60
+ "typescript": "^4.9.5"
61
+ },
62
+ "ember": {
63
+ "edition": "octane"
64
+ },
65
+ "scripts": {
66
+ "build": "rollup --config && babel ./addon --out-dir addon --plugins=../private-build-infra/src/transforms/babel-plugin-transform-ext.js",
67
+ "start": "rollup --config --watch"
68
+ }
69
+ }