-
In webpack module federation it is possible to import components at runtime. function loadComponent(scope, module) {
return async () => {
// Initializes the share scope. This fills it with known provided modules from this build and all remotes
await __webpack_init_sharing__('default');
const container = window[scope]; // or get the container somewhere else
// Initialize the container, it may provide shared modules
await container.init(__webpack_share_scopes__.default);
const factory = await window[scope].get(module);
const Module = factory();
return Module;
};
} Is this project also possible? Is there any example? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
In my recent project im using it like this, this allows you to have dynamic (modules?) i guess. But the remotes still have to be hard coded in the vite.config
What we are missing is a way to set the remotes at runtime, there is already a PR made by @foot , exposing a function that is doing that but we have no confirmation if it will make it. |
Beta Was this translation helpful? Give feedback.
-
Yes, it is now possible with latest release, also there is an updated example with that release. |
Beta Was this translation helpful? Give feedback.
Yes, it is now possible with latest release, also there is an updated example with that release.