|
| 1 | +# ADR-0010: Single Package Consolidation |
| 2 | + |
| 3 | +## Status |
| 4 | + |
| 5 | +Accepted |
| 6 | + |
| 7 | +## Context |
| 8 | + |
| 9 | +OCPP DebugKit was originally published as four independent npm packages under |
| 10 | +the `@ocpp-debugkit` scope: |
| 11 | + |
| 12 | +- `@ocpp-debugkit/core` — data model, trace parser, event normalizer, timeline, |
| 13 | + failure detection |
| 14 | +- `@ocpp-debugkit/scenarios` — predefined trace scenarios for testing |
| 15 | +- `@ocpp-debugkit/reporter` — report generators (Markdown) |
| 16 | +- `@ocpp-debugkit/cli` — command-line interface |
| 17 | + |
| 18 | +Two additional packages — `@ocpp-debugkit/replay` (replay engine) and |
| 19 | +`@ocpp-debugkit/react` (reusable React components) — were planned for v0.2.0. |
| 20 | + |
| 21 | +This multi-package layout created several problems: |
| 22 | + |
| 23 | +1. **Version drift.** Each package was independently versioned. Consumers had |
| 24 | + to keep peer versions in sync, and a mismatch between `core` and `scenarios` |
| 25 | + could cause subtle runtime failures that were hard to diagnose. |
| 26 | + |
| 27 | +2. **Cross-package coupling.** `scenarios`, `reporter`, and `cli` all depend on |
| 28 | + `core` types. A change to a `core` type required coordinated releases across |
| 29 | + all dependent packages, defeating the supposed independence. |
| 30 | + |
| 31 | +3. **Installation friction.** Consumers needed to install and list multiple |
| 32 | + packages: |
| 33 | + |
| 34 | + ```bash |
| 35 | + npm install @ocpp-debugkit/core @ocpp-debugkit/scenarios @ocpp-debugkit/reporter |
| 36 | + ``` |
| 37 | + |
| 38 | +4. **Release overhead.** Each release required changeset coordination across |
| 39 | + multiple packages, multiple `npm publish` calls, and CI that had to build |
| 40 | + and test the full dependency graph in order. |
| 41 | + |
| 42 | +5. **Small project, not a library ecosystem.** The packages are tightly coupled |
| 43 | + and maintained by a single team. The independence promised by the |
| 44 | + multi-package layout was theoretical — in practice, every meaningful change |
| 45 | + touched multiple packages simultaneously. |
| 46 | + |
| 47 | +6. **Internal module boundaries are enough.** The actual source code already |
| 48 | + lives in a single `packages/toolkit` directory with subdirectories (`core`, |
| 49 | + `scenarios`, `reporter`, `replay`, `react`, `cli`). The npm package |
| 50 | + boundaries were a publishing artifact, not an architectural one. |
| 51 | + |
| 52 | +## Decision |
| 53 | + |
| 54 | +**Consolidate all four published packages into a single npm package, |
| 55 | +`@ocpp-debugkit/toolkit`, exposed via subpath exports.** |
| 56 | + |
| 57 | +### Package structure |
| 58 | + |
| 59 | +``` |
| 60 | +@ocpp-debugkit/toolkit |
| 61 | + exports: |
| 62 | + . # umbrella entry (re-exports core + scenarios) |
| 63 | + ./core # data model, parser, normalizer, timeline, failure detection |
| 64 | + ./scenarios # predefined trace scenarios |
| 65 | + ./reporter # report generators (Markdown, HTML) |
| 66 | + ./replay # replay engine |
| 67 | + ./react # reusable React components |
| 68 | + ./cli # programmatic CLI entry |
| 69 | + ./fixtures # trace fixtures (moved from core/fixtures) |
| 70 | + bin: |
| 71 | + ocpp-debugkit # CLI binary |
| 72 | +``` |
| 73 | + |
| 74 | +### Subpath exports |
| 75 | + |
| 76 | +Consumers import from `@ocpp-debugkit/toolkit/<module>` instead of |
| 77 | +`@ocpp-debugkit/<module>`: |
| 78 | + |
| 79 | +```ts |
| 80 | +// Before |
| 81 | +import { parseTrace } from '@ocpp-debugkit/core'; |
| 82 | +import { scenarios } from '@ocpp-debugkit/scenarios'; |
| 83 | +import { generateMarkdownReport } from '@ocpp-debugkit/reporter'; |
| 84 | + |
| 85 | +// After |
| 86 | +import { parseTrace } from '@ocpp-debugkit/toolkit/core'; |
| 87 | +import { scenarios } from '@ocpp-debugkit/toolkit/scenarios'; |
| 88 | +import { generateMarkdownReport } from '@ocpp-debugkit/toolkit/reporter'; |
| 89 | +``` |
| 90 | + |
| 91 | +### Binary |
| 92 | + |
| 93 | +The CLI binary name remains `ocpp-debugkit`. Consumers install one package and |
| 94 | +get the CLI: |
| 95 | + |
| 96 | +```bash |
| 97 | +npm install -g @ocpp-debugkit/toolkit |
| 98 | +ocpp-debugkit inspect trace.json |
| 99 | +``` |
| 100 | + |
| 101 | +For `npx`: |
| 102 | + |
| 103 | +```bash |
| 104 | +npx ocpp-debugkit inspect trace.json |
| 105 | +``` |
| 106 | + |
| 107 | +### Deprecation of old packages |
| 108 | + |
| 109 | +The four old packages (`@ocpp-debugkit/core`, `@ocpp-debugkit/scenarios`, |
| 110 | +`@ocpp-debugkit/reporter`, `@ocpp-debugkit/cli`) remain on npm with a |
| 111 | +`deprecated` flag in their latest published versions. They will not receive new |
| 112 | +features or bug fixes. A migration guide is provided at |
| 113 | +[`docs/migration.md`](../migration.md). |
| 114 | + |
| 115 | +### Single version |
| 116 | + |
| 117 | +`@ocpp-debugkit/toolkit` is a single versioned unit. No more peer-dependency |
| 118 | +mismatches — one version, one install, one release. |
| 119 | + |
| 120 | +## Consequences |
| 121 | + |
| 122 | +### Positive |
| 123 | + |
| 124 | +- **Simpler installation.** One package to install: `npm install |
| 125 | + @ocpp-debugkit/toolkit`. |
| 126 | +- **No version drift.** All modules share a single version. Mismatches are |
| 127 | + structurally impossible. |
| 128 | +- **Faster releases.** One package, one publish, one changeset — instead of |
| 129 | + coordinated multi-package releases. |
| 130 | +- **Cleaner dependency graph.** Internal modules depend on each other via |
| 131 | + TypeScript path aliases, not npm dependencies. The build is a single `tsc` |
| 132 | + pass. |
| 133 | +- **Better tree-shaking.** Subpath exports let bundlers include only the |
| 134 | + modules a consumer actually imports. A consumer using only `core` doesn't pull |
| 135 | + in `react` or `cli`. |
| 136 | +- **Module boundaries preserved.** The `core` / `scenarios` / `reporter` / |
| 137 | + `replay` / `react` / `cli` separation still exists as directories and export |
| 138 | + paths — the architectural boundary is intact, only the npm boundary is gone. |
| 139 | + |
| 140 | +### Negative |
| 141 | + |
| 142 | +- **Breaking change for existing consumers.** Anyone importing |
| 143 | + `@ocpp-debugkit/core` must update to `@ocpp-debugkit/toolkit/core`. The |
| 144 | + migration guide and deprecated old packages ease this. |
| 145 | +- **Larger single package.** The npm tarball is larger, though consumers only |
| 146 | + pay for what they import at runtime via subpath exports and tree-shaking. |
| 147 | +- **No independent versioning.** A bug fix to `reporter` bumps the version for |
| 148 | + all modules. Given the tight coupling, this is acceptable — a `reporter` fix |
| 149 | + often depends on a `core` change anyway. |
| 150 | + |
| 151 | +### Neutral |
| 152 | + |
| 153 | +- The old packages stay on npm indefinitely for backward compatibility, but |
| 154 | + they are deprecated and frozen. |
0 commit comments