Module Federation supports Node.js out of the box. Whether you are consuming modules at runtime only, or integrating into a Webpack/Rspack build pipeline, it can be adopted with a relatively small amount of configuration. This document walks through common ways to use Module Federation in Node.js.
In a Node.js server application, you can load remote modules via Module Federation. These modules can be local files built in CommonJS format, or remote services accessed over HTTP. This enables a flexible foundation for server-side microservices, dynamic feature delivery, and shared resources.
If you are only consuming modules in Node.js and do not want to introduce bundlers like Webpack/Rspack, you can use the runtime-only approach. The key idea is: no build plugins required. You only need the APIs provided by @module-federation/runtime.
Steps:
createInstance.remotes array.loadRemote.The following example shows how to load a remote module exposed over HTTP:
If your Node.js application is built with Webpack or Rspack, integrating Module Federation is straightforward: add the plugin and the required runtime configuration.
For the Host (consumer), the key is to add @module-federation/node/runtimePlugin and set remoteType: 'script' and target: 'async-node', then apply the rest of the configuration.
Rspack example (Webpack is largely the same):
After that, you can directly import remote modules in your code:
On the producer side, we recommend using Rslib. You only need to use the @module-federation/rsbuild-plugin plugin and set target: 'async-node' to generate a remote that can be consumed in Node.js.
Key configuration from apps/node-remote/rslib.config.ts:
If you are not using Rslib, you can also build the remote with Rspack/Webpack (the configuration is largely the same). The key points are: set target to async-node, and output remoteEntry.js with library.type = 'commonjs-module'.
Rspack example:
Webpack configuration is largely the same as the Rspack example above.
target: 'async-node' do?target: 'async-node' is a Webpack build target that produces output suitable for Node.js with asynchronous loading. This is important for Module Federation’s dynamic, async loading model—especially when you need top-level await while loading remotes.
remoteType: 'script'?Currently, the MF bundler runtime only supports the script remote loading type, so for Node.js consumption you need to explicitly set remoteType: 'script'.
apps/node-host/webpack.config.jsapps/node-host/src/main.jsapps/node-remote/rslib.config.tsapps/node-remote/webpack.config.js