micro-app
A simple, efficient and powerful micro front-end framework. 一款简约、高效、功能强大的微前端框架
Top Related Projects
📦 🚀 Blazing fast, simple and complete solution for micro frontends.
Dynamic ES module loader
Implementation examples of module federation , by the creators of module federation
EMP Micro FE Base on Rspack & module federation
Quick Overview
Micro-app is a lightweight, efficient micro-frontend framework for building large-scale web applications. It allows developers to break down complex applications into smaller, more manageable pieces that can be developed, tested, and deployed independently.
Pros
- Easy integration with existing projects, supporting various frameworks like React, Vue, and Angular
- Efficient performance with low overhead and small bundle size
- Supports both pre-rendering and dynamic loading of micro-applications
- Provides a sandbox environment for each micro-app, enhancing security and isolation
Cons
- Limited documentation in English, which may be challenging for non-Chinese speakers
- Relatively new project, which might lack extensive community support compared to more established solutions
- May require additional setup and configuration for complex scenarios
- Learning curve for developers new to micro-frontend architecture
Code Examples
- Basic usage of micro-app:
import microApp from '@micro-zoe/micro-app'
microApp.start()
// In your HTML
<micro-app name="app1" url="http://localhost:3000/app1/" baseroute="/my-page"></micro-app>
- Passing data to a micro-app:
<micro-app
name="app1"
url="http://localhost:3000/app1/"
:data="{ message: 'Hello from main app' }"
></micro-app>
// In the micro-app
window.microApp.getData() // { message: 'Hello from main app' }
- Listening for micro-app lifecycle events:
microApp.addDataListener(data => {
console.log('Data from micro-app:', data)
}, 'app1')
microApp.addGlobalDataListener(data => {
console.log('Global data:', data)
})
Getting Started
-
Install micro-app:
npm install @micro-zoe/micro-app
-
Import and initialize in your main application:
import microApp from '@micro-zoe/micro-app' microApp.start()
-
Add a micro-app to your HTML:
<micro-app name="app1" url="http://localhost:3000/app1/"></micro-app>
-
Configure your micro-app to expose itself:
// In your micro-app's entry file if (window.__MICRO_APP_ENVIRONMENT__) { // Running in micro-app environment __webpack_public_path__ = window.__MICRO_APP_PUBLIC_PATH__ }
Competitor Comparisons
📦 🚀 Blazing fast, simple and complete solution for micro frontends.
Pros of qiankun
- More mature and widely adopted, with a larger community and ecosystem
- Supports multiple frameworks (React, Vue, Angular) out of the box
- Provides built-in sandbox isolation for better security and stability
Cons of qiankun
- Heavier implementation and potentially more complex setup
- May have performance overhead due to its comprehensive features
- Less flexible for custom configurations and edge cases
Code Comparison
micro-app:
import microApp from '@micro-zoe/micro-app'
microApp.start()
<micro-app name="app1" url="http://localhost:3000/"></micro-app>
qiankun:
import { registerMicroApps, start } from 'qiankun';
registerMicroApps([
{ name: 'app1', entry: '//localhost:3000', container: '#container', activeRule: '/app1' },
]);
start();
Both micro-app and qiankun are micro-frontend solutions, but they differ in their approach and features. micro-app focuses on simplicity and ease of use, with a web components-based implementation. It offers a lighter setup and potentially better performance for simpler use cases. However, it may lack some advanced features and cross-framework support compared to qiankun.
qiankun, on the other hand, provides a more comprehensive solution with built-in support for multiple frameworks and advanced features like sandbox isolation. It's better suited for complex applications with diverse technology stacks but may require more setup and configuration.
Dynamic ES module loader
Pros of SystemJS
- More mature and widely adopted, with a larger community and ecosystem
- Supports loading various module formats (CommonJS, AMD, UMD) in addition to ES modules
- Offers more flexibility in module loading and configuration options
Cons of SystemJS
- Steeper learning curve due to its extensive features and configuration options
- Larger bundle size compared to micro-app, which may impact initial load times
- Requires more setup and configuration for basic use cases
Code Comparison
micro-app:
import microApp from '@micro-zoe/micro-app'
microApp.start()
<micro-app name="app1" url="http://localhost:3000/"></micro-app>
SystemJS:
import { importMap } from 'systemjs'
System.config({
map: { 'app1': 'http://localhost:3000/main.js' }
})
System.import('app1')
Key Differences
- micro-app focuses specifically on micro-frontends, while SystemJS is a more general-purpose module loader
- micro-app uses a custom HTML element for embedding applications, whereas SystemJS relies on JavaScript API calls
- SystemJS offers more advanced module loading capabilities, while micro-app provides a simpler, more opinionated approach to micro-frontend architecture
Both libraries serve different purposes and cater to different use cases, with micro-app being more specialized for micro-frontend implementations and SystemJS offering broader module loading capabilities.
Implementation examples of module federation , by the creators of module federation
Pros of module-federation-examples
- Provides a wide range of examples for different Module Federation use cases
- Demonstrates integration with various frameworks and build tools
- Offers more flexibility in terms of runtime dependencies and shared modules
Cons of module-federation-examples
- Steeper learning curve due to its more complex architecture
- Requires more configuration and setup compared to micro-app
- May introduce additional bundle size overhead for smaller applications
Code Comparison
micro-app:
import microApp from '@micro-zoe/micro-app'
microApp.start()
<micro-app name="app1" url="http://localhost:3000/app1/"></micro-app>
module-federation-examples:
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');
module.exports = {
plugins: [
new ModuleFederationPlugin({
name: 'app1',
filename: 'remoteEntry.js',
exposes: {
'./App': './src/App',
},
shared: ['react', 'react-dom'],
}),
new HtmlWebpackPlugin({
template: './public/index.html',
}),
],
};
EMP Micro FE Base on Rspack & module federation
Pros of emp
- More flexible architecture, supporting multiple micro-frontend implementation methods
- Better TypeScript support and type definitions
- More active community with frequent updates and contributions
Cons of emp
- Steeper learning curve due to more complex configuration options
- Less focus on simplicity compared to micro-app
- May require more setup time for basic use cases
Code Comparison
micro-app:
import microApp from '@micro-zoe/micro-app'
microApp.start()
<micro-app name="app1" url="http://localhost:3000/app1/"></micro-app>
emp:
import { createMicroApp } from '@efox/emp'
const app = createMicroApp({
name: 'app1',
entry: 'http://localhost:3000/app1/',
})
app.mount('#app-container')
Both micro-app and emp are micro-frontend frameworks, but they differ in their approach and features. micro-app focuses on simplicity and ease of use, making it a good choice for projects that need a straightforward micro-frontend solution. emp, on the other hand, offers more flexibility and advanced features, making it suitable for complex applications that require fine-grained control over the micro-frontend architecture.
emp's TypeScript support and active community can be advantageous for larger teams or projects with strict type requirements. However, its increased complexity may lead to a longer setup time and a steeper learning curve compared to micro-app.
When choosing between the two, consider your project's specific needs, team expertise, and desired level of control over the micro-frontend implementation.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Englishï½ç®ä½ä¸æ
To facilitate unified management of open-source projects, we need to migrate Micro-app to jd.
New official website address:https://jd-opensource.github.io/micro-app/
New GitHub address:https://github.com/jd-opensource/micro-app
Top Related Projects
📦 🚀 Blazing fast, simple and complete solution for micro frontends.
Dynamic ES module loader
Implementation examples of module federation , by the creators of module federation
EMP Micro FE Base on Rspack & module federation
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot