Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@module-federation/typescript
Advanced tools
Webpack plugin to stream typescript for module federation apps/components
A webpack plugin for sharing typescript types between module federated apps. This plugin is distributed for free via privjs.com
Procure a free license to this plugin from privjs.com. Check your email for the private token and then run the following commands:
$ npm config set @module-federation:registry https://r.privjs.com
$ npm i @module-federation/typescript
Register the plugin in webpack.config.js file
const FederatedTypesPlugin = require('@module-federation/typescript')
const federationConfig = {
name: 'my-app',
filename: 'remoteEntry.js',
exposes: {
//...exposed components
'./Button': './src/Button',
'./Input': './src/Input',
},
remotes: {
app2: 'app2@http://localhost:3002/remoteEntry.js',
},
shared: ['react', 'react-dom'],
}
plugins: [
// ...
new ModuleFederationPlugin(federationConfig),
new FederatedTypesPlugin(), // Optional: you can pass federationConfig object here as well
]
You need to register this plugin in both remote and host apps. The plugin will automatically create a directory named @mf-typescript
in the host app - that contains all the types exported by the remote apps.
In your file:
import RemoteButtonType from "../@mf-typescript/Button";
const RemoteButton = React.lazy(
() => import("app2/Button")
) as unknown as typeof RemoteButtonType;
You need to manually pass the federationConfig
object to the plugin. The remotes
value should contain absolute path.
Sample code:
// next.config.js
const FederatedTypesPlugin = require('@module-federation/typescript')
module.exports = {
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
config.plugins.push(
new ModuleFederationPlugin(federationConfig),
new FederatedTypesPlugin({
...federationConfig,
remotes: { app2: 'app2@http://localhost:3000/remoteEntry.js' }
})
)
return config
},
}
Drop me a message on twitter for support/feedback, or maybe just say Hi at @prasannamestha
Shoutout to @ScriptedAlchemy for helping with the development of this plugin.
FAQs
Webpack plugin to stream typescript for module federation apps/components
The npm package @module-federation/typescript receives a total of 10,975 weekly downloads. As such, @module-federation/typescript popularity was classified as popular.
We found that @module-federation/typescript demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.