-
随着业务的发展,微前端需求越来越复杂,仅仅提供隔离性的微前端框架不再满足业务需求,微前端需要一种
业务协作 + 隔离
的方案。 -
随着业务的发展,每个业务团队可能都需要拥有自己特性的微前端框架,可以自己研发,也可以基于已有的微前端框架修改,一种可以批量生产自己特性的微前端框架的引擎亟待提出。
- 多框架兼容
- 独立部署
- 懒加载
- 应用嵌套,单主应用
- 强大的插件能力
- 扩展能力
- 微前端引擎
- 沙箱,自定义沙箱
- 自定义应用匹配
- html 入口
微前端框架,微前端解决方案
License: MIT License
随着业务的发展,微前端需求越来越复杂,仅仅提供隔离性的微前端框架不再满足业务需求,微前端需要一种 业务协作 + 隔离
的方案。
随着业务的发展,每个业务团队可能都需要拥有自己特性的微前端框架,可以自己研发,也可以基于已有的微前端框架修改,一种可以批量生产自己特性的微前端框架的引擎亟待提出。
考虑这个一个问题,主应用使用 versea,目前接入两个子应用 A 和 B,假设 A 应用可以嵌套 B。
const routes = [{
path: 'a',
apps: [A],
children: [{
path: 'a1',
apps: [A],
}, {
path: 'b',
apps: [B],
}],
}]
const routes = [{
path: 'a',
component: Index,
children: [{
path: 'a1',
component: ComponentA,
}, {
path: 'b',
component: () => import('ComponentB'),
}],
}]
<template>
<div>ComponentA</div>
</template>
<template>
<div>ComponentB</div>
<!-- 用于嵌套 B 应用 -->
<div id="inner_slot"></div>
</template>
复线步骤:
因此这里存在两个问题:
我们拦截了 popstate 事件,可是此时无法 mount B,需要应用 A 先完成 vue-router 路由匹配逻辑,然后渲染出 ComponentB,才会展示<div id="inner_slot"></div>
在页面上,有了id 是 inner_slot 的 div 才能交给 versea mount B 应用。
并不是每个方法都可以添加超时设置,有些方法执行已经产生了副作用,而这些副作用在超时之后无法被销毁,因此不可以设置超时。
是否需要支持 redirect,如果需要支持,理由是什么,有什么场景?如果不需要,路由是什么?
除了 versea/core,还有一层 versea/versea 的封装
用于让不理解 inversify 的开发人员使用,不需要理解 inversify 的各种概念就能使用 versea
class Versea {
constructor() {
this.container = new Container({ defaultScope: 'Singleton' });
this.container.load(buildProviderModule());
}
registerApp(options: AppOptions) {
this.container.get(IAppService).registerApp(options);
}
}
插件独立于 versea/core,也就是不依赖 versea/core 的依赖注入能力,依赖 versea/versea 的 Versea 类
class Versea {
use(plugin: Plugin) {
plugin.apply(this);
}
}
插件写法如下:
class MyPlugin {
constructor(options) {
this.options = options;
}
apply(context) {
context.container.get(IHooks).registerApp.tap('my-plugin', (hookParams) => {
console.log(hookParams);
});
}
}
插件独立于 versea/core,不依赖 versea/versea 的 Versea 类,但依赖 versea/core 的依赖注入能力。
class Versea {
use(pluginKey) {
this.container.get(pluginKey).apply(this)
}
}
插件写法如下:
@provide(IMyPlugin)
class MyPlugin {
constructor(@inject(IHooks) hooks) {
this._hooks = hooks;
}
apply(context) {
this._hooks.registerApp.tap('my-plugin', (hookParams) => {
console.log(hookParams);
});
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.