Library for loading in dynamic remote components when utilizing webpack Module Federation
npm install mf-dynamic-remote-componentLoading in dynamic remote federated components made easy
- Keep remote modules in a cache on the window object
- Promise based
- 0 dependencies
- Support for both lazy/suspense, loadable or others
``bash`
npm install mf-dynamic-remote-component
`js`
// config object example
{
"path": "/client/App2RemoteEntry.js", // Path to remote container entry. Ideally CDN location in live environments.
"scope": "App2", // Container scope name
"module": "./MyRemoteComponent" // Shared module
}
`js
import React, {lazy, Suspense} from 'react';
import {RemoteComponent} from 'mf-dynamic-remote-component';
export default function RemoteHostComponent(config) {
const Component = React.lazy(() => RemoteComponent(config));
return (
$3
`js
import React from 'react';
import {RemoteComponent} from 'mf-dynamic-remote-component';
import loadable from '@loadable/component';export default function RemoteHostComponent(config) {
const Component = loadable(() => RemoteComponent(config));
return (
<>
config={config}
customProps={customProps}
otherProps={otherProps}
/>
>
);
}
`$3
`js
import React from 'react';
import {RemoteComponent} from 'mf-dynamic-remote-component';
import loadable from '@loadable/component';export default function RemoteHostComponent(config) {
const Component = loadable(() => RemoteComponent(config), {
fallback: (
Loading...
),
});
return (
<>
config={config}
customProps={customProps}
otherProps={otherProps}
/>
>
);
}
``