feat(browser): support Module Federation in Browser Mode - #1639
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 16bbd5be33
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Rsdoctor Bundle Diff AnalysisFound 13 projects in monorepo, 3 projects with changes. 📊 Quick Summary
📋 Detailed Reports (Click to expand)📁 browserPath:
📦 Download Diff Report: browser Bundle Diff 📁 core/browserPath:
📦 Download Diff Report: core/browser Bundle Diff 📁 core/mainPath:
📦 Download Diff Report: core/main Bundle Diff Generated by Rsdoctor GitHub Action |
16bbd5b to
c4064aa
Compare
Deploying rstest with
|
| Latest commit: |
4604e31
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://dc69f7b2.rstest.pages.dev |
| Branch Preview URL: | https://9aoy-feat-mf-browser-mode.rstest.pages.dev |
c4064aa to
6621527
Compare
6621527 to
387dfab
Compare
387dfab to
4604e31
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4604e31562
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| }, | ||
| plugins: [ | ||
| pluginReact(), | ||
| federation({ |
There was a problem hiding this comment.
Select the browser target for the federation plugin
In this Browser Mode config, calling federation without its second argument retains the plugin's Node-target default, so ComponentRemote.browser.test.tsx is bundled with the Node federation setup instead of the web runtime and cannot load the browser remote. The headed-watch fixture correctly passes { target: 'browser' }; apply the same option here and in the Browser Mode documentation example.
Useful? React with 👍 / 👎.
|
|
||
| export default defineConfig({ | ||
| federation: true, | ||
| globalSetup: ['./scripts/rstestBrowserGlobalSetup.ts'], |
There was a problem hiding this comment.
Run browser global setup before collecting federated tests
When this configuration is used with rstest list, browser collection goes directly through executor.collect() without running runBrowserGlobalSetupStage, unlike node collection. The static component-app/Button import is evaluated during collection, but this setup is what starts the remote on port 3001, so discovery returns a BrowserCollectError or times out; run and tear down browser global setup around non-files-only collection.
Useful? React with 👍 / 👎.
| 'serve', | ||
| ]); | ||
| globalThis.__RSTEST_MF_CHILDREN__!.push(server); | ||
| await waitForUrl(browserRemoteEntryUrl, 30_000); |
There was a problem hiding this comment.
Clean up the remote when readiness fails
If the browser server starts but remoteEntry.js never becomes reachable—for example, because the output filename changes or serve cannot expose the build—this await throws before the global setup successfully registers its exported teardown. Rstest's failed-setup path therefore terminates the setup worker without calling cleanupRemote, leaving the spawned pnpm serve process and port 3001 behind; catch this readiness failure, clean up the tracked child, and then rethrow.
Useful? React with 👍 / 👎.
Summary
This PR enables Module Federation in Rstest Browser Mode using the bundler's web federation runtime while preserving the existing Node runner compatibility shims.
federationand@module-federation/rstestin browser projects, including browser runtime config projectionRelated Links
Checklist