Table of Contents

Federated remote anatomy

The expected structure of a MIB custom federated remote and the full export contract the shell reads from it. Grounded on the GVP reference remote (MIBFrontEnd-GVP-components@main d5a69740, 1.6.5) and the shell's own Config type (MibFrontEnd apps/cms/src/application/config/federation.ts:23-42, cms 2.48.0).

The export contract — 12 keys, one file

The exposed module is one file (exposes: { './all': './src/main.tsx' }); its exports ARE the contract. The shell types this superset (the GVP remote uses 7 of them):

Export Type Notes
components (+default) Record<viewTypeKey, FC<MibComponentProps>> keys must equal DB COMPONENT_VIEW_TYPE; reference wraps each lazy() entry in <Suspense fallback={suspenseSkeletons[key] ?? DefaultSkeleton}>
decorators Decorators the action seam — frontend-decorators
useFormChange (pageKey, form, setComponents) => void top-level export, not nested under hooks; flat if (pageKey === …) dispatcher over pages/<page_key>/ dirs; runs additively across all slots
skeletons Record<PAGE key, FC> page-level loading skeletons — keyed by DB pageKey
suspenseSkeletons Record<VIEWTYPE key, FC> per-component Suspense fallbacks — keyed like components. The two maps key differently on purpose; mixing them up is a silent no-op
translations nested JSON registered under the cc: namespace; values may be dict:<dictionary/key> CMS-dictionary indirections
handlers, model, populateDB MSW trio dev/test mocks; production build aliases common/mock-server → mock-server-stub
variants, renderTypes, tr, dataExtractor typed, unused by the reference renderTypes: Record<string, TableTypes.CellComponent> is a custom list-cell hook at the contract level — available-but-unproven; read the shell consumption before relying

Federation config

// vite.config.ts (remote)
federation({
  name: 'customComponents',            // or customComponents2 / customComponents3 — nothing else works
  filename: 'remoteEntry.js',
  exposes: { './all': './src/main.tsx' },
  shared: ['react', 'react-dom', '@agilecontent/ui', '@agilecontent/mib-api-connector',
           'react-i18next', '@agilecontent/mib-modules', 'styled-components', 'swr'],
})

Array shorthand ⇒ no singleton/requiredVersion guards — version alignment with the shell is manual. The reference pins all @agilecontent/* exactly (mib-modules 1.39.0, ui 2.26.0, api-connector 1.20.0), react ^18.2.0. Omitting @agilecontent/mib-modules from shared means your action components read a different ComponentsContext and useDecorators returns undefined.

antd is deliberately NOT shared (pinned 5.29.3, duplicated into the remote bundle — two antd copies at runtime). Import Tooltip/useModal/SecondaryButton/Form/icons from @agilecontent/ui; every GVP decorator does.

Repo tree (reference)

src/
  main.tsx                 # THE exposed './all' module
  components.ts            # lazy() registry → components map (viewType key → FC)
  components/<widget>/     # ~40 custom widgets
  core-decorators/         # decorators export: index.ts → related-list/{header-actions,item-actions}/<action>/
  hooks/use-form-change/   # dispatcher + pages/<page_key>/ (31 pages)
  common/                  # adapters/http (axios), utils/url, event-bus, mock-server
  application/             # config, lang/mib/translations.json
  helpers/dev/             # standalone dev app (federation NOT exercised)

common/adapters/http's getBaseUrl() falls back to window.cms.instance when VITE_API_URL is unset — that is how the remote inherits the shell's auth interceptors in production. Route handler calls through it, never raw fetch.

Shipping

Docker: node build stage (throwaway .npmrc from ARG NPM_AUTH_TOKEN — GitHub Packages PAT with read:packages), then nginx-unprivileged serving dist on :4000. nginx serves /assets/remoteEntry.js with Cache-Control: no-cache (the one file that must never be stale); other assets immutable 7d + CORS *. start.sh writes /tmp/config.json (API_URL, BASE_PATH) — the only runtime knobs; everything else is baked at build (process.env is define-shimmed at build time).

Dev mode limits

index.html loads src/helpers/dev (not main.tsx): it renders ONE component picked by VITE_STANDALONE, wrapped in withPageData(<hardcoded pageKey/id/componentKey>), MSW-mocked. Federation is not exercised and there is no ComponentsContextProvider — decorators and useFormChange are unrenderable in dev and Storybook. Verify them against a real shell: npm run build && npm run preview (:4000) and point the stack's CUSTOM_COMPONENTS_URL (or mib dev route) at it.

i18n

Labels via t('cc:…'); keys extracted by npm run i18n-extract into src/application/lang/mib/translations.json (i18next-parser.cjs — the README's helpers/i18n path is stale). Values may be dict: indirections (CMS-editable).

Recipe — bootstrap a new remote from zero

The registry item recipe.bootstrap-remote carries the validated scaffold — package.json with the @agilecontent/* pins matching cms 2.48.0, .npmrc, vite.config.ts (slot name, ./all, the 8 shared deps), src/main.tsx export surface, a hello widget, Dockerfile + nginx. Build-validated 2026-08-06: npm install + tsc --noEmit + vite build → dist/assets/remoteEntry.js. Fetch it with mib get recipe.bootstrap-remote.

See also: shell-architecture · frontend-decorators · viewtype-resolution.