A modern microfrontend architecture demonstrating the integration of multiple frontend frameworks (React, Vue, Svelte) using Webpack Module Federation and Vite.
This project showcases a Host-Remote microfrontend pattern where:
- Host Application: React + Vite dashboard that orchestrates and displays all games
- Remote Applications: Independent game applications built with different frameworks
- ๐ฏ Tic Tac Toe: Built with Svelte
- โ๏ธ Checker Game: Built with Vue.js
- ๐ช Hangman: Built with React
webpack-micro/
โโโ apps/
โ โโโ host-dashboard/ # React Host (Port 3000)
โ โ โโโ src/
โ โ โ โโโ App.jsx # Main dashboard component
โ โ โ โโโ App.css # Dashboard styles
โ โ โ โโโ main.jsx # Entry point
โ โ โโโ vite.config.js # Vite + Module Federation config
โ โ โโโ package.json
โ โ
โ โโโ tictactoe-svelte/ # Svelte Remote (Port 3001)
โ โ โโโ src/
โ โ โ โโโ App.svelte # Exposed component
โ โ โโโ vite.config.ts # Vite + Federation config
โ โ โโโ package.json
โ โ
โ โโโ checker-vue/ # Vue Remote (Port 3002)
โ โ โโโ src/
โ โ โ โโโ App.vue # Exposed component
โ โ โโโ vite.config.ts # Vite + Federation config
โ โ โโโ package.json
โ โ
โ โโโ hangman-react/ # React Remote (Port 3003)
โ โโโ src/
โ โ โโโ App.tsx # Exposed component
โ โโโ vite.config.ts # Vite + Federation config
โ โโโ package.json
โ
โโโ package.json # Root workspace config
โโโ pnpm-workspace.yaml # Workspace definition
โโโ README.md # This file
- Node.js (v16 or higher)
- npm or pnpm
-
Clone the repository
git clone <repository-url> cd webpack-micro
-
Install dependencies for all applications
# Install dependencies for each app cd apps/host-dashboard && npm install cd ../tictactoe-svelte && npm install cd ../checker-vue && npm install cd ../hangman-react && npm install
Open 4 separate terminals and run:
# Terminal 1 - Host Dashboard
cd apps/host-dashboard
npm run dev
# Terminal 2 - Tic Tac Toe (Svelte)
cd apps/tictactoe-svelte
npm run dev
# Terminal 3 - Checker Game (Vue)
cd apps/checker-vue
npm run dev
# Terminal 4 - Hangman (React)
cd apps/hangman-react
npm run dev
Start any individual application:
# Host Dashboard only
cd apps/host-dashboard && npm run dev
# Individual games
cd apps/tictactoe-svelte && npm run dev
cd apps/checker-vue && npm run dev
cd apps/hangman-react && npm run dev
- ๐ Host Dashboard: http://localhost:3000
- ๐ฏ Tic Tac Toe: http://localhost:3001
- โ๏ธ Checker Game: http://localhost:3002
- ๐ช Hangman: http://localhost:3003
// apps/host-dashboard/vite.config.js
import federation from '@originjs/vite-plugin-federation'
export default defineConfig({
plugins: [
react(),
federation({
name: 'host-dashboard',
remotes: {
tictactoeApp: 'http://localhost:3001/assets/remoteEntry.js',
checkerApp: 'http://localhost:3002/assets/remoteEntry.js',
hangmanApp: 'http://localhost:3003/assets/remoteEntry.js',
},
shared: ['react', 'react-dom']
})
]
})
// apps/tictactoe-svelte/vite.config.ts
federation({
name: 'tictactoeApp',
filename: 'remoteEntry.js',
exposes: {
'./App': './src/App.svelte'
},
shared: ['svelte']
})
// apps/checker-vue/vite.config.ts
federation({
name: 'checkerApp',
filename: 'remoteEntry.js',
exposes: {
'./App': './src/App.vue'
},
shared: ['vue']
})
// apps/hangman-react/vite.config.ts
federation({
name: 'hangmanApp',
filename: 'remoteEntry.js',
exposes: {
'./App': './src/App.tsx'
},
shared: ['react', 'react-dom']
})
- React for the host dashboard
- Svelte for lightweight, reactive components
- Vue.js for progressive enhancement
- React for component reusability
- Remote applications are loaded on-demand
- Graceful fallbacks with loading states
- Error boundaries for failed remote loads
- Beautiful gradient backgrounds
- Responsive grid layouts
- Smooth animations and transitions
- Mobile-friendly design
- Hot module replacement for all frameworks
- Independent development and deployment
- Shared dependencies optimization
- TypeScript support across all apps
Component | Technology | Purpose |
---|---|---|
Host | React + Vite | Main dashboard and orchestration |
Remote 1 | Svelte + Vite | Tic Tac Toe game |
Remote 2 | Vue + Vite | Checker board game |
Remote 3 | React + Vite | Hangman word game |
Federation | @originjs/vite-plugin-federation | Module federation |
Bundler | Vite | Fast development and building |
Styling | CSS3 + Modern Features | Gradients, flexbox, grid |
# Each app runs independently
npm run dev # In each app directory
# Build all applications
cd apps/host-dashboard && npm run build
cd ../tictactoe-svelte && npm run build
cd ../checker-vue && npm run build
cd ../hangman-react && npm run build
- Host Application starts and loads the main dashboard
- Remote Entry Points are fetched from each remote application
- Dynamic Imports load remote components when needed
- Shared Dependencies are deduplicated across applications
- Runtime Integration allows seamless interaction between frameworks
graph TD
A[Host Dashboard - React] --> B[Load Remote Entry]
B --> C[Tic Tac Toe - Svelte]
B --> D[Checker Game - Vue]
B --> E[Hangman - React]
C --> F[Expose ./App]
D --> G[Expose ./App]
E --> H[Expose ./App]
F --> I[Dynamic Import in Host]
G --> I
H --> I
- Classic 3x3 grid gameplay
- Player vs Player mode
- Win detection and game reset
- Lightweight Svelte implementation
- Strategic board game
- Move validation
- Progressive Vue.js architecture
- Reactive state management
- Word guessing game
- Visual hangman drawing
- Letter tracking
- React hooks implementation
-
Remote not loading
- Ensure all remote applications are running
- Check console for CORS errors
- Verify port configurations
-
Module not found errors
- Run
npm install
in each app directory - Check import paths in federation config
- Run
-
Build failures
- Clear node_modules and reinstall
- Check TypeScript configurations
- Verify Vite plugin versions
- Start remotes before the host for best experience
- Use browser dev tools to inspect module federation
- Check network tab for remote entry loading
- Monitor console for federation-specific errors
- Fork the repository
- Create a feature branch
- Make your changes
- Test across all applications
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Built with โค๏ธ using Microfrontend Architecture
Demonstrating the power of framework-agnostic, scalable frontend development