• Stars
    star
    841
  • Rank 54,194 (Top 2 %)
  • Language
    TypeScript
  • License
    Other
  • Created over 6 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Mooa 是一个为 Angular 服务的微前端框架。A independent-deployment micro-frontend Framework for Angular from single-spa.

Mooa

Build Status Coverage Status Maintainability node npm

A single SPA Utils for Angular 2+

Simliar Projects: https://github.com/worktile/ngx-planet (Production Ready)

based on single-spa && single-spa-angular-cli

difference:

  • Host <-> Apps Architecture
  • Configurable App (no loader require)
  • Independent App in Different Repo and runnable

Mooa Architecture

Examples: see in examples/

Online Demo:

  1. http://mooa.pho.im/ (host in AWS S3)
  2. http://mooa.phodal.com/ (host in GitHub Pages)

Features:

  1. SPA by Configurable file, ex: apps.json
  2. Pluggable APP
  3. support Child APP navigate
  4. CLI for Generate Config

Goal:

  1. 构建插件化的 Web 开发平台,满足业务快速变化及分布式多团队并行开发的需求
  2. 构建服务化的中间件,搭建高可用及高复用的前端微服务平台
  3. 支持前端的独立交付及部署

Usecase

If you are mooa, please provide you case to help this project.

Theory

Research and Application of Micro Frontends

Boilerplate

App Boilerplate: https://github.com/phodal/mooa-boilerplate

Usage

1. Install mooa

in Host and Child App

yarn add mooa

2. Config Host

  1. add get Apps logic in AppComponent (app.component.ts)
constructor(private renderer: Renderer2, http: HttpClient, private router: Router) {
  // config Mooa
  this.mooa = new Mooa({
    mode: 'iframe',
    debug: false,
    parentElement: 'app-home',
    urlPrefix: 'app',
    switchMode: 'coexist',
    preload: true,
    includeZone: true
  });
  http.get<IAppOption[]>('/assets/apps.json')
    .subscribe(
      data => {
        this.createApps(data);
      },
      err => console.log(err)
    );
}

private createApps(data: IAppOption[]) {
  data.map((config) => {
    this.mooa.registerApplication(config.name, config, mooaRouter.matchRoute(config.prefix));
  });

  this.router.events.subscribe((event) => {
    if (event instanceof NavigationEnd) {
      this.mooa.reRouter(event);
    }
  });

  return this.mooa.start();
}

3. Config App

  1. config App main.ts for load
import { mooaPlatform } from 'mooa';

if (environment.production) {
  enableProdMode();
}

mooaPlatform.mount('help').then((opts) => {
  platformBrowserDynamic().bootstrapModule(AppModule).then((module) => {
    opts['attachUnmount'](module);
  });
});
  1. setup app routing in app.module.ts
const appRoutes: Routes = [
  {path: '*', component: AppComponent}
  ...
];

@NgModule({
  declarations: [
    AppComponent,
    ...
  ],
  imports: [
    BrowserModule,
    RouterModule.forRoot(
      appRoutes
    )
  ],
  providers: [
    {provide: APP_BASE_HREF, useValue: mooaPlatform.appBase()},
  ],
  bootstrap: [AppComponent]
})
export class AppModule {

}
  1. Add for handle URL Change in app.component.ts
constructor(private router: Router) {
  mooaPlatform.handleRouterUpdate(this.router, 'app1');
}

4. Setup apps.json with Mooa CLI

  1. install global cli
npm install -g mooa
  1. create URL list files

Examples: apps.txt

http://mooa.phodal.com/assets/app1
http://mooa.phodal.com/assets/help
  1. Generate Config File
mooa -g apps.txt

Examples:

[
  {
    "name": "app1",
    "selector": "app-app1",
    "baseScriptUrl": "/assets/app1",
    "styles": [
      "styles.bundle.css"
    ],
    "prefix": "app/app1",
    "scripts": [
      "inline.bundle.js",
      "polyfills.bundle.js",
      "main.bundle.js"
    ]
  }
]

Mooa Config

config in Host app's app.component.ts

this.mooa = new Mooa({
  mode: 'iframe',
  debug: false,
  parentElement: 'app-home',
  urlPrefix: 'app',
  switchMode: 'coexist'
}) 

mode: 'iframe'

use iframe as application container:

<app-home _nghost-c2="">
  <iframe frameborder="" width="100%" height="100%" src="http://localhost:4200/app/help/homeassets/iframe.html" id="help_206547"></iframe>
</app-home>

switchMode: 'coexist'

hidden application when inactive:

<app-home _nghost-c2="">
  <app-app1 _nghost-c0="" ng-version="5.2.8" style="display: none;"><nav _ngcontent-c0="" class="navbar"></app-app1>
  <iframe frameborder="" width="100%" height="100%" src="http://localhost:4200/app/help/homeassets/iframe.html" id="help_206547"></iframe>
</app-home>

For Angular Lazyload Module

inline.bundle.js will load script for / path.

So, just copy *.chunk.js files to dist/, then deploy it.

API

registerApplicationByLink

exmples:

mooa.registerApplicationByLink('help', '/assets/help', mooaRouter.matchRoute('help'));

registerApplication

mooa.registerApplication(config.name, config, mooaRouter.matchRoute(config.prefix));

hybrid

if (config.sourceType) {
  that.mooa.registerApplicationByLink(config.name, config.link, mooaRouter.matchRoute(config.name));
} else {
  that.mooa.registerApplication(config.name, config, mooaRouter.matchRoute(config.prefix));
}

navigateTo Custom App

mooaPlatform.navigateTo({
  appName: 'help',
  router: 'home'
});

License

Phodal's Idea

Copyright (c) 2013-2014 Christopher Simpkins Copyright (c) 2017-2018 Robin Coma Delperier

© 2018 A Phodal Huang's Idea. This code is distributed under the MIT license. See LICENSE in this directory.

More Repositories

1

github

GitHub 漫游指南- a Chinese ebook on how to build a good project on Github. Explore the users' behavior. Find some thing interest.
Rich Text Format
9,132
star
2

growth-ebook

Growth Engineering: The Definitive Guide。全栈增长工程师指南
HTML
7,688
star
3

awesome-iot

Awesome IoT. A collaborative list of great resources about IoT Framework, Library, OS, Platform
Python
4,042
star
4

ideabook

一个全栈增长工程师的练手项目集. A Growth Engineering Idea in Action.
HTML
3,729
star
5

migration

《系统重构与迁移指南》手把手教你分析、评估现有系统、制定重构策略、探索可行重构方案、搭建测试防护网、进行系统架构重构、服务架构重构、模块重构、代码重构、数据库重构、重构后的架构守护
Java
3,232
star
6

microfrontends

Micro-frontend Architecture in Action-微前端的那些事儿
3,012
star
7

prompt-patterns

Prompt 编写模式:如何将思维框架赋予机器,以设计模式的形式来思考 prompt
2,810
star
8

growth-in-action

全栈增长工程师实战
HTML
2,492
star
9

designiot

教你设计物联网系统。构建自己的Internet of Things 。
HTML
2,192
star
10

growth-ionic

[v2.0 DEPRECATED, please update to Growth 3.0] Growth - App to help you Be Awesome Developer & Awesome Hacker
TypeScript
2,158
star
11

ledge

Ledge —— DevOps knowledge learning platform. DevOps、研发效能知识和工具平台,是我们基于在 ThoughtWorks 进行的一系列 DevOps 实践、敏捷实践、软件开发与测试、精益实践提炼出来的知识体系。它包含了各种最佳实践、操作手册、原则与模式、度量、工具,用于帮助您的企业在数字化时代更好地前进,还有 DevOps 转型。
TypeScript
2,142
star
12

fe

《我的职业是前端工程师》 - Ebook:I'm a FrontEnd Developer
HTML
2,004
star
13

serverless

Serverless 架构应用开发指南 - Serverless Architecture Application Development Guide with Serverless Framework.
HTML
1,729
star
14

developer

developer roadmap. use growth https://github.com/phodal/growth replace this
Makefile
1,712
star
15

aigc

《构筑大语言模型应用:应用开发与架构设计》一本关于 LLM 在真实世界应用的开源电子书,介绍了大语言模型的基础知识和应用,以及如何构建自己的模型。其中包括Prompt的编写、开发和管理,探索最好的大语言模型能带来什么,以及LLM应用开发的模式和架构设计。
Rust
1,354
star
16

growth

Growth 3.0 with React Native - an app to help you to be Awesome Developer
JavaScript
1,231
star
17

iot

IoT, 这是一个最小Internet of Things ,一个Internet of Things相关的毕业设计产生的一个简化的物联网系统。 。
Python
1,129
star
18

booktree

A Book Tree
JavaScript
1,044
star
19

skilltree

Web Developer 技能树
JavaScript
952
star
20

ideas

Ideas of Phodal
940
star
21

articles

Article Publish in Wechat & Toutiao
Makefile
911
star
22

toolbox

Phodal's Toolbox
HTML
906
star
23

coca

Coca is a toolbox which is design for legacy system refactoring and analysis, includes call graph, concept analysis, api tree, design patterns suggest. Coca 是一个用于系统重构、系统迁移和系统分析的工具箱。它可以分析代码中的测试坏味道、模块化分析、行数统计、分析调用与依赖、Git 分析以及自动化重构等。
Go
881
star
24

clean-frontend

Clean Frontend Architecture:整洁前端架构
TypeScript
805
star
25

tangping

躺平即正义。Nothing is true, everything is permitted
708
star
26

repractise

RePractise
HTML
699
star
27

sherlock

Skill Tree Sherlock
JavaScript
675
star
28

lan

Internet of Things Server Layer with CoAP, WebSocket, MQTT, HTTP Protocol.
JavaScript
559
star
29

eks

嵌入式知识总汇 Embedded Knowledge Structure
552
star
30

weapp-quick

微信小应用示例代码
JavaScript
474
star
31

ebook-boilerplate

A Markdown convert to Ebook ➡️ html、mobi、epub、pdf、rtf Template
CSS
426
star
32

quake

Quake is a knowledge management meta-framework for geeks. Use meta-data + Transflow to CRUD data, Git + markdown to management content, Web Component for frontend-custom. Quake 是面向极客的知识管理元框架。
Rust
423
star
33

growth-roadmap

Growth APP' Project, Links, Blogs, Books, Resources
CSS
407
star
34

aofe.code

《前端架构:从入门到微前端》源码,code for Architecture of Frontend
JavaScript
370
star
35

new-project-checklist

🥳🥳🥳🥳 a checklist & tool for new project setup for developer. 新项目检查清单及其工具。
JavaScript
347
star
36

awesome-iot-document

Awesome IoT Documents. [Deprecated] Internet of Things Document
340
star
37

phodit

Phodal's markdown/ebook editor with MicroFrontend & Web Components
TypeScript
330
star
38

oculus-nodejs-threejs-example

Oculus + Node.js + Three.js 打造VR世界
JavaScript
296
star
39

lowcode

Low-code platform design rule
275
star
40

weapp-webdemo

A Hack of Weapp Framework
JavaScript
268
star
41

dx-book

《开发者体验:探索与重塑》电子书。book of research and refactoring in developer experience (WIP)
SCSS
259
star
42

evolution

Growth:增长工程师修炼之道——读书、写作、编程
HTML
244
star
43

licenses

OpenSource License Explains
HTML
243
star
44

adr

Architecture Decision Records in Node.js with Reporter, supported Windows, GNU/Linux, macOS - 轻量级架构决策记录工具
TypeScript
240
star
45

cloud-dev

云研发,是一种生于云上的闭环 + 代码化的软件开发方式。它可以让业务人员、开发人员、运营人员等在同一个云端共同协作、透明化地完成整个软件的生命周期(需求、设计、编码、构建、部署、运营),而非相互隔离,又或者是借助于多个软件才能完成工作。
225
star
46

mole

Mole - based-git cloud note | 墨乐 - GitHub上的云笔记
JavaScript
222
star
47

techlead

Tech Lead Toolbox
TypeScript
197
star
48

make

📖📖📖📖📖 写给软件工程师看的硬件编程指南
HTML
193
star
49

fde

前端体系规划指南。Architecture of Frontend Development Efficiency
192
star
50

vmap

location:china, GitHub most popular Chinese user in Map
JavaScript
185
star
51

md

A Markdown Editor for Wechat Media Platform
JavaScript
183
star
52

aofe.images

《前端架构:从入门到微前端》原图,image for Architecture of Frontend
161
star
53

smart-home

Phodal's Smart Home Setup Guide:HomeBridge + Home Assistant + Amazon Echo
C++
152
star
54

2md

A Converter for Copy/Paste content to Markdown
JavaScript
151
star
55

trusted

10 factor to build trusted system - 构建可信系统的 10 元素
138
star
56

diaonan

MQTT协议,CoAP协议,WebSocket,物联网协议测试平台
CSS
137
star
57

frontend

《大前端:前端的扩张》
HTML
137
star
58

mifa

Mifa Design
CSS
134
star
59

wecode

A Serverless Gist Application in WeChat. 微信群里的代码协作小程序
JavaScript
125
star
60

lettuce

Mobile Framework for Romantic. 简约的移动开发框架
JavaScript
124
star
61

iot-coap

IoT Learning with CoAP Protocol
JavaScript
121
star
62

awesome-iot-projects

Awesome IoT Projects. A collaborative list of great resources about IoT Demos
112
star
63

setup.guide

前端程序员的 macOS 搭建指南
111
star
64

echoesworks

Next-Generation Tech Blog/Presentation/Slider Framework
JavaScript
109
star
65

water

Water 是开源的下一代软件架构模式,专为云研发/云开发时代设计的软件架构。由实时开发环境 + 云编译、云转译、编程语言数据库等核心要素构建的新一代软件架构模式。
98
star
66

brand

Design for Fun
Python
97
star
67

winv

A mini compatible MINA for web
CSS
91
star
68

growth-in-30-minutes

A Introduction for Growth Paper in Minutes - 真实世界的全栈工程师的十八项必备技能
91
star
69

moqi.mobi

开源移动CMS框架——墨颀移动CMS
JavaScript
86
star
70

javascript-refactor

前端工程师技能训练之重构
JavaScript
82
star
71

ascode.ink

Everything as code architecture design patten and rules。本系列文章是根据《云研发:研发即代码》一文编写的具体实现,将文档、需求、设计、代码、构建、部署、运营变成代码化。
82
star
72

phodaldev

person website
JavaScript
75
star
73

valentine

程序员情人节礼物示例, Valentine's Day Example
JavaScript
75
star
74

layer-architecture

DDD & Clean Architecture in Java, JavaScript, TypeScript, Python, Golang, Cpp
Java
70
star
75

congee

A Web Editor design for Baimizhou
JavaScript
68
star
76

stepping

Stepping - a tools for code design, event storming, domain model generate.
TypeScript
66
star
77

fed

Ebook of Frontend.《我的职业是前端工程师》姐妹篇《前端进阶指南》
HTML
61
star
78

daily

日常练习
CSS
61
star
79

moform

A Serverlesss form builder
JavaScript
58
star
80

dore

React Native-base Hybrid Framework, for migrating Cordova and WebView application to React Native.
JavaScript
55
star
81

growth-code

The Source Code of Growth Paper - 《全栈应用开发:精益实践》源码
Python
55
star
82

summary

Awesome articles, tools, OS project, design of Phodal - collections in path of Phodal's way for new geek & nerd to quick growth
51
star
83

skillwheel

A Skill List for Web Developer
CSS
51
star
84

dou2

一份面向残疾地区的,简单的无障碍上网指南
50
star
85

ionic-elasticsearch

Django ElasticSearch Ionic 打造 GIS 移动应用
JavaScript
49
star
86

awesome-practise-project

Awesome Practise Project
JavaScript
47
star
87

backbone-react

Backbone React in Practice
JavaScript
47
star
88

oan

Another Web Components Framework . A Spike of Web Components Design
TypeScript
45
star
89

mopass

A OpenSource Clientless & Serverless Password Manager
JavaScript
42
star
90

designiot-app

Internet of Things APP
JavaScript
42
star
91

django-elasticsearch

Django ElasticSearch Ionic 打造 GIS 移动应用
JavaScript
41
star
92

awesome-smart-speaker

A Awesome List for Smart Speaker(智能音箱)
41
star
93

growth-in-action-code

Growth In Action Django Code
Python
40
star
94

componentless

Componentless is a architecture pattern which is means component as a services. 无组件(Componentless)架构是一种架构模式,它是指大量依赖于三方组件(运行时依赖的组件而非编译时依赖的组件,即编译即服务)或暂存容器中运行的自定义代码的前端应用。
39
star
95

romantic

待我代码编成,娶你为妻可好
JavaScript
38
star
96

thesis

TeX
36
star
97

design

Design as Code, a DSL for UX & backend modeling. DSL to Sketch file, Sketch to DSL, DSL to code.
Go
36
star
98

designiot-code

Source Code of Design IoT
JavaScript
31
star
99

mooa-boilerplate

microfrontends framewrok mooa's boilerplate.前端微服务化框架 Mooa 脚手架示例
TypeScript
30
star
100

mest

契约测试框架。A TypeScript Contract Test for Interface base project.
TypeScript
29
star