# ADR 0005: Frontend Source vs Distribution

Date: 2026-04-11

## Status
Accepted

## Context

The frontend is authored in TypeScript/Vue and must be served to ComfyUI as
browser-ready JavaScript. Official ComfyUI documentation allows a custom
`WEB_DIRECTORY`, and the official TypeScript extension template uses a source
UI directory plus a generated `dist/` directory.

| Directory | Role |
|-----------|------|
| `ui/` | Source: TypeScript, Vue SFCs, Pinia stores, tests, and authored assets. |
| `dist/` | Artifact: Vite output served by ComfyUI via `WEB_DIRECTORY`. |

## Decision

1. `ui/` is the single source of truth for frontend development.
2. `dist/` is generated by `npm run build` and is the only frontend directory served by ComfyUI.
3. `__init__.py` points `WEB_DIRECTORY` at `dist/`; it does not fall back to `ui/` because ComfyUI only auto-loads browser-ready `.js` files.
4. `pyproject.toml` sets `WebDirectory = "dist"` and includes `dist/` for registry packaging.
5. Any source change under `ui/` that affects runtime behavior must be followed by `npm run build`.

## Consequences

- The source/build split matches the official ComfyUI TypeScript template shape.
- End users can install the node pack without Node.js or a local build step.
- Pull requests that modify frontend behavior may include generated `dist/` churn.

## Notes

- `vite.config.mjs` defines `ui/entry.ts` as the source entry and `dist/` as output.
- `vitest.config.mjs`, ESLint, TypeScript, and architecture tests target `ui/`.
- ComfyUI loads `dist/entry.js` through `WEB_DIRECTORY`.
