DEV Community

Naveen kumar Gopi
Naveen kumar Gopi

Posted on

1

Module Federation

The module federation plugin spits out this set of files that includes a set of directions on how other projects can get access to the source code - meaning Basically the module federation plugin comes into action when we are working in Micro-Frontend application.

Here inside the plugin array, we need to declare the plugin with its name, filename(visible in network tab), exposes.
The Plugin will create the global object with the name had been declared.
Whereas exposes we need to tell webpack that i need to share the file remotely for that path of the file is mentioned.

Usage:

const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
 const devConfig = {
  mode: "development",
  devServer: {
    port: 8081,
    historyApiFallback: {
      index: "index.html",
    },
  },
  plugins: [
    new ModuleFederationPlugin({
      name: "marketing",
      filename: "remoteEntry.js",
      exposes: {
        "./App": "./src/index",
      },
      shared: packageJSON.dependencies,
    }),
  ],
};

Enter fullscreen mode Exit fullscreen mode

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay