How module-federation/vite works
Main Components
a) Core Plugin Components:
• Plugin System (Central Hub)
• Module Federation Manager
• Virtual Module System
• Plugin Processors
• Remote Entry Handler
• Shared Module Manager
b) Integration Points:
• Vite Build Pipeline
• Module Federation Runtime
• Remote Entry Points
• Host Applications
• Remote Applications
┌─────────────────────────────────────────────────────────────┐
• Module Federation Plugin │
• ┬───────────────────┬──────────────────┤
• Plugin System │ Virtual Modules │ Utils Layer │
• ┌───────────────┐ │ ┌───────────────┐ │ ┌──────────────┐ │
• Federation Core│ │ │Remote Entry │ │ │Promise Store │ │
• Plugin Manager │ │ │Shared Modules │ │ │Package Utils │ │
• Config Normal. │ │ │Exposes Handler│ │ │Module Normal.│ │
• ┘ │ └───────────────┘ │ └──────────────┘ │
• ┤
• Integration Layer │
• ┬───────────────────┬──────────────────┤
• Vite Build Hook │ Remote Loading │ Shared Module │
• Integration │ Management │ Resolution │
• ┴───────────────────┴──────────────────┘
Key Relationships
a) Data Flow:
• Host → Remote Entry Points
• Plugin → Vite Build Pipeline
• Virtual Modules → Runtime Loading
• Shared Modules → Multiple Applications
b) Dependencies:
• Plugin → Vite
• Remote Apps → Host Apps
• Shared Modules → All Apps
Implementation Details to Highlight
• Plugin Architecture:
• Plugin system's modular structure (/src/plugins/)
• Virtual module generation (/src/virtualModules/)
• Utility services integration (/src/utils/)
• Integration Points:
• Demonstrate how different bundlers can work together (Vite, Webpack, Rspack)
• Support for multiple frameworks (Vue, React, Svelte, etc.)