Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
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 4 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.