Comments (3)
目前微前端大家的思路都是在项目入口导出几个方法用来挂载 & 卸载子应用。 但是实现思路各自各有不同
飞冰的思路是把子应用导出的方法,直接挂载到 window 的 变量里面,然后去使用子应用的导出的生命周期函数。然后如果想使用沙箱,必须通过 xhr 把脚本请求回来然后再去 new Function 的执行
在 Alfa 中 有 CONSOLE_OS_GLOBAL_HOOK,_CONSOLE_OS_GLOBAL_VARS 这几个变量是为了通过在沙箱开启的情况下还能以 script 的方式加载子应用,并且通过类似 amd 的方式 通过模块系统获取函数的导出。
在我们实践中发现 xhr + new Function 十分损耗内存,对在应用变多的情况下体验十分糟糕。我们这样的好处是,script 加载天然是被浏览器优化的,所以性能上肯定没有问题
对于代码复杂度高的原因是我们在里面提供了非常多的高级特性比如:
from alibabacloud-alfa.
CONSOLE_OS_GLOBAL_HOOK
_CONSOLE_OS_GLOBAL_VARS
……等
这些全局变量似乎还增加了维护的复杂程度
from alibabacloud-alfa.
@Boelroy 那在兼容性方面呢,目前在官档没找到对应说明,尝试了下demo是无法运行的,已经做了polyfill
from alibabacloud-alfa.
Related Issues (20)
- 子应用在本地开发时,无法热更新,如何解决
- vue子应用如何接受props? HOT 1
- demo中的React子应用出错
- React子项目中用到jQuery HOT 2
- 打正式包 需要Access-Control-Allow-Origin HOT 5
- postcss-prefix-wrapper 对 font-family 处理有误 HOT 1
- example运行起来后报错 HOT 1
- 在同一个区域切换子应用的示例 HOT 4
- Umi架构下的应用,目前无法成为子应用 HOT 2
- 是否支持vite构建作为子应用 HOT 3
- 支持blazor webassembly框架吗?.net 系的 HOT 1
- ng-portal是否可以可以更新一下? HOT 3
- 保持宿主路由同步后浏览器返回前进按钮功能失效 HOT 1
- 刷新页面后子应用返回首页 HOT 1
- 兼容性问题:browser-vm模块是否可以不使用 es6 Proxy 实现?
- 您好,关于angular,我没在官网看到当angular作为子应用时的demo HOT 1
- 项目支持vue3吗? 没看到有vue3的demo HOT 1
- 官网更新 HOT 2
- 如何实现一个更加纯粹的iframe HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alibabacloud-alfa.