Skip to content

Commit efe5df6

Browse files
authored
chore: update package flags (emberjs#8357)
* chore: update package flags * chore: update pnpm version * fix lint * update deps * add missing peer-dep * update embroider-macros patch
1 parent d203ef0 commit efe5df6

File tree

26 files changed

+276
-127
lines changed

26 files changed

+276
-127
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@
164164
},
165165
"pnpm": {
166166
"patchedDependencies": {
167-
"@embroider/[email protected]": "patches/@[email protected]"
167+
"@embroider/[email protected]": "patches/@[email protected]",
168+
"@embroider/[email protected]": "patches/@[email protected]"
168169
}
169170
}
170171
}

packages/model/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
],
3131
"peerDependencies": {
3232
"@ember-data/json-api": "workspace:4.10.0-alpha.4",
33+
"@ember-data/graph": "workspace:4.10.0-alpha.4",
3334
"@ember-data/store": "workspace:4.10.0-alpha.4",
3435
"@ember-data/tracking": "workspace:4.10.0-alpha.4",
3536
"@ember/string": "^3.0.0",
@@ -38,6 +39,9 @@
3839
"peerDependenciesMeta": {
3940
"@ember-data/json-api": {
4041
"optional": true
42+
},
43+
"@ember-data/graph": {
44+
"optional": true
4145
}
4246
},
4347
"dependenciesMeta": {

packages/model/src/-private/legacy-relationships-support.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { LocalRelationshipOperation } from '@ember-data/graph/-private/grap
99
import type { ImplicitRelationship } from '@ember-data/graph/-private/graph/index';
1010
import type BelongsToRelationship from '@ember-data/graph/-private/relationships/state/belongs-to';
1111
import type ManyRelationship from '@ember-data/graph/-private/relationships/state/has-many';
12-
import { HAS_RECORD_DATA_PACKAGE } from '@ember-data/private-build-infra';
12+
import { HAS_JSON_API_PACKAGE } from '@ember-data/private-build-infra';
1313
import { DEPRECATE_PROMISE_PROXIES } from '@ember-data/private-build-infra/deprecations';
1414
import type Store from '@ember-data/store';
1515
import { fastPush, isStableIdentifier, recordIdentifierFor, SOURCE, storeFor } from '@ember-data/store/-private';
@@ -207,7 +207,7 @@ export class LegacySupport {
207207
}
208208

209209
getManyArray(key: string, definition?: UpgradedMeta): RelatedCollection {
210-
if (HAS_RECORD_DATA_PACKAGE) {
210+
if (HAS_JSON_API_PACKAGE) {
211211
let manyArray: RelatedCollection | undefined = this._manyArrayCache[key];
212212
if (!definition) {
213213
const graphFor = (importSync('@ember-data/graph/-private') as typeof import('@ember-data/graph/-private'))
@@ -248,7 +248,7 @@ export class LegacySupport {
248248
manyArray: RelatedCollection,
249249
options?: FindOptions
250250
): Promise<RelatedCollection> {
251-
if (HAS_RECORD_DATA_PACKAGE) {
251+
if (HAS_JSON_API_PACKAGE) {
252252
let loadingPromise = this._relationshipPromisesCache[key] as Promise<RelatedCollection> | undefined;
253253
if (loadingPromise) {
254254
return loadingPromise;
@@ -273,7 +273,7 @@ export class LegacySupport {
273273
}
274274

275275
reloadHasMany(key: string, options?: FindOptions) {
276-
if (HAS_RECORD_DATA_PACKAGE) {
276+
if (HAS_JSON_API_PACKAGE) {
277277
let loadingPromise = this._relationshipPromisesCache[key];
278278
if (loadingPromise) {
279279
return loadingPromise;
@@ -298,7 +298,7 @@ export class LegacySupport {
298298
}
299299

300300
getHasMany(key: string, options?: FindOptions): PromiseManyArray | RelatedCollection {
301-
if (HAS_RECORD_DATA_PACKAGE) {
301+
if (HAS_JSON_API_PACKAGE) {
302302
const graphFor = (importSync('@ember-data/graph/-private') as typeof import('@ember-data/graph/-private'))
303303
.graphFor;
304304
const relationship = graphFor(this.store).get(this.identifier, key) as ManyRelationship;
@@ -370,7 +370,7 @@ export class LegacySupport {
370370
let reference = this.references[name];
371371

372372
if (!reference) {
373-
if (!HAS_RECORD_DATA_PACKAGE) {
373+
if (!HAS_JSON_API_PACKAGE) {
374374
// TODO @runspired while this feels odd, it is not a regression in capability because we do
375375
// not today support references pulling from RecordDatas other than our own
376376
// because of the intimate API access involved. This is something we will need to redesign.
@@ -418,7 +418,7 @@ export class LegacySupport {
418418
relationship: ManyRelationship,
419419
options: FindOptions = {}
420420
): Promise<void | unknown[]> | void {
421-
if (HAS_RECORD_DATA_PACKAGE) {
421+
if (HAS_JSON_API_PACKAGE) {
422422
if (!resource) {
423423
return;
424424
}

packages/private-build-infra/addon/available-packages.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ export default {
22
HAS_EMBER_DATA_PACKAGE: 'ember-data',
33
HAS_STORE_PACKAGE: '@ember-data/store',
44
HAS_MODEL_PACKAGE: '@ember-data/model',
5-
HAS_RECORD_DATA_PACKAGE: '@ember-data/json-api',
5+
HAS_JSON_API_PACKAGE: '@ember-data/json-api',
6+
HAS_GRAPH_PACKAGE: '@ember-data/graph',
7+
HAS_REQUEST_PACKAGE: '@ember-data/request',
8+
HAS_TRACKING_PACKAGE: '@ember-data/tracking',
69
HAS_ADAPTER_PACKAGE: '@ember-data/adapter',
710
HAS_SERIALIZER_PACKAGE: '@ember-data/serializer',
811
HAS_DEBUG_PACKAGE: '@ember-data/debug',

packages/private-build-infra/addon/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ export const HAS_MODEL_PACKAGE = flagState('HAS_MODEL_PACKAGE');
1313
export const HAS_ADAPTER_PACKAGE = flagState('HAS_ADAPTER_PACKAGE');
1414
export const HAS_SERIALIZER_PACKAGE = flagState('HAS_SERIALIZER_PACKAGE');
1515
export const HAS_DEBUG_PACKAGE = flagState('HAS_DEBUG_PACKAGE');
16-
export const HAS_RECORD_DATA_PACKAGE = flagState('HAS_RECORD_DATA_PACKAGE');
16+
export const HAS_JSON_API_PACKAGE = flagState('HAS_JSON_API_PACKAGE');
17+
export const HAS_GRAPH_PACKAGE = flagState('HAS_GRAPH_PACKAGE');
18+
export const HAS_REQUEST_PACKAGE = flagState('HAS_REQUEST_PACKAGE');
19+
export const HAS_TRACKING_PACKAGE = flagState('HAS_TRACKING_PACKAGE');

packages/store/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"peerDependencies": {
3232
"@ember-data/model": "workspace:4.10.0-alpha.4",
3333
"@ember-data/json-api": "workspace:4.10.0-alpha.4",
34+
"@ember-data/graph": "workspace:4.10.0-alpha.4",
3435
"@ember-data/tracking": "workspace:4.10.0-alpha.4",
3536
"@ember/string": "^3.0.0",
3637
"@glimmer/tracking": "^1.1.2"
@@ -39,6 +40,9 @@
3940
"@ember-data/json-api": {
4041
"optional": true
4142
},
43+
"@ember-data/graph": {
44+
"optional": true
45+
},
4246
"@ember-data/model": {
4347
"optional": true
4448
}

packages/store/src/-private/caches/instance-cache.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { resolve } from 'rsvp';
66

77
import type { Graph } from '@ember-data/graph/-private/graph/graph';
88
import type { peekGraph } from '@ember-data/graph/-private/graph/index';
9-
import { HAS_RECORD_DATA_PACKAGE } from '@ember-data/private-build-infra';
9+
import { HAS_GRAPH_PACKAGE, HAS_JSON_API_PACKAGE } from '@ember-data/private-build-infra';
1010
import { LOG_INSTANCE_CACHE } from '@ember-data/private-build-infra/debugging';
1111
import { DEPRECATE_V1_RECORD_DATA, DEPRECATE_V1CACHE_STORE_APIS } from '@ember-data/private-build-infra/deprecations';
1212
import type {
@@ -40,7 +40,7 @@ import normalizeModelName from '../utils/normalize-model-name';
4040
import { removeRecordDataFor, setRecordDataFor } from './record-data-for';
4141

4242
let _peekGraph: peekGraph;
43-
if (HAS_RECORD_DATA_PACKAGE) {
43+
if (HAS_GRAPH_PACKAGE) {
4444
let __peekGraph: peekGraph;
4545
_peekGraph = (wrapper: Store | StoreWrapper): Graph | undefined => {
4646
let a = (importSync('@ember-data/graph/-private') as { peekGraph: peekGraph }).peekGraph;
@@ -192,7 +192,7 @@ export class InstanceCache {
192192
record: staleIdentifier,
193193
value: keptIdentifier,
194194
});
195-
} else if (HAS_RECORD_DATA_PACKAGE) {
195+
} else if (HAS_JSON_API_PACKAGE) {
196196
// TODO notify cache always, this requires it always being a singleton
197197
// and not ever specific to one record-data
198198
this.store.__private_singleton_recordData?.sync({
@@ -208,7 +208,7 @@ export class InstanceCache {
208208

209209
/*
210210
TODO @runspired consider adding this to make polymorphism even nicer
211-
if (HAS_RECORD_DATA_PACKAGE) {
211+
if (HAS_GRAPH_PACKAGE) {
212212
if (identifier.type !== matchedIdentifier.type) {
213213
const graphFor = importSync('@ember-data/graph/-private').graphFor;
214214
graphFor(this).registerPolymorphicType(identifier.type, matchedIdentifier.type);
@@ -375,7 +375,7 @@ export class InstanceCache {
375375
!record || record.isDestroyed || record.isDestroying
376376
);
377377

378-
if (HAS_RECORD_DATA_PACKAGE) {
378+
if (HAS_GRAPH_PACKAGE) {
379379
let graph = _peekGraph(this.store);
380380
if (graph) {
381381
graph.remove(identifier);

packages/store/src/-private/network/fetch-manager.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { DEBUG } from '@glimmer/env';
88
import { importSync, isDevelopingApp } from '@embroider/macros';
99
import { default as RSVP, resolve } from 'rsvp';
1010

11-
import { HAS_RECORD_DATA_PACKAGE } from '@ember-data/private-build-infra';
11+
import { HAS_GRAPH_PACKAGE } from '@ember-data/private-build-infra';
1212
import { DEPRECATE_RSVP_PROMISE } from '@ember-data/private-build-infra/deprecations';
1313
import type { CollectionResourceDocument, SingleResourceDocument } from '@ember-data/types/q/ember-data-json-api';
1414
import type { FindRecordQuery, Request, SaveRecordMutation } from '@ember-data/types/q/fetch-manager';
@@ -217,7 +217,7 @@ export default class FetchManager {
217217
const recordData = store._instanceCache.peek({ identifier, bucket: 'recordData' });
218218
if (!recordData || recordData.isEmpty(identifier) || isLoading) {
219219
let isReleasable = true;
220-
if (!recordData && HAS_RECORD_DATA_PACKAGE) {
220+
if (!recordData && HAS_GRAPH_PACKAGE) {
221221
const graphFor = (importSync('@ember-data/graph/-private') as typeof import('@ember-data/graph/-private'))
222222
.graphFor;
223223
const graph = graphFor(store);

packages/store/src/-private/network/snapshot.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { importSync } from '@embroider/macros';
77

88
import type BelongsToRelationship from '@ember-data/graph/-private/relationships/state/belongs-to';
99
import type ManyRelationship from '@ember-data/graph/-private/relationships/state/has-many';
10-
import { HAS_RECORD_DATA_PACKAGE } from '@ember-data/private-build-infra';
10+
import { HAS_JSON_API_PACKAGE } from '@ember-data/private-build-infra';
1111
import { DEPRECATE_SNAPSHOT_MODEL_CLASS_ACCESS } from '@ember-data/private-build-infra/deprecations';
1212
import type { StableRecordIdentifier } from '@ember-data/types/q/identifier';
1313
import type { OptionsHash } from '@ember-data/types/q/minimum-serializer-interface';
@@ -315,7 +315,7 @@ export default class Snapshot implements Snapshot {
315315
// function without access to intimate API contracts between RecordData and Model.
316316
// This is a requirement we should fix as soon as the relationship layer does not require
317317
// this intimate API usage.
318-
if (!HAS_RECORD_DATA_PACKAGE) {
318+
if (!HAS_JSON_API_PACKAGE) {
319319
assert(`snapshot.belongsTo only supported when using the package @ember-data/json-api`);
320320
}
321321

@@ -416,7 +416,7 @@ export default class Snapshot implements Snapshot {
416416
// function without access to intimate API contracts between RecordData and Model.
417417
// This is a requirement we should fix as soon as the relationship layer does not require
418418
// this intimate API usage.
419-
if (!HAS_RECORD_DATA_PACKAGE) {
419+
if (!HAS_JSON_API_PACKAGE) {
420420
assert(`snapshot.hasMany only supported when using the package @ember-data/json-api`);
421421
}
422422

packages/store/src/-private/store-service.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { reject, resolve } from 'rsvp';
1212

1313
import type { RecordData as RecordDataClass } from '@ember-data/json-api/-private';
1414
import type DSModelClass from '@ember-data/model';
15-
import { HAS_MODEL_PACKAGE, HAS_RECORD_DATA_PACKAGE } from '@ember-data/private-build-infra';
15+
import { HAS_GRAPH_PACKAGE, HAS_JSON_API_PACKAGE, HAS_MODEL_PACKAGE } from '@ember-data/private-build-infra';
1616
import { LOG_PAYLOADS } from '@ember-data/private-build-infra/debugging';
1717
import {
1818
DEPRECATE_HAS_RECORD,
@@ -1928,7 +1928,7 @@ class Store {
19281928
// destroy the graph before unloadAll
19291929
// since then we avoid churning relationships
19301930
// during unload
1931-
if (HAS_RECORD_DATA_PACKAGE) {
1931+
if (HAS_GRAPH_PACKAGE) {
19321932
const peekGraph = (importSync('@ember-data/graph/-private') as typeof import('@ember-data/graph/-private'))
19331933
.peekGraph;
19341934
let graph = peekGraph(this);
@@ -2403,7 +2403,7 @@ class Store {
24032403
identifier: StableRecordIdentifier,
24042404
storeWrapper: RecordDataStoreWrapper
24052405
): RecordData | RecordDataV1 {
2406-
if (HAS_RECORD_DATA_PACKAGE) {
2406+
if (HAS_JSON_API_PACKAGE) {
24072407
// we can't greedily use require as this causes
24082408
// a cycle we can't easily fix (or clearly pin point) at present.
24092409
//
@@ -2633,7 +2633,7 @@ class Store {
26332633
}
26342634
}
26352635

2636-
if (HAS_RECORD_DATA_PACKAGE) {
2636+
if (HAS_GRAPH_PACKAGE) {
26372637
const peekGraph = (importSync('@ember-data/graph/-private') as typeof import('@ember-data/graph/-private'))
26382638
.peekGraph;
26392639
let graph = peekGraph(this);

patches/@[email protected]

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
diff --git a/src/babel/module-exists.js b/src/babel/module-exists.js
2+
index 4737d6ebd58e55fd22257a66bef08805be792eba..1774eb28c9407169b0859debf6e02457bde8f83a 100644
3+
--- a/src/babel/module-exists.js
4+
+++ b/src/babel/module-exists.js
5+
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6+
Object.defineProperty(exports, "__esModule", { value: true });
7+
const error_1 = __importDefault(require("./error"));
8+
const evaluate_json_1 = require("./evaluate-json");
9+
-const resolve_1 = __importDefault(require("resolve"));
10+
const path_1 = require("path");
11+
function moduleExists(path, state) {
12+
if (path.node.arguments.length !== 1) {
13+
@@ -16,7 +15,7 @@ function moduleExists(path, state) {
14+
throw (0, error_1.default)((0, evaluate_json_1.assertArray)(path.get('arguments'))[0], `the first argument to moduleExists must be a string literal`);
15+
}
16+
try {
17+
- resolve_1.default.sync(moduleSpecifier.value, { basedir: (0, path_1.dirname)(state.sourceFile) });
18+
+ require.resolve(moduleSpecifier.value, { paths: [process.cwd(), state.sourceFile, (0, path_1.dirname)(state.sourceFile)] });
19+
return true;
20+
}
21+
catch (err) {

0 commit comments

Comments
 (0)