Add build and runtime configuration for micro-frontends

What does this MR do and why?

Adds the build and runtime plumbing the monolith needs to consume a micro-frontend (MFE) published as an npm package. In phase 1 of the MFE architecture, npm is the delivery mechanism, so the MFE ships inside the monolith's own assets. Nothing mounts an MFE yet.

  • Dependencies: @gitlab-mfe/duo-chat, @gitlab-mfe/context (the data contract) and @module-federation/enhanced (the Module Federation 2.0 runtime). .npmrc points the @gitlab-mfe scope at the gitlab-mfe package registry, so both yarn and untamper-my-lockfile resolve it there, and config/dependency_decisions.yml records the MIT license, which the packages don't declare yet.
  • Bundlers: webpack, rspack and Vite copy @gitlab-mfe/duo-chat/dist to assets/webpack/mfes/duo-chat-<version>/ and expose that path as process.env.MFE_DUO_CHAT_PUBLIC_PATH. The version is part of the path because the MFE's chunk names carry no content hash. Webpack 4 also gets aliases and a Babel pass for the @module-federation/* and @gitlab-mfe/context export sub-paths it can't resolve on its own.
  • Loader: ~/mfe_loader provides loadMFEModule(), which registers and loads a remote through the MF runtime. It also provides buildGitLabContext(), which collects gon, the CSRF token and the mount element's dataset into the GitLabContext shape.
  • CSP: in development only, MFE_SERVER_ORIGIN adds an external MFE dev server origin to the CSP, so the remote can be served with hot reload. Production is unchanged.

This is MR 2 of a 4-MR stack, split from !233214:

  1. Feature flag: !268037 (merged)
  2. Build and runtime configuration (this MR)
  3. Context contract CI job: !268043 (merged)
  4. Agentic Duo Chat from the MFE in the AI panel: !268044

References

Screenshots or screen recordings

Not applicable: no visible change.

How to set up and validate locally

  1. Run yarn install.
  2. Start the frontend dev server and check that public/assets/webpack/mfes/duo-chat-0.1.0/mf-manifest.json (webpack) or /assets/vite/mfes/duo-chat-0.1.0/mf-manifest.json (Vite) is served.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

This MR adds dependencies and changes yarn.lock, so it needs an Application Security review.

Edited by Rafa Frederico

Merge request reports

Loading
Loading