A production-ready monorepo boilerplate for building scalable microfrontend applications, powered by modern web technologies and best practices. Built entirely from scratch without using any cli tools, providing complete control over the build configuration and development workflow.
- 🎯 Overview
- ✨ Key Features
- ⚙️ Technology Stack
- 📁 Project Structure
- 🚀 Getting Started
- 🛠 Development Tools
- 🏗 Architecture
- 🔒 Security
- 📦 Deployment
- 🤝 Contributing
- 📄 License
This monorepo provides a complete foundation for building scalable microfrontend applications. It solves several key challenges in modern web development:
- 🏢 Microfrontend Architecture: Implement independent, deployable frontend applications that work together seamlessly
- 🔄 Code Sharing: Share components and logic between applications efficiently using Webpack 5 Module Federation
- 📝 Type Safety: Full TypeScript support across all applications and packages
- ⚡️ Development Workflow: Streamlined development experience with hot reloading and custom CLI tools
- 🛡️ Security: Built-in protection for remote module access
- 📈 Scalability: Monorepo structure that scales with your team and application needs
- 🎛️ Full Configuration Control: Custom webpack configuration built from ground up, offering maximum flexibility
- ⚡️ Webpack 5 Module Federation for component sharing
- 🔒 Secure Express middleware for remote module access
- 🔄 Hot Module Replacement (HMR) support
- 📦 Optimized production builds
- 🎨 CSS/SCSS Modules support
- 🧪 Testing setup with Jest
- 🎯 Built From Scratch: No black-box configurations from Create React App or Vite
- ⚙️ Custom Webpack Setup: Full control over build process and optimizations
- 🔧 Extensible Configuration: Easy to add new features and customize build behavior
- 📦 Optimized Bundling: Fine-tuned webpack configuration for optimal performance
- 🔄 Hot Reload: Custom-configured development server with HMR
- 🎨 Asset Handling: Customized loaders for various file types
- 🚀 Performance Optimizations:
- Code splitting
- Tree shaking
- Chunk optimization
- Dynamic imports
- Module federation
- Cache optimization
- 🛠 Custom dev-cli tool for workflow automation
- 📝 Comprehensive TypeScript support
- 🧹 Unified code formatting and linting
- ⚙️ Shared configurations for all tools
- 📚 Component library setup
- 🔧 Core: React 18, TypeScript, Webpack 5
- 🎨 Styling: CSS Modules, SCSS
- 📦 Monorepo: pnpm Workspaces, Lerna
- ✨ Quality: ESLint, Prettier, Jest
- 🛠 Development: Custom CLI, Hot Module Replacement
- 🏗 Build: SWC, Webpack optimizations
// Example of the flexible webpack configuration
module.exports = {
// Core build optimization
optimization: {
splitChunks: {
chunks: 'all',
// Customizable chunking strategy
},
runtimeChunk: 'single',
},
// Module Federation for micro-frontends
plugins: [
new ModuleFederationPlugin({
// Customizable sharing strategy
shared: {
react: { singleton: true },
'react-dom': { singleton: true },
},
}),
],
// Extensible loader configuration
module: {
rules: [
// TypeScript/JavaScript processing with SWC
// CSS/SCSS handling
// Asset optimization
// Custom loader configurations
],
},
};
├── apps/ # Microfrontend applications
│ ├── host/ # Host application
│ └── remote/ # Remote application
├── packages/ # Shared packages
│ ├── dev-cli/ # Development workflow tools
│ ├── ui/ # Shared UI components
│ ├── utils/ # Common utilities
│ └── configs/ # Shared configurations
├── scripts/ # Build and utility scripts
└── package.json # Root package file
├── webpack/
│ ├── common.js # Shared webpack configuration
│ ├── development.js # Development-specific settings
│ ├── production.js # Production optimizations
│ └── module-fed.js # Module Federation setup
This project uses SWC (Speedy Web Compiler) instead of Babel for faster compilation:
- 🚀 Performance: Up to 20x faster than Babel
- 🔄 Modern Syntax: Full support for latest JavaScript and TypeScript features
- 🛠 Optimized Build: Native compilation for better performance
- ⚡️ Hot Reload: Fast refresh during development
- 📦 Production Ready: Minification and optimization support
// Example SWC configuration
{
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": true
},
"transform": {
"react": {
"runtime": "automatic"
}
},
"target": "es2020"
}
}
- Node.js >= 18
- pnpm >= 9.0.0
# Clone the repository
git clone https://github.com/your-username/ts-microfrontend-monorepo-kit.git
# Install dependencies
pnpm install
# Start development
pnpm dev
pnpm dev
: Start all applications in development modepnpm start:host
: Start host applicationpnpm start:remote
: Start remote applicationpnpm build
: Build all applicationspnpm lint
: Run lintingpnpm format
: Format code
Custom CLI tool that provides:
- 🔄 Workflow automation
- 🖥️ Development server management
- ⚡️ Build process optimization
- 🏗 Project scaffolding
Usage:
# Create a new component
dev-cli generate component
# Run development servers
dev-cli serve
- 📝 TypeScript configurations
- 🧹 ESLint rules
- 🔧 Webpack configurations
- 🛠 SWC configuration
- 🧪 Jest setup
-
Host Application: Main application shell
- 🧭 Manages routing
- 🔐 Handles authentication
- 🎮 Orchestrates remote modules
-
Remote Applications: Independent features
- 📦 Expose components via Module Federation
- 🚀 Can be deployed independently
- 💾 Maintain their own state and routing
- 📥 Dynamic loading of remote modules
- 🔄 Shared dependencies management
- ⚡️ Runtime integration of components
- 📈 Version control of shared modules
- ✅ Origin validation middleware
- 🔐 Configurable access controls
- 🌐 CORS protection
- ⚡️ Rate limiting support
- 🔐 Secure module loading
- 🛡️ Protected development endpoints
- ⚙️ Environment-based configurations
- 🔄 Error boundary implementation
# Production build
pnpm build
# Environment-specific builds
NODE_ENV=staging pnpm build
- 📦 Optimized bundles
- 🗺️ Source maps
- 🎨 Asset optimization
- ⚡️ Cache management
Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE.md file for details.
For questions and support, please open an issue in the GitHub repository.
⭐️ If you find this project helpful, please give it a star!