You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/PACKAGE_DEPENDENCIES.md
+79-23Lines changed: 79 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,21 @@ This document describes the allowed dependency structure within the CDC Open Viz
6
6
7
7
The CDC Open Viz monorepo follows a specific dependency architecture to maintain clean separation of concerns and prevent circular dependencies. The standalone build tests enforce these rules to ensure packages can be built independently.
8
8
9
+
## TL;DR
10
+
11
+
**Quick Reference:**
12
+
13
+
-**Core** (`@cdc/core`) → Depends on nothing (foundation)
14
+
-**Visualizations** (`chart`, `map`, `data-table`, etc.) → Depend only on Core
15
+
-**Orchestrators** (`dashboard`, `editor`) → Can depend on everything
16
+
9
17
## Dependency Rules
10
18
11
19
### ✅ Allowed Dependencies
12
20
13
21
1.**Core Package (`@cdc/core`)**
14
22
15
-
-**Can depend on ANY other package**
23
+
-**Cannot depend on any other internal packages** (foundation layer)
16
24
-**Any package can depend on `@cdc/core`**
17
25
- Core contains shared utilities, types, components, and helpers used across the monorepo
18
26
- Examples: `import { cloneConfig } from '@cdc/core/helpers/cloneConfig'`
@@ -58,16 +66,33 @@ Individual visualization packages should be self-contained:
58
66
## CurrentPackageStructure
59
67
60
68
```
61
-
@cdc/core ← Base package (can be imported by all)
62
-
├── @cdc/chart ← Standalone visualization
63
-
├── @cdc/map ← Standalone visualization
64
-
├── @cdc/data-table ← Standalone visualization
65
-
├── @cdc/data-bite ← Standalone visualization
66
-
├── @cdc/waffle-chart ← Standalone visualization
67
-
├── @cdc/filtered-text ← Standalone visualization
68
-
├── @cdc/markup-include← Standalone visualization
69
-
├── @cdc/dashboard ← Orchestrator (can import from all)
70
-
└── @cdc/editor ← Configuration tool (can import from all)
@@ -81,9 +106,9 @@ Individual visualization packages should be self-contained:
81
106
82
107
### Special Cases
83
108
84
-
- **Dashboard**: Acts as a composition root, combining multiple visualizations
85
-
- **Editor**: Needs access to all components for configuration UI and live previews
86
-
- **Core**: Provides shared infrastructure (utilities, types, base components)
109
+
- **Core**: Foundation layer providing shared infrastructure (utilities, types, base components). Cannot depend on other packages to prevent circular dependencies.
110
+
- **Dashboard**: Acts as a composition root, combining multiple visualizations. Can import from all packages.
111
+
- **Editor**: Needs access to all components for configuration UI and live previews. Can import from all packages.
87
112
88
113
## Exemptions
89
114
@@ -102,6 +127,32 @@ The dependency rules are enforced by:
102
127
103
128
1. **Standalone Build Tests**: Each package has a test that verifies it can be built in isolation
104
129
2. **Code Reviews**: Manual verification during pull request reviews
130
+
3. **Monitoring Commands**: Grep-based commands to detect cross-package imports (see Monitoring section)
131
+
132
+
## Known Limitations
133
+
134
+
### TypeScript Type-Only Imports
135
+
136
+
TypeScript type-only imports (using the `type` keyword) can slip through standalone build tests:
137
+
138
+
```typescript
139
+
// This violates architecture but may not fail builds
140
+
import { type DashboardConfig } from '@cdc/dashboard/src/types/DashboardConfig'
141
+
```
142
+
143
+
**Why builds still succeed:**
144
+
145
+
- Type-only imports are stripped during compilation and create no runtime dependency
146
+
- TypeScript may not fail when the imported package isn't installed
147
+
- The package can build successfully in isolation
148
+
149
+
**Important:** These are still **architectural violations** even if they don't break builds. Type-only imports:
150
+
151
+
- Create conceptual coupling between packages
152
+
- Can evolve into runtime imports over time
153
+
- Violate the intended dependency hierarchy
154
+
155
+
**Solution:** Move shared types to `@cdc/core` so both packages can reference them without violating the architecture.
0 commit comments