Files
ui/pkg/hanzo/README.md
zeekayandHanzo Dev fc3463d89c Derive the hanzo exports map from its members
@hanzo/ui publishes 43 subpaths and adds more than anyone remembers to
mirror, so a hand-listed map rots into ERR_PACKAGE_PATH_NOT_EXPORTED under
a name that promised the subpath. scripts/gen.mjs reads the members' own
exports and writes one forwarder per subpath, by the member's specifier,
so the inner resolution happens in the consumer's node_modules under the
consumer's conditions and a forwarder cannot answer differently from what
it forwards to. 359 subpaths, and the suite asserts the map on disk still
says what the members say.

@hanzo/iam, @hanzo/ai and @hanzo/event join @hanzo/ui and @hanzo/gui as
members. src/ui.ts and src/gui.ts go: the generated forwarders are what
they were written by hand to be.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-08 15:04:30 -07:00

2.1 KiB

hanzo

One dependency over the Hanzo frontend. Everything the libraries publish is reachable under this one name, subpath for subpath.

pnpm add hanzo
member reached as
@hanzo/ui — components hanzo/ui, hanzo/ui/chat, hanzo/ui/agents, hanzo/ui/theme.css, …
@hanzo/gui — the primitive substrate @hanzo/ui renders through hanzo/gui
@hanzo/iam — identity hanzo/iam, hanzo/iam/react, hanzo/iam/server, …
@hanzo/ai — models hanzo/ai, hanzo/ai/react
@hanzo/event — analytics hanzo/event, hanzo/event/react

A subpath of hanzo re-exports the member subpath of the same name by the member's own specifier, so it is the same module: same components, same types, and the same browser/node and import/require conditions, resolved where you install rather than here.

The exports map is generated from the members' own exports at build time (scripts/gen.mjs), so a subpath a library adds arrives with the next release rather than when someone remembers to mirror it.

Three ways in

// 1 — the umbrella, eager.
import { Button } from 'hanzo/ui'
import { useSession } from 'hanzo/iam/react'

// 2 — the umbrella, lazy. The root imports no library, so it costs a chunk
//     boundary and nothing else until a loader is called.
import { ui, gui } from 'hanzo'
const { Button } = await ui()

// 3 — the libraries by their own names, unchanged.
import { Button } from '@hanzo/ui'

Reach for the lazy root when the components belong to a route or a dialog the first paint does not need — await ui() puts them in their own chunk. Reach for hanzo/ui when they are on the page anyway, and a second round trip buys nothing.

version names the release you resolved:

import { version } from 'hanzo'

What is not forwarded

Data files. @hanzo/plans publishes thirteen .json subpaths and JSON has no re-export syntax, so forwarding it would mean shipping a second, staler copy of every one. Name that package directly.

License

Apache-2.0 OR MIT, at your option. See LICENSE-APACHE, LICENSE-MIT and NOTICE.