# @sanity/federation

Internal package providing [Module Federation](https://module-federation.io/) support for Sanity apps and studios. Used by the Sanity CLI — not intended for direct consumption.

## Structure

```
src/
  runtime/   → Runtime utilities for federated modules
  vite/      → Vite plugin for federation builds
```

### Vite plugin

The Vite plugin composes three internal plugins:

1. **`sanity/environment`** — registers a `federation` build environment with Rollup, outputting to `dist/federation/`.
2. **`sanity/federation-runtime`** — for studios, generates a `.sanity/federation/remote-entry.jsx` entry file that wraps the Sanity Studio component.
3. **`@module-federation/vite`** — the upstream Module Federation plugin, configured with the resolved `exposes` map and manifest generation.

#### Entry resolution

| Mode   | Entry point                             |
| ------ | --------------------------------------- |
| App    | `./src/App.tsx`                         |
| Studio | `./.sanity/federation/remote-entry.jsx` |

The `exposes` map always includes `./App` pointing at the resolved entry. Additional entries passed via the `exposes` option are merged on top.

## License

MIT
