Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@module-federation/node

Package Overview
Dependencies
Maintainers
4
Versions
712
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@module-federation/node

Module Federation for Node.js

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
43K
decreased by-40.21%
Maintainers
4
Weekly downloads
 
Created
Source

Module Federation Support for Node Environments

This package exposes two Webpack Plugins to bring the concept and power of Module Federation to NodeJS. This will allow your server to fetch chunks across the network allowing for distributed deployments of federated applications.

Installation

To install the plugin run one of the following commands in your terminal for your application.

# npm
npm install @module-federation/node

# yarn
yarn add @module-federation/node

Usage

To then use the plugin, modify your webpack.config.js to include and use the two plugins.

At build time, you need to be aware if you're building for the server or for the browser. If it's building for server, we need to set target: false to allow the plugins to function correctly.

The NodeFederationPlugin follows the same API as the Module Federation Plugin and therefore should be a drop-in replacement if you already have it set up in your webpack.config.js.

An example configuration is presented below:


const {NodeFederationPlugin, StreamingTargetPlugin} = require("@module-federation/node");

const config = {
  target: isServer ? false : "web",
  plugins: [
    new NodeFederationPlugin({
      name: 'website2',
      library: {type: 'commonjs-module'},
      remotes: {},
      filename: 'remoteEntry.js',
      exposes: {
        './SharedComponent': './remoteServer/SharedComponent',
      },
    }),
    new StreamingTargetPlugin({
      name: 'website2',
      library: {type: 'commonjs-module'},
      remotes: {},
    }),
  ]
}

FAQs

Package last updated on 20 Sep 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc