# runtime-demo This example demos automatic-vendor-sharing, each host/remote will share all vendors possible, with react listed as a singleton - `host` consumes remote. - `remote1` exposes a blue button component. - `remote2` exposes a red button component. host declare remote2 in webpack.config.js, and use `@module-federation/runtime` to load remote1 dynamic # Running Demo Run `pnpm run app:runtime:dev` to start host, remote1, remote2. - host: [localhost:3005](http://localhost:3005/) - remote1: [localhost:3006](http://localhost:3006/) - remote2: [localhost:3007](http://localhost:3007/) ## Observability Demo The observability fixture lives in the runtime host. The host explicitly enables `@module-federation/observability-plugin` for this demo, so the report is generated by the runtime plugin instead of local UI state. The host also installs `ObservabilityBuildPlugin`, so each build writes a build summary to `.mf/observability/build-info.json`. If a host build fails after the plugin runs, the build-side report is written to `.mf/observability/build-report.json`. - observability fixture page: [localhost:3005/observability](http://localhost:3005/observability) - observability showcase: [localhost:3005/observability-showcase](http://localhost:3005/observability-showcase) Start the demo first: ```bash pnpm run app:runtime:dev ``` Then open the observability fixture page and use these controls: - `observability-showcase`: a clean recording page that looks like a normal product page. Opening the page loads `runtime_remote2/ProfileCard` with `createInstance`. Click `Open Analytics Workspace` to route to the analytics view, which loads `runtime_remote2/AnalyticsPanel` with another `createInstance`, resolves `react`, and then fails to resolve `observability-customer-sdk` because the route asks for `^3.0.0` while only `2.1.0` is available. The page renders a limited analytics view instead of crashing, without exposing the low-level shared error in the UI. Use this page to record an AI agent discovering which expose was attempted, which shared dependency failed, why the limited view appeared, and what evidence exists in the observability report. Use `/observability` for the full fixture matrix. - Build observability: after the host compiles, check `apps/runtime-demo/3005-runtime-host/.mf/observability/build-info.json`. It should include `runtime_host`, the remote manifest URL, `Button`, and shared dependencies such as `react`, without local source paths. A clean build should not leave a stale `apps/runtime-demo/3005-runtime-host/.mf/observability/build-report.json`. - `Load success remote`: loads `dynamic-remote/ButtonOldAnt` from remote2. The status should become `success`, the remote button should render, and the report should include a completed `loadRemote` timeline with `summary.outcome: "runtime-loaded"` and per-phase success facts under `summary.phases`. The report should also include `diagnosis.outcome: "runtime-loaded"`. The same report is available at `window.__FEDERATION__.__OBSERVABILITY__.runtime_host.getLatestReport()`. - `Preload remote`: calls `preloadRemote` for the real `dynamic-remote` producer. The status should become `success`, and the latest report should include `summary.outcome: "preloaded"` plus a `preload` phase. This verifies that preloading is not treated as a failed or stuck component load. - `Load missing expose`: loads a missing expose from remote2. The status should become `error`, and the report should include `dynamic-remote/__missing_expose__` with `failedPhase: "expose"`. The `diagnosis.actions` list should include a concrete expose check. The browser console should print an observability hint with a `traceId`. - `Load broken manifest`: loads a remote with a broken manifest URL. The status should become `error`. The report should include the original manifest URL, `RUNTIME-003`, `ownerHint: "host"`, `diagnosis.facts.url`, and a manifest check in `diagnosis.actions`. - `Load remote URL error`: registers a remote whose manifest URL points to an unavailable server. The report should fail at `manifest` and include `RUNTIME-003`, the original URL, and a manifest check. - `Load retry recovered`: serves a remoteEntry that fails on the first script load and succeeds on retry. The report should be successful with `summary.outcome: "recovered"`, `summary.flags.retried: true`, and a retry recovery warning. - `Load fallback success`: loads a missing expose and lets the demo fallback plugin return a fallback module. The report should be successful with `summary.outcome: "recovered"`, keep the original expose failure under `summary.error`, and set `summary.flags.fallback: true`. - `Load manifest missing fields`: serves a JSON manifest that misses required fields. The report should fail at `manifest`, show the missing fields, and include a manifest check. - `Load wrong globalName`: serves a manifest and remoteEntry where the remoteEntry registers a different global name from the manifest. The report should fail at `remoteEntry`, include `RUNTIME-001`, and include a remote global check. - `Load remoteEntry execution error`: serves a remoteEntry that throws while it is being executed. The report should fail at `remoteEntry`, include `RUNTIME-008`, classify the resource error as script execution, and include a remoteEntry check. - `Load snapshot match error`: registers a version-only remote that cannot be matched from deployment `moduleInfo`. The report should include `RUNTIME-007`, `moduleInfo.reason: "remote-snapshot"`, the clipped `moduleInfo.availableNames`, and a moduleInfo check. - `Mark business loaded`: calls the observability plugin's component success API, and the report should include `component:business-loaded` with `summary.outcome: "component-loaded"`. The demo also sends sample metadata to verify that business-provided metadata stays visible in the report. - `Shared miss`: triggers a missing shared provider report. The report should include `observability-missing-shared`, `missing-provider`, and shared provider/version checks in `diagnosis.actions`. - `Shared version mismatch`: asks for an unsupported React version. The report should include `react`, `^99.0.0`, the available version, and `version-mismatch`. - `Shared unexpected provider`: resolves a shared dependency from a remote-like provider even though the host provider is present. The report should be successful and include `observability-provider-choice`, `provider: "runtime_remote2"`, and `selectedVersion: "2.0.0"`. - `Load multi-consumer chain`: creates two runtime consumers with `createInstance`, loads different exposes from the real `runtime_remote2` remote on port 3007, and gives each consumer its own shared dependency. It records the remote load report, shared dependency report, business component success event, and repeated load cache evidence. Use this scenario when validating whether an agent can answer who loaded which expose, which shared provider was selected, and whether the producer load reused cached runtime state. - `Eager config error`: synchronously consumes an async shared dependency. The report should include `observability-async-shared`, `RUNTIME-005`, and `sync-async-boundary`, with `ownerHint: "shared"` and an eager config check in `diagnosis.actions`. - `Runtime eager config error`: synchronously consumes an async shared dependency from the pure runtime path. The report should include `observability-runtime-async-shared`, `RUNTIME-006`, and `sync-async-boundary`, with the same eager config check. Run the automated verification: ```bash pnpm run ci:local --only=e2e-runtime ``` This command installs the e2e dependencies if needed, builds the packages, starts the host and remotes, and runs the Cypress checks. The observability fixture is covered by the `observability demo fixture` tests in the runtime host e2e suite.