Module Federation

Module Federation has been described as a game-changer in the JavaScript architecture. It essentially allows applications to run code from remotely stored modules between servers while part of a bundled application.

Some developers may be aware of a technology called GraphQL. It is essentially a solution for sharing code between applications, developed by a company called Apollo. Federated Modules are a feature of Webpack 5 that allows this to happen between bundled applications.

For a long time, the best compromise was the use of externals of the DllPlugin, which relied on a centralized external dependency file, However, this isn't great for organic development, convenience, or large-scale projects.

With Module Federation, JavaScript applications can dynamically load code between applications and share dependencies. If an application is using a federated module as part of its build but requires a dependency to serve the federated code, Webpack can also download that dependency from the origin of the federated build. So, the federation will effectively provide a map of where Webpack 5 can find the required dependency code.

There is some terminology to consider when it comes to federation: remote and host. The term remote refers to the application or modules that are loaded into the user's application, while the host refers to the application that the user is visiting through their browser at runtime.

The federation method is designed for standalone builds and can be deployed independently or in your own repository. In this sense, they can be hosted bi-directionally, effectively serving as the host of remote content. This means that a single project could potentially switch between hosting orientations throughout the user's journey.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.156.46