
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@ucloud-fe/rapiop
Advanced tools
A simple micro frontend library
当公司有数十、甚至上百的前端项目,终于由于难以管理维护,想要统一管理的时候,最先能想到的大概是将所有的项目再统一的平台上全部重构,然而这必然会消耗大量的人力,甚至做到一半后因为各种高优先级任务而不了了之。
RAPIOP 出现的初心就是,让任意技术栈的前端项目(目前只支持 SPA 项目,多页应用后续计划支持),只需通过简单的改动(10 分钟 - 30 分钟),便可以无痛的和其它项目共存,大大减少前期的重构人力。在所有项目介入后,便可以方便的对项目进行无痛迭代更新,直至统一化。
最近一两年微前端的概念兴起,RAPIOP 能够很好的承载各种微前端设计。
新建一个前端项目作为所有项目的容器,也可选择一个已有项目
项目中安装 rapiop
yarn add @ucloud-fe/rapiop
参考examples/basic/index.ts,创建一个新的实例。
import rapiop from "@ucloud-fe/rapiop";
import { createBrowserHistory } from "history";
// 路由可自定义,或通过其它方式实现,非必要
const history = createBrowserHistory();
const app = rapiop({
// 产品配置,支持函数、异步函数
config: {
demo: {
prefix: "/demo/"
},
"demo-2": {
prefix: "/demo-2/"
}
},
// 项目的挂载点,异步可使用 FramePlugin,或使用 hooks
mountDOM: document.getElementById("mount-dom"),
// 自定义路由
history
});
config为必要参数
注册各个子项目
app.register(
"home",
(mountDOM: Element) => {
const content = document.createElement("div");
content.innerText = "this is my home";
mountDOM.appendChild(content);
console.log("home mounted");
},
(mountDOM: Element) => {
mountDOM.innerHTML = null;
console.log("home unmounted");
}
);
app.register(
"demo",
(mountDOM: Element) => {
const content = document.createElement("div");
content.innerText = "this is my demo";
mountDOM.appendChild(content);
console.log("demo mounted");
},
(mountDOM: Element) => {
mountDOM.innerHTML = null;
console.log("demo unmounted");
}
);
app.register(
"demo-2",
(mountDOM: Element) => {
const content = document.createElement("div");
content.innerText = "this is my demo-2";
mountDOM.appendChild(content);
console.log("demo-2 mounted");
},
(mountDOM: Element) => {
mountDOM.innerHTML = null;
console.log("demo-2 unmounted");
}
);
home为默认页面 key,若 config 中无可匹配路由的项目,则渲染该页面,可使用option.fallbackProjectKey来自定义
启动后项目根据 config 中的 url 规则匹配的地址进入对应项目
config 中传入 files,可支持在路由切换时自动加载文件然后执行挂载,可参考 examples/advance
等待施工 👷👷
FAQs
Run all project in one place/project
The npm package @ucloud-fe/rapiop receives a total of 3 weekly downloads. As such, @ucloud-fe/rapiop popularity was classified as not popular.
We found that @ucloud-fe/rapiop demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.