
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
use-lazy-module-federation
Advanced tools
This project is to make Micro FE with Module Federation become easier to use
This project was inspire from this sample to load dynamic remote module advanced-api/dynamic-remotes from Creator of Module Federation
But it's still complex to understand all the mechanism to load remote module, so I create this hook to wrap that complex mechanism
webpack.config.js
plugins
part:
const ModuleFederationPlugin = require('webpack').container.ModuleFederationPlugin
module.exports = {
// ...
plugins: [
// ...
new ModuleFederationPlugin({
name: "home",
filename: "remoteEntry.js",
shared: [
{
react: { singleton: true, eager: true },
"react-dom": { singleton: true, eager: true }
}
]
}),
],
};
yarn add -D react-app-rewired
react-app-rewired
will merge your override config with the default webpack config from cra and you can inject your additional settingsconfig-overrides.js
with these content:const ModuleFederationPlugin = require('webpack').container.ModuleFederationPlugin
module.exports = function override(config, env) {
config.plugins = config.plugins || []
config.plugins.push(
new ModuleFederationPlugin({
name: "home",
filename: "remoteEntry.js",
shared: [
{
react: { singleton: true, eager: true },
"react-dom": { singleton: true, eager: true }
}
]
}),
)
return config;
}
react-scripts
with react-app-rewired
"scripts": {
"dev": "react-app-rewired start",
"build": "react-app-rewired build",
"start": "serve -s build -l 3000",
"test": "react-app-rewired test",
"eject": "react-scripts eject"
},
yarn add -D use-lazy-module-federation
import { useLazyModuleFederation } from "use-lazy-module-federation";
type RemoteComponentProps = {
title?: string
}
export default function Container() {
const { Component: RemoteComponent, errorLoading } = useLazyModuleFederation<RemoteComponentProps>({
url: 'http://localhost:3003/remoteEntry.js',
scope: 'app3',
module: './Widget',
});
return (
<>
<Suspense fallback="Loading System">
{errorLoading
? `Error loading module "${module}"`
: RemoteComponent && <RemoteComponent title="hello" />}
</Suspense>
</>
)
}
FAQs
## 1.Reason
The npm package use-lazy-module-federation receives a total of 2 weekly downloads. As such, use-lazy-module-federation popularity was classified as not popular.
We found that use-lazy-module-federation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.