
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
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
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.