Module Federation Runtime init() lazy loading #3922
Replies: 1 comment
-
In order for the system to work and shared modules to be negotiated, the remote modules have to initialize and perform a handshake with each other. Think of Lazy loading remotes basically will mean that each latter remote will have "more shares" than the previous one because they have been sealed. For example if you need v4, as a singleton, but only X remotes are loaded and they only use v3, they will use v3 and when v4 shows up, its too late to unload them from memory. The json manifest isnt actually supposed to be loaded in browsers at all, its designed for server side / edge networks to calculate a lock file, but since users do not have the infra that bytedance has to run this, part of our server logic runs on the fly to recalculate the module locks. So the jsons are more or less a separate thing from federations own initialization phases. It should not be prefetching all shared modules, only ones that are eagerly imported. Do you have a demo repo? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using Module Federation Runtime, with dynamic remotes defined using
mf-manifest.json
. When I callinit()
with these remotes, it fetches all the manifests (which is expected). However, it also fetches all theremoteEntry.mjs
files in those manifests, whilst my typical use case is that only one of those remotes is going to be used in this scenario. Can I control the prefetching strategy somehow so that only the requiredremoteEntry.mjs
is fetched? Also, it pre-fetches all shared modules, but most remotes only use a subset of those shared modules. Can this be made lazy, so that a share is only loaded upon first request? These two capabilities would reduce the number of unnecessary network requests upon module federation initialization. Or will this somehow result in worsened performance than the current situation?Any thoughts, tips and feedback are more than welcome :) Thanks!
Beta Was this translation helpful? Give feedback.
All reactions