• Stars
    star
    315
  • Rank 132,951 (Top 3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 2 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Vite Plugin for Module Federation

Vite/Rollup plugin for Module Federation

Reason why 🤔

Microservices nowadays is a well-known concept and maybe you are using it in your current company. Do you know that now you can apply similar ideas on the Frontend? With Module Federation you can load separately compiled and deployed code into a unique application. This plugin makes Module Federation work together with Vite.

Working implementations

React

Svelte

Vue

Getting started 🚀

This plugin is based on top of native-federation so this library is a peer dependency.

You need to extend the Vite configuration with this plugin:

import { defineConfig } from 'vite';
import { federation } from '@module-federation/vite';
import { createEsBuildAdapter } from '@softarc/native-federation-esbuild';

// https://vitejs.dev/config/
export default defineConfig(async ({ command }) => ({
  server: {
    fs: {
      allow: ['.', '../shared'],
    },
  },
  plugins: [
    await federation({
      options: {
        workspaceRoot: __dirname,
        outputPath: 'dist',
        tsConfig: 'tsconfig.json',
        federationConfig: 'module-federation/federation.config.cjs',
        verbose: false,
        dev: command === 'serve',
      },
      adapter: createEsBuildAdapter({ plugins: [...], }),
    }),
    [...]
  ],
}));

Define configs

You need to define two different configurations in the federationConfig property.
Here are two examples:

So far so good 🎉

Now you are ready to use Module Federation in Vite!

Thanks 🤝

Big thanks to:

Manfred Steyer, Speaker, Trainer, Consultant and Author with focus on Angular. Google Developer Expert (GDE) and Microsoft MVP.

who collaborate with me to make this possible.

More Repositories

1

module-federation-examples

Implementation examples of module federation , by the creators of module federation
JavaScript
5,621
star
2

core

Module Federation is a concept that allows developers to share code and resources across multiple JavaScript applications
TypeScript
1,497
star
3

aegis-host

This is the ÆGIS federated application host. Federated components are independently deployable, written by multiple teams in multiple languages, and loaded from multiple repos and network locations at runtime, yet capable of running together in a single process or as distributed components in the ÆGIS application fabric.
JavaScript
237
star
4

medusa

A dashboard to tame and control federated apps
JavaScript
171
star
5

aegis

Module federation for the backend. Aegis core lib. Regain control of your microservices by consolidating them into one or more shared processes without loosing deployment or language independence. Eliminate the need for deployment automation. Let services deploy themselves.
JavaScript
145
star
6

typescript

Typescript Types Support For Module Federation
JavaScript
104
star
7

rollup-federation

Module Federation within the rollup bundler
JavaScript
81
star
8

practical-module-federation

JavaScript
76
star
9

automatic-vendor-federation

Utility to enable automatic vendor sharing within bundles using Module Federation
JavaScript
74
star
10

external-remotes-plugin

Dynamically set remote origins at runtime within hosts
JavaScript
52
star
11

enhanced

Enhanced API for Module Federation
JavaScript
46
star
12

fmr

Federated Module Reloading for DEV mode
JavaScript
44
star
13

utilities

Various Utilities for Module Federation
TypeScript
37
star
14

webpack-4

Webpack 4 Plugin For Module Federation
JavaScript
36
star
15

reunited

Module federation and unit tests
JavaScript
34
star
16

module-federation.github.io

Website for Module Federation Org
JavaScript
34
star
17

nextjs-ssr

Next.js Federated SSR over Software Streaming
JavaScript
28
star
18

node

Software streaming to enable node.js support for browser-like chunk loading
27
star
19

aegis-app

This template project provides the scaffolding to build a federated application on ÆGIS. It also contains an example of an Order, Customer and Inventory service streaming to / running in the same ÆGIS host server process; and demonstrates integration with, and orchestration of, an Address, Payment, Inventory, Shipping, Event (Kafka, WebSockets), and Persistence service (MongoDB) via Aegis federated ports.
JavaScript
26
star
20

federation-dashboard

Dashboard service to command, control, and visualize module federation based systems
JavaScript
19
star
21

concat-runtime

Joins runtimeChunk: "single" back to a ModuleFederationPlugin remote containers for independent functionality
JavaScript
14
star
22

apollo-gateway

Webpack Module Federation Apollo based gateway
JavaScript
5
star
23

common-3rd-parties

Common Third party scripts provided as federated modules
JavaScript
3
star
24

next-catchall

Federated Catch All for removing page reloads between next zones
JavaScript
3
star
25

FMR-issues

a place to file issues related to FMR plugin
2
star
26

.github

1
star
27

aegis-scaffold

This template repo provides the scaffolding to develop an ÆGIS federated application.
JavaScript
1
star