Skip to content

Commit 45ac2ac

Browse files
committed
build(deps): make four Radix and sonner peers optional
@radix-ui/react-dialog, @radix-ui/react-dropdown-menu, @radix-ui/react-tooltip and sonner are imported only by subpath-only modules kept out of the root barrel. dep-guard reads the optional peers from peerDependenciesMeta.
1 parent c12c96c commit 45ac2ac

8 files changed

Lines changed: 63 additions & 15 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ contract — modules that are not exported are internal and may change in any re
6868
`StepListItem` and `StepDisplayStatus` stay public from `ui/step-list`;
6969
`GateShellModel` and `GateKind` from `ui/gate-block`. For `cn`, compose `clsx` and
7070
`tailwind-merge` directly: `twMerge(clsx(...inputs))`.
71+
- **Four peers are optional and their modules are subpath-only.** `@radix-ui/react-dialog`,
72+
`@radix-ui/react-dropdown-menu`, `@radix-ui/react-tooltip` and `sonner` move to
73+
`peerDependenciesMeta`. `ui/dialog`, `ui/command-palette`, `ui/mic-permission-dialog`,
74+
`ui/menu`, `ui/tooltip` and `ui/toast` leave the root barrel; import them by subpath
75+
(`import { Toaster, toast } from "@corbits/react-ui/ui/toast"`).
7176

7277
### Added
7378

‎IMPLEMENTATION.md‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ Why the library exists lives in [PRODUCT.md](./PRODUCT.md).
1010
- Package name `@corbits/react-ui`, ESM (`"type": "module"`), license
1111
`LGPL-2.1-only`.
1212
- Required peers: `react` and `react-dom` (`^18.2.0 || ^19.0.0`),
13-
`lucide-react` (`^0.545.0 || ^1.0.0`), `sonner` (`^2.0.7`),
14-
`@radix-ui/react-dialog` (`^1.1.15`), `@radix-ui/react-dropdown-menu`
15-
(`^2.1.16`), `@radix-ui/react-slot` (`^1.2.3`),
16-
`@radix-ui/react-tooltip` (`^1.2.8`).
13+
`lucide-react` (`^0.545.0 || ^1.0.0`), `@radix-ui/react-slot` (`^1.2.3`).
14+
- Optional peers (`peerDependenciesMeta`), each imported only by subpath-only
15+
modules kept out of the root barrel (`BARREL_EXCLUDED`):
16+
`@radix-ui/react-dialog` (`^1.1.15`; `ui/dialog`, `ui/command-palette`,
17+
`ui/mic-permission-dialog`), `@radix-ui/react-dropdown-menu` (`^2.1.16`;
18+
`ui/menu`), `@radix-ui/react-tooltip` (`^1.2.8`; `ui/tooltip`), `sonner`
19+
(`^2.0.7`; `ui/toast`).
1720
- Direct dependencies: `class-variance-authority`, `clsx`, `tailwind-merge`.
1821
- `sideEffects` is CSS-only (`**/*.css`). `files` publishes `dist/` only.
1922

‎README.md‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@ React components for agent and workflow surfaces — chat, runs, artifacts, anal
44

55
## Runtime support
66

7-
Node >= 24 consumes built `dist/`. Peers: `react` and `react-dom` (18 or 19), `lucide-react`, `sonner`, `@radix-ui/react-dialog`, `@radix-ui/react-dropdown-menu`, `@radix-ui/react-slot`, `@radix-ui/react-tooltip`.
7+
Node >= 24 consumes built `dist/`. Required peers: `react` and `react-dom` (18 or 19), `lucide-react`, `@radix-ui/react-slot`.
8+
9+
Optional peers, needed only by the subpaths that import them. These modules are not in the root barrel; import them by subpath:
10+
11+
| Peer | Subpaths |
12+
| --- | --- |
13+
| `@radix-ui/react-dialog` | `ui/dialog`, `ui/command-palette`, `ui/mic-permission-dialog` |
14+
| `@radix-ui/react-dropdown-menu` | `ui/menu` |
15+
| `@radix-ui/react-tooltip` | `ui/tooltip` |
16+
| `sonner` | `ui/toast` |
817

918
## Quickstart
1019

@@ -26,7 +35,8 @@ Import the stylesheet once at the app root, before your own CSS (no Tailwind bui
2635
```tsx
2736
import "@corbits/react-ui/styles.css";
2837

29-
import { ThemeProvider, Toaster, toast } from "@corbits/react-ui";
38+
import { ThemeProvider } from "@corbits/react-ui";
39+
import { Toaster, toast } from "@corbits/react-ui/ui/toast";
3040

3141
export function Root() {
3242
return (
@@ -70,7 +80,7 @@ export function NotFoundPage() {
7080
}
7181
```
7282

73-
Every component is importable by subpath (`@corbits/react-ui/ui/button`) or from the root (`@corbits/react-ui`).
83+
Every component is importable by subpath (`@corbits/react-ui/ui/button`); all but the optional-peer modules above are also exported from the root (`@corbits/react-ui`).
7484

7585
The brand faces (Red Hat Display, Space Mono) are named by the theme but not bundled. Load them yourself, or the stack falls through to system fonts; to use a face loaded under a generated name, override `--font-sans` / `--font-mono`.
7686

‎bun.lock‎

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@
5858
"react-dom": "^18.2.0 || ^19.0.0",
5959
"sonner": "^2.0.7"
6060
},
61+
"peerDependenciesMeta": {
62+
"@radix-ui/react-dialog": {
63+
"optional": true
64+
},
65+
"@radix-ui/react-dropdown-menu": {
66+
"optional": true
67+
},
68+
"@radix-ui/react-tooltip": {
69+
"optional": true
70+
},
71+
"sonner": {
72+
"optional": true
73+
}
74+
},
6175
"devDependencies": {
6276
"@eslint/js": "^9.39.1",
6377
"@happy-dom/global-registrator": "^20.11.2",

‎scripts/dep-guard.mjs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ import { dirname, join, relative, resolve } from "node:path";
1717

1818
const ROOT = new URL("../src", import.meta.url).pathname;
1919

20-
const OPTIONAL_PEERS = [];
20+
const PKG = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
21+
const OPTIONAL_PEERS = Object.keys(PKG.peerDependenciesMeta).filter(
22+
(peer) => PKG.peerDependenciesMeta[peer].optional,
23+
);
2124

2225
const RULES = [
2326
{ label: "@workbench/*", pattern: /["'](@workbench\/[^"']*)["']/g, allow: () => false },

‎scripts/generate-exports.mjs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@ const INTERNAL = new Set([
3030
"lib/workflow-registry",
3131
"ui/chat-dock-timing",
3232
]);
33-
const BARREL_EXCLUDED = new Set();
33+
const BARREL_EXCLUDED = new Set([
34+
"ui/command-palette",
35+
"ui/dialog",
36+
"ui/menu",
37+
"ui/mic-permission-dialog",
38+
"ui/toast",
39+
"ui/tooltip",
40+
]);
3441

3542
const walk = (dir) =>
3643
readdirSync(dir).flatMap((entry) => {

‎src/index.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
// on purpose and must be imported by their subpath. The barrel is a single
88
// module: anything it re-exports is loaded by any root import, so one such
99
// re-export would make the optional peer mandatory for everyone.
10+
// @corbits/react-ui/ui/command-palette
11+
// @corbits/react-ui/ui/dialog
12+
// @corbits/react-ui/ui/menu
13+
// @corbits/react-ui/ui/mic-permission-dialog
14+
// @corbits/react-ui/ui/toast
15+
// @corbits/react-ui/ui/tooltip
1016

1117
export * from "./blocks/login/auth-layout.js";
1218
export * from "./blocks/login/login-form.js";
@@ -49,12 +55,10 @@ export * from "./ui/chat-input.js";
4955
export * from "./ui/chat-panel.js";
5056
export * from "./ui/chat-thread.js";
5157
export * from "./ui/checkbox.js";
52-
export * from "./ui/command-palette.js";
5358
export * from "./ui/compare-body.js";
5459
export * from "./ui/confirm-button.js";
5560
export * from "./ui/corbits-mark.js";
5661
export * from "./ui/csv-table.js";
57-
export * from "./ui/dialog.js";
5862
export * from "./ui/dictation-status-line.js";
5963
export * from "./ui/dither-canvas.js";
6064
export * from "./ui/embed-body.js";
@@ -72,10 +76,8 @@ export * from "./ui/library-page-header.js";
7276
export * from "./ui/list-detail.js";
7377
export * from "./ui/live-run-banner.js";
7478
export * from "./ui/live-status-line.js";
75-
export * from "./ui/menu.js";
7679
export * from "./ui/message-bubble.js";
7780
export * from "./ui/mic-button.js";
78-
export * from "./ui/mic-permission-dialog.js";
7981
export * from "./ui/notifications-bell.js";
8082
export * from "./ui/now-cards.js";
8183
export * from "./ui/page-panel.js";
@@ -114,12 +116,10 @@ export * from "./ui/thinking-indicator.js";
114116
export * from "./ui/thinking-label.js";
115117
export * from "./ui/thinking-mark.js";
116118
export * from "./ui/time-series-chart.js";
117-
export * from "./ui/toast.js";
118119
export * from "./ui/token-mosaic.js";
119120
export * from "./ui/tool-block.js";
120121
export * from "./ui/tool-narrative.js";
121122
export * from "./ui/tool-picker.js";
122-
export * from "./ui/tooltip.js";
123123
export * from "./ui/top-bar.js";
124124
export * from "./ui/trace-waterfall.js";
125125
export * from "./ui/typing-indicator.js";

0 commit comments

Comments
 (0)