❗ Blank Page on Reload with Vite Module Federation (Host ↔ Remote Circular Dependency + Shared Scope Issue)
📌 Description
I am working on a React + Vite Micro Frontend architecture using vite-plugin-federation, with multiple applications sharing modules between each other.
The setup involves bi-directional module federation, where both Host and Remote apps consume each other.
🧩 Project Structure
🔹 Host App (Port: 5001)
-
Exposes:
- Header
- Login
- Dashboard
- hostCss
-
Consumes Remotes:
🔹 Core App (Port: 5002)
-
Exposes:
-
Consumes Remote:
- host (Header, Login, Dashboard, hostCss)
🔹 BRM App (Port: 5003)
-
Exposes:
-
Consumes Remote:
- host (Header, Login, Dashboard, hostCss)
🔁 Dependency Pattern
Host → Core
Host → BRM
Core → Host
BRM → Host
This creates a circular (bi-directional) federation dependency.
✅ Expected Behavior
- Core and BRM load inside Host
- Shared components (Header, Login, Dashboard) work across apps
- Page reload should reinitialize all modules correctly
❌ Actual Behavior
🔍 Detailed Observations
-
Issue occurs specifically after refresh
-
Remote modules fail to render even though:
- remoteEntry.js is accessible
-
No consistent error in console
-
In some cases:
import("remote/module") silently fails
- React Suspense fallback not triggered
⚠️ Suspected Root Cause
Based on behavior, the issue seems related to:
1. Circular Federation Dependency
- Host stand alone
- Core/BRM depend on Host - remote to load some component
- This may break module resolution order during reload
2. Shared Scope Initialization Timing
- Shared libs (react, react-dom, redux) may not be initialized before remote usage
- On reload, federation runtime may fail to resolve shared modules
3. Eager/Dynamic Import Conflict
4. CSS/Side Effects (hostCss)
- Shared CSS exposed from Host may not load correctly in remotes during refresh
⚙️ Tech Stack
- React
- Vite
- vite-plugin-federation
- Redux Toolkit
📦 Federation Config (Simplified)
Host
remotes: {
core: "http://localhost:5002/remoteEntry.js",
brm: "http://localhost:5003/remoteEntry.js",
}
Core / BRM
remotes: {
host: "http://localhost:5001/remoteEntry.js",
}
🧪 Steps to Reproduce
- Start Host (5001)
- Start Core (5002)
- Start BRM (5003)
- Open Host in browser
- Page loads correctly
- Refresh browser
- ❌ Blank page appears
❓ Questions
-
Is bi-directional federation (Host ↔ Remote) officially supported in vite-plugin-federation?
-
Does circular dependency break shared scope initialization on reload?
-
Is there a required pattern for:
- sharing components from Host to Remotes
- avoiding runtime timing issues?
-
Should remotes avoid consuming host entirely?
💡 Additional Notes
- Using lazy loading (
React.lazy) improves stability slightly but does not fully fix the issue
- Standalone remotes require fallback handling for host imports
- Issue does NOT occur when remotes are not running
🙏 Expected Guidance
Looking for:
- Recommended architecture pattern (unidirectional vs bi-directional)
- Proper way to share common modules (Header, Layout, CSS)
- Fix or workaround for reload issue
Thank you!
❗ Blank Page on Reload with Vite Module Federation (Host ↔ Remote Circular Dependency + Shared Scope Issue)
📌 Description
I am working on a React + Vite Micro Frontend architecture using vite-plugin-federation, with multiple applications sharing modules between each other.
The setup involves bi-directional module federation, where both Host and Remote apps consume each other.
🧩 Project Structure
🔹 Host App (Port: 5001)
Exposes:
Consumes Remotes:
🔹 Core App (Port: 5002)
Exposes:
Consumes Remote:
🔹 BRM App (Port: 5003)
Exposes:
Consumes Remote:
🔁 Dependency Pattern
This creates a circular (bi-directional) federation dependency.
✅ Expected Behavior
❌ Actual Behavior
Running only Host → works correctly
Running Host + Core + BRM:
🔍 Detailed Observations
Issue occurs specifically after refresh
Remote modules fail to render even though:
No consistent error in console
In some cases:
import("remote/module")silently failsBased on behavior, the issue seems related to:
1. Circular Federation Dependency
2. Shared Scope Initialization Timing
3. Eager/Dynamic Import Conflict
Remotes may be imported before federation runtime is fully ready
Especially when using:
4. CSS/Side Effects (hostCss)
⚙️ Tech Stack
📦 Federation Config (Simplified)
Host
Core / BRM
🧪 Steps to Reproduce
❓ Questions
Is bi-directional federation (Host ↔ Remote) officially supported in vite-plugin-federation?
Does circular dependency break shared scope initialization on reload?
Is there a required pattern for:
Should remotes avoid consuming host entirely?
💡 Additional Notes
React.lazy) improves stability slightly but does not fully fix the issue🙏 Expected Guidance
Looking for:
Thank you!