
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
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>
</>
)
}
Happy coding ♥
FAQs
## 1.Reason
The npm package use-lazy-module-federation receives a total of 5 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.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.