hot-chocolate

hot-chocolate 是一个浏览器端运行的微前端沙箱框架,支持零修改运行现有代码,基于 Proxy + Shadow Dom 实现,适用于 React、Vue 等多种框架项目。

Check out hot-chocolate on CurateClick

• Copy the embed code to showcase this product on your website

• Share on X to spread the word about this amazing tool

项目地址https://github.com/NeteaseLofter/hot-chocolate### 项目描述hot-chocolate 是浏览器端运行的沙箱框架。可以广泛的运用于微前端系统中,帮助大家在一些巨石的项目中完成新老版本切换和共存。其目标是零修改即可运行现有代码,目前已经正常的运行react、vue等多种不同框架的项目,其是对原生js上的修改,对框架本身并无要求。基于Proxy + Shadow Dom 实现。实现了较好的隔离效果,理论上能同时支持多个应用同时运行。#### 特性有哪些?何为零修改即可运行?1. 无生命周期:应用代码无生命周期,不需要设置挂载、卸载操作,让hot-chocolate帮你完成。1. 打包配置无修改:可以直接用create-react-appvue-cli生成项目,也可以自定义webpack配置。也支持非webpack项目,只要你生产的html和js、css 是正确的、可访问的。当然使用umi也可以,且无需额外修改配置,我们现在不少也是用umi的开发的后台。1. 支持动态引入js、css,你的webpack可以按需拆分模块了,动态创建的script、style、link标签都将被正确的使用,同时支持使用icon-font等css字体图标。1. 推荐使用htmlRemote: 'http://abc.com/index.html的方式,直接设置html的地址,剩下的交给hot-chocolate。更多沙箱参数可以点击这里#### 易于扩展的插件体系hot-chocolate 提供了一套插件体系。其开发目的是为了使用者可以对沙箱中运行环境进行自定义。使用插件可以实现对沙箱内的进行ajax、localStorage等行为,进行监控、代理、重写等操作。也可以基于插件完成跨沙箱间通信。开发自定义插件可以看这里。目前已提供了沙箱从启动到运行到销毁,各个阶段多个事件,基本可以满足大部分自定义需求。如果有想法可以提issue,我们进行补充。### demodemo更多demo: https://github.com/NeteaseLofter/hot-chocolate/tree/master/examples### 未来计划及一些注意事项hot-chocolate 这样实现其实并不太轻巧。其追求的是沙箱中代码的 零修改。所以重度使用了Proxy和Shadow Dom,在一些兼容性要求不高的后台应用中更能获得较好的体验。现在的迭代计划主要再以下方面:- 可能会实现更兼容性的版本,但同时会牺牲一些隔离效果。如果使用兼容性版本,这会需要使用者对项目有更好了解和规范。- 更多插件的支持,比如单页面history的适配,其他如果有想法可以提issue,我们进行补充。- 沙箱的上层封装 -- 完整的微前端。hot-chocolate专注于沙箱。微前端的功能,包括路由切换、应用资源自动发放,我们考虑在上层提供全新的包去完整。这样hot-chocolate可以有更好的使用空间。同时作者感觉,微前端是个比较复杂的设计,我们使用需要对当前项目有充分的评估。如果你需要整合技术栈,可以使用。如果没有明确的需求,则可以了解但放缓。

Latest Weekly Picks

make.ink favicon
Weekly Pick

Your AI tattoo generator for pro-grade concepts

Leo Wade
sellfy.com favicon
Weekly Pick

A code-free online store builder to turn views into revenue. Sell digital products, subscriptions, and merch, without fees or hassle.

Maris
www.videotoblog.ai favicon
Weekly Pick

Convert videos into awesome blog posts.

Video To Blog
www.sellerpic.ai favicon
Weekly Pick

SellerPic is the all-in-one AI design platform for e-commerce

SellerPic
fastimage.ai favicon
Weekly Pick

Fast Image AI instantly transforms your photos into stunning styles like Ghibli, Sketch, and Pixar. Effortlessly control image elements and create amazing effects with just one click.

Fast AI Team
linkedinpro.daisy.so favicon
Weekly Pick

AI-powered tool that transforms casual photos into professional LinkedIn headshots instantly. No photographer needed—just upload and download.

Gabriel
crevas.ai favicon
Weekly Pick

Crevas unifies Veo 3, Sora 2, Nano Banana and more into one intuitive canvas — so filmmakers can script, prompt, and generate cinematic stories without switching tools or losing consistency.

Spark Alpha
fotominiatur.com favicon
Weekly Pick

AI Foto Edit - Text to Image & Image Edit

foto miniatur