|
1 | 1 | // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. |
2 | 2 |
|
3 | 3 | /** |
4 | | - * `@objectstack/lint/runtime` — the KERNEL-SAFE entry (#4463). |
5 | | - * |
6 | | - * The metadata write path (`@objectstack/metadata-protocol`) sits on the kernel |
7 | | - * boot path and must reach the shared rule core without dragging the lint |
8 | | - * package's gate-only dependencies (`typescript` ~9 MB, `sucrase`) into it. |
9 | | - * That constraint is real and it is guarded from both ends: |
10 | | - * |
11 | | - * - `lazy-deps.test.ts` pins that no `src/` file eagerly imports either dep, so |
12 | | - * importing this entry loads neither; |
13 | | - * - `runtime-lazy-deps.test.ts` pins the stronger claim this entry needs — that |
14 | | - * RUNNING the gate on a real, gated body loads neither either, because the |
15 | | - * rules #4463 wired to `runtime-publish` (flow / approval / expression / |
16 | | - * reference) never parse authored source. |
| 4 | + * `@objectstack/lint/runtime` — the NARROW entry. Not the light one (#4463). |
| 5 | + * |
| 6 | + * ## What it is, measured |
| 7 | + * |
| 8 | + * This entry narrows the EXPORT SURFACE. It does not narrow the module graph, |
| 9 | + * and reading it as a weight boundary is a trap that costs a console build to |
| 10 | + * disprove. Measured by walking the static import graph of `src/` from each |
| 11 | + * entry, and by `stat` on this package's own `tsup` output: |
| 12 | + * |
| 13 | + * | | modules reached | ESM bundle | exported names | |
| 14 | + * |------------|------------------------|------------------|----------------| |
| 15 | + * | `.` | 72 | 552,936 B | 263 | |
| 16 | + * | `./runtime`| 71, 70 shared with `.` | 518,583 B (93.8%)| 5 | |
| 17 | + * |
| 18 | + * So: **93.8% of the bytes, 1.9% of the surface.** The one non-barrel module |
| 19 | + * `.` reaches and this entry does not is `lint-startup-registry-verdict.ts`; |
| 20 | + * that single module IS the whole graph delta, and it is not the reason the |
| 21 | + * entry exists. (Re-derive rather than trust these: the numbers move with the |
| 22 | + * rule set, the ratio has not.) |
| 23 | + * |
| 24 | + * The published `.d.ts` is the one place the narrowing shows as bytes — |
| 25 | + * `dist/runtime.d.ts` is a 278 B re-export line against `dist/index.d.ts`'s |
| 26 | + * ~158 KB — because types are erased, and code is not. |
| 27 | + * |
| 28 | + * ## What it does NOT carry |
| 29 | + * |
| 30 | + * `validateCapabilityReferences` is not exported here, and switching to this |
| 31 | + * entry to get a cheaper capability check gets neither half: the rule's code is |
| 32 | + * compiled INTO `dist/runtime.js` (it is a member of the one shared registry), |
| 33 | + * it is only not named on the way out. You pay its bytes and cannot call it. |
| 34 | + * The root entry is where that rule, and the other 257 names, are reachable. |
| 35 | + * |
| 36 | + * ## Why it exists anyway |
| 37 | + * |
| 38 | + * So the kernel boot path can name only the five gate functions below, and so a |
| 39 | + * test can prove it named nothing else. `@objectstack/metadata-protocol`'s |
| 40 | + * runtime gate must reach this package through this entry rather than the root |
| 41 | + * barrel, and `authoring-rule-wiring.test.ts` fails if it ever does otherwise. |
| 42 | + * That is an import-discipline boundary, machine-checked: it stops a |
| 43 | + * kernel-path consumer from hand-calling a CLI-only rule, which is the drift |
| 44 | + * #4463 closed. The value is the pin, not the payload. |
| 45 | + * |
| 46 | + * ## What is the PACKAGE's doing, not this entry's |
| 47 | + * |
| 48 | + * Lazy dependency loading. `lazy-deps.test.ts` pins that no `src/` file eagerly |
| 49 | + * imports `typescript` (~9 MB), `sucrase` or `ajv` — so importing `.` loads |
| 50 | + * none of them either, and this entry is not what buys that. |
| 51 | + * `runtime-lazy-deps.test.ts` adds the claim this consumer actually needs: that |
| 52 | + * RUNNING the gate on a real, gated body loads none of them, because the rules |
| 53 | + * #4463 wired to `runtime-publish` (flow / approval / expression / reference) |
| 54 | + * never parse authored source. Both are properties of which rules RUN. Neither |
| 55 | + * is a property of which entry you import — the react/jsx rules' modules are |
| 56 | + * present in this entry's graph, exactly as `runtime-lazy-deps.test.ts` states. |
17 | 57 | * |
18 | 58 | * The deliberate NON-goal: this is not a second, lighter rule set. It re-exports |
19 | 59 | * a filtered view of the ONE registry in `authoring-rules.ts`. If the two ever |
|
0 commit comments