Skip to content

Commit ac34e82

Browse files
seefeldbclaude
andauthored
Break circular dependency between memory and runner packages (#2000)
Break circular dependency between memory and runner Move SchemaContext and SchemaPathSelector type definitions from runner to memory/interface.ts, eliminating the circular import between packages. Changes: - memory/interface.ts: Define SchemaContext and SchemaPathSelector locally, import JSONSchema from @commontools/api instead of @commontools/runner - runner/src/builder/types.ts: Import SchemaContext from memory - runner/src/traverse.ts: Import SchemaContext and SchemaPathSelector from memory Impact: - Files without complex runner dependencies now compile 30-40x faster (0.013s vs 0.5s) - Simple utility files reduced from 267 dependencies (34MB) to 2-5 dependencies (~116KB) - Total runner package typecheck time reduced by 3 seconds 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 62797bf commit ac34e82

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

packages/memory/interface.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
import type { Reference } from "merkle-reference";
2-
import { JSONValue, SchemaContext } from "@commontools/runner";
3-
import { SchemaPathSelector } from "@commontools/runner/traverse";
2+
import type { JSONSchema, JSONValue } from "@commontools/api";
43

5-
export type { JSONValue, Reference, SchemaContext, SchemaPathSelector };
4+
export type SchemaContext = {
5+
schema: JSONSchema;
6+
rootSchema: JSONSchema;
7+
};
8+
9+
export type SchemaPathSelector = {
10+
path: readonly string[];
11+
schemaContext?: Readonly<SchemaContext>;
12+
};
13+
14+
export type { JSONValue, Reference };
615

716
export interface Clock {
817
now(): UTCUnixTimestampInSeconds;

packages/runner/src/builder/types.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { isObject, type Mutable } from "@commontools/utils/types";
22
import { toOpaqueRef } from "../back-to-cell.ts";
3+
import type { SchemaContext } from "@commontools/memory/interface";
34

45
import type {
56
ByRefFunction,
@@ -158,11 +159,7 @@ export type NodeRef = {
158159
frame: Frame | undefined;
159160
};
160161

161-
// This is a schema, together with its rootSchema for resolving $ref entries
162-
export type SchemaContext = {
163-
schema: JSONSchema;
164-
rootSchema: JSONSchema;
165-
};
162+
export type { SchemaContext };
166163

167164
export type StreamValue = {
168165
$stream: true;

packages/runner/src/traverse.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ import {
1111
} from "../../utils/src/types.ts";
1212
import { getLogger } from "../../utils/src/logger.ts";
1313
import { ContextualFlowControl } from "./cfc.ts";
14+
import type { JSONObject, JSONSchema, JSONValue } from "./builder/types.ts";
1415
import type {
15-
JSONObject,
16-
JSONSchema,
17-
JSONValue,
1816
SchemaContext,
19-
} from "./builder/types.ts";
17+
SchemaPathSelector,
18+
} from "@commontools/memory/interface";
2019
import { deepEqual } from "./path-utils.ts";
2120
import { isAnyCellLink, parseLink } from "./link-utils.ts";
2221
import { fromURI } from "./uri-utils.ts";
@@ -25,12 +24,7 @@ import type { IAttestation, IMemoryAddress } from "./storage/interface.ts";
2524
const logger = getLogger("traverse", { enabled: true, level: "warn" });
2625

2726
export type { IAttestation, IMemoryAddress } from "./storage/interface.ts";
28-
29-
// Both path and schemaContext are relative to the fact.is.value
30-
export type SchemaPathSelector = {
31-
path: readonly string[];
32-
schemaContext?: Readonly<SchemaContext>;
33-
};
27+
export type { SchemaPathSelector };
3428

3529
/**
3630
* A data structure that maps keys to sets of values, allowing multiple values

0 commit comments

Comments
 (0)