Giter Site home page Giter Site logo

Comments (3)

Boelroy avatar Boelroy commented on July 26, 2024 3

目前微前端大家的思路都是在项目入口导出几个方法用来挂载 & 卸载子应用。 但是实现思路各自各有不同

飞冰的思路是把子应用导出的方法,直接挂载到 window 的 变量里面,然后去使用子应用的导出的生命周期函数。然后如果想使用沙箱,必须通过 xhr 把脚本请求回来然后再去 new Function 的执行

在 Alfa 中 有 CONSOLE_OS_GLOBAL_HOOK,_CONSOLE_OS_GLOBAL_VARS 这几个变量是为了通过在沙箱开启的情况下还能以 script 的方式加载子应用,并且通过类似 amd 的方式 通过模块系统获取函数的导出。

在我们实践中发现 xhr + new Function 十分损耗内存,对在应用变多的情况下体验十分糟糕。我们这样的好处是,script 加载天然是被浏览器优化的,所以性能上肯定没有问题

对于代码复杂度高的原因是我们在里面提供了非常多的高级特性比如:

from alibabacloud-alfa.

klfzlyt avatar klfzlyt commented on July 26, 2024

CONSOLE_OS_GLOBAL_HOOK
_CONSOLE_OS_GLOBAL_VARS
……等
这些全局变量似乎还增加了维护的复杂程度

from alibabacloud-alfa.

lolipop99 avatar lolipop99 commented on July 26, 2024

@Boelroy 那在兼容性方面呢,目前在官档没找到对应说明,尝试了下demo是无法运行的,已经做了polyfill

from alibabacloud-alfa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.