You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Above All
farm 版本:基于目前 farm v2 nightly 版本讨论(分支 v2-dev)
远程模块(remote module):被生产者生产的模块, 可被消费者通过异步加载的方式进行消费。(模块联邦插件 exposes 配置的打包产物)
关于生产(expose)实现
Container 容器
Container 容器作为远程模块的入口文件,在模块联邦中为消费者提供统一的接口,消费者可以通过这些接口实现对异步模块的消费
远程模块需要实现
init和get接口。init接口负责异步模块的初始化;get接口负责返回异步模块的工厂方法。在webpack的实现中,这两个接口定义如下
下面给出 Container Runtime 的伪代码(get部分DONE,init部分TODO)。例子部分 ModuleFederationPlugin Config 如下:
[DOING] 模块联邦中间件
webpack中通过
__webpack_require__.f下的一系列中间件来完成了模块联邦加载 remote module和共享作用域等一系列工作。下面将给出对应中间件在 farm 中的实现:1、
__webpack_require__.f.remotes2、
__webpack_require__.f.consumes[TODO] 关于消费(remote)实现
按上文实现了 expose 之后,用户应该就可以通过 @module-federation/core 进行消费了;如果希望后续提供
build-in的消费支持,插件侧也需要实现一套同样的消费逻辑🤔Beta Was this translation helpful? Give feedback.
All reactions