Loading
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)..npmrcpoints the@gitlab-mfescope at the gitlab-mfe package registry, so both yarn anduntamper-my-lockfileresolve it there, andconfig/dependency_decisions.ymlrecords the MIT license, which the packages don't declare yet. - Bundlers: webpack, rspack and Vite copy
@gitlab-mfe/duo-chat/disttoassets/webpack/mfes/duo-chat-<version>/and expose that path asprocess.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/contextexport sub-paths it can't resolve on its own. - Loader:
~/mfe_loaderprovidesloadMFEModule(), which registers and loads a remote through the MF runtime. It also providesbuildGitLabContext(), which collectsgon, the CSRF token and the mount element's dataset into theGitLabContextshape. - CSP: in development only,
MFE_SERVER_ORIGINadds 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:
- Feature flag: !268037 (merged)
- Build and runtime configuration (this MR)
- Context contract CI job: !268043 (merged)
- Agentic Duo Chat from the MFE in the AI panel: !268044
References
- gitlab-org#22344
- gitlab-org/frontend/gitlab-mfe#4 (closed)
- https://gitlab.com/gitlab-org/frontend/gitlab-mfe/-/blob/main/docs/architecture-rfc.md
- !233214
Screenshots or screen recordings
Not applicable: no visible change.
How to set up and validate locally
- Run
yarn install. - 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