{"id":19380870,"url":"https://github.com/module-federation/vite","last_synced_at":"2026-05-30T00:01:46.554Z","repository":{"id":65526193,"uuid":"533871213","full_name":"module-federation/vite","owner":"module-federation","description":"Vite Plugin for Module Federation ","archived":false,"fork":false,"pushed_at":"2026-05-27T20:38:48.000Z","size":3260,"stargazers_count":769,"open_issues_count":2,"forks_count":134,"subscribers_count":13,"default_branch":"main","last_synced_at":"2026-05-27T21:22:08.727Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/module-federation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-09-07T17:32:52.000Z","updated_at":"2026-05-27T20:38:54.000Z","dependencies_parsed_at":"2026-01-27T20:01:28.350Z","dependency_job_id":"331ab540-5118-48d3-bc6a-af32955e52cb","html_url":"https://github.com/module-federation/vite","commit_stats":{"total_commits":21,"total_committers":4,"mean_commits":5.25,"dds":0.5714285714285714,"last_synced_commit":"a95fd32aec99f389e9a41ec9e9a2385440320a6a"},"previous_names":[],"tags_count":73,"template":false,"template_full_name":null,"purl":"pkg:github/module-federation/vite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/module-federation%2Fvite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/module-federation%2Fvite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/module-federation%2Fvite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/module-federation%2Fvite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/module-federation","download_url":"https://codeload.github.com/module-federation/vite/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/module-federation%2Fvite/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33675019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-29T02:00:06.066Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T09:15:03.081Z","updated_at":"2026-05-30T00:01:46.529Z","avatar_url":"https://github.com/module-federation.png","language":"TypeScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Framework-agnostic Plugins"],"readme":"# Vite plugin for Module Federation\n\n[![npm](https://img.shields.io/npm/v/@module-federation/vite.svg)](https://www.npmjs.com/package/@module-federation/vite)\n\n## Reason why 🤔\n\n[Microservices](https://martinfowler.com/articles/microservices.html) nowadays is a well-known concept and maybe you are using it in your current company.\nDo you know that now you can apply similar ideas on the Frontend?\nWith [Module Federation](https://blog.logrocket.com/building-micro-frontends-webpacks-module-federation/#:~:text=Module%20federation%20is%20a%20JavaScript,between%20two%20different%20application%20codebases.) you can load separately compiled and deployed code into a unique application.\nThis plugin makes Module Federation work together with [Vite](https://vitejs.dev/).\n\n## Working implementations\n\nExamples live in [`gioboa/module-federation-vite-examples`](https://github.com/gioboa/module-federation-vite-examples):\n\n| Example                                                                                  | Host            | Remote            | Framework                   |\n| ---------------------------------------------------------------------------------------- | --------------- | ----------------- | --------------------------- |\n| [Alpine](https://github.com/gioboa/module-federation-vite-examples/tree/main/alpine)     | `alpine-host`   | `alpine-remote`   | Alpine.js                   |\n| [Angular](https://github.com/gioboa/module-federation-vite-examples/tree/main/angular)   | `angular-host`  | `angular-remote`  | Angular                     |\n| [Lit](https://github.com/gioboa/module-federation-vite-examples/tree/main/lit)           | `lit-host`      | `lit-remote`      | Lit                         |\n| [Nuxt](https://github.com/gioboa/module-federation-vite-examples/tree/main/nuxt)         | `nuxt-host`     | `nuxt-remote`     | Nuxt 4                      |\n| [Nx](https://github.com/gioboa/react-nx-microfrontend-demo)                              | `host`          | `remote`          | React + Nx                  |\n| [Preact](https://github.com/gioboa/module-federation-vite-examples/tree/main/preact)     | `preact-host`   | `preact-remote`   | Preact 10                   |\n| [React](https://github.com/gioboa/module-federation-vite-examples/tree/main/react)       | `react-host`    | `react-remote`    | React 19                    |\n| [Solid](https://github.com/gioboa/module-federation-vite-examples/tree/main/solid)       | `solid-host`    | `solid-remote`    | Solid                       |\n| [Svelte](https://github.com/gioboa/module-federation-vite-examples/tree/main/svelte)     | `svelte-host`   | `svelte-remote`   | Svelte 5                    |\n| [TanStack](https://github.com/gioboa/module-federation-vite-examples/tree/main/tanstack) | `tanstack-host` | `tanstack-remote` | TanStack Router + React 19  |\n| [Turborepo](https://github.com/gioboa/react-turborepo-microfrontend-demo)                | `host`          | `remote`          | React + Turborepo           |\n| [Vinext](https://github.com/gioboa/module-federation-vite-examples/tree/main/vinext)     | `vinext-host`   | `vinext-remote`   | Vinext + Next 16 + React 19 |\n| [Vue](https://github.com/gioboa/module-federation-vite-examples/tree/main/vue)           | `vue-host`      | `vue-remote`      | Vue 3                       |\n\n## Try this crazy example with all these bundlers together\n\n\u003cimg src=\"./docs/multi-example.png\"/\u003e\n\n\u003cp float=\"left\"\u003e\n  \u003cimg src=\"./docs/vite.webp\" width=\"150\" /\u003e\n  \u003cimg src=\"./docs/webpack.webp\" width=\"160\" /\u003e \n  \u003cimg src=\"./docs/rspack.webp\" width=\"200\" /\u003e\n\u003c/p\u003e\n\n```bash\npnpm install\npnpm run build\npnpm run multi-example\n```\n\n## Getting started 🚀\n\n[https://module-federation.io/guide/build-plugins/plugins-vite.html](https://module-federation.io/guide/build-plugins/plugins-vite.html)\n\nWith **@module-federation/vite**, the process becomes delightfully simple, you will only find the differences from a normal Vite configuration.\n\n\u003e This example is with [Vue.js](https://vuejs.org/)\u003c/br\u003e\n\u003e The @module-federation/vite configuration remains the same for different frameworks.\n\n## Dedicated configuration file\n\nYou can keep Module Federation options in `module-federation.config.ts`.\n\n```ts\nimport { createModuleFederationConfig } from '@module-federation/vite';\n\nexport default createModuleFederationConfig({\n  name: 'remote',\n  filename: 'remoteEntry.js',\n  exposes: {\n    './remote-app': './src/App.vue',\n  },\n  shared: ['vue'],\n});\n```\n\n```ts\nimport { defineConfig } from 'vite';\nimport { federation } from '@module-federation/vite';\nimport moduleFederationConfig from './module-federation.config';\n\nexport default defineConfig({\n  plugins: [federation(moduleFederationConfig)],\n});\n```\n\n## The Remote Application configuration\n\nfile: **remote/vite.config.ts**\n\n```ts\nimport { defineConfig } from 'vite';\nimport { federation } from '@module-federation/vite'; 👈\n\nexport default defineConfig({\n  [...]\n  plugins: [\n    [...]\n    federation({ 👈\n      name: \"remote\",\n      filename: \"remoteEntry.js\",\n      // optional: additional \"var\" remoteEntry file\n      // needed only for legacy hosts with \"var\" usage (remote.type = 'var')\n      varFilename: \"varRemoteEntry.js\",\n      exposes: {\n        \"./remote-app\": \"./src/App.vue\",\n      },\n      shared: [\"vue\"],\n    }),\n  ],\n  server: {\n    origin: \"http://localhost:{Your port}\"\n  },\n  [...]\n});\n```\n\nIn this remote app configuration, we define a remoteEntry.js file that will expose the App component.\nThe shared property ensures that both host and remote applications use the same vue library.\n\n## The Host Application configuration\n\nfile **host/vite.config.ts**\n\n```ts\nimport { defineConfig } from 'vite';\nimport { federation } from '@module-federation/vite'; 👈\n\nexport default defineConfig({\n  [...]\n  plugins: [\n    [...]\n    federation({ 👈\n      name: \"host\",\n      remotes: {\n        remote: {\n          type: \"module\", // type \"var\" (default) for vite remote is supported with remote's `varFilename` option\n          name: \"remote\",\n          entry: \"https://[...]/remoteEntry.js\",\n          entryGlobalName: \"remote\",\n          shareScope: \"default\",\n        },\n      },\n      filename: \"remoteEntry.js\",\n      shared: [\"vue\"],\n      // Optional parameter that controls where the host initialization script is injected.\n      // By default, it is injected into the index.html file.\n      // You can set this to \"entry\" to inject it into the entry script instead.\n      // Useful if your application does not load from index.html.\n      hostInitInjectLocation: \"html\", // or \"entry\"\n      // Controls whether all CSS assets from the bundle should be added to every exposed module.\n      // When false (default), the plugin will not process any CSS assets.\n      // When true, all CSS assets are bundled into every exposed module.\n      bundleAllCSS: false, // or true\n      // Timeout for parsing modules in seconds.\n      // Defaults to 10 seconds.\n      moduleParseTimeout: 10,\n      // Idle timeout for parsing modules in seconds. When set, the timeout\n      // resets on every parsed module and only fires when there has been no\n      // module activity for the configured duration. Prefer this over\n      // moduleParseTimeout for large codebases where total build time may\n      // exceed the fixed timeout value.\n      moduleParseIdleTimeout: 10,\n      // Controls whether module federation manifest artifacts are generated.\n      // Type: boolean | object\n      // - false/undefined: no manifest generated\n      // - true: generates mf-manifest.json + mf-stats.json (default names)\n      // - object: overrides fileName/filePath and asset analysis behavior\n      manifest: {\n        // Optional output file name for runtime manifest.\n        // Default: \"mf-manifest.json\"\n        fileName: \"mf-manifest.json\",\n        // Optional output directory/path for both artifacts.\n        // Example: \"dist/\" -\u003e dist/mf-manifest.json + dist/mf-stats.json\n        filePath: \"dist/\",\n        // If true, skips asset analysis.\n        // Effect: shared/exposes are omitted from manifest and assetAnalysis is omitted from stats.\n        // It also disables the preload-helper patch used for remotes.\n        // In serve for consumer-only apps, this defaults to true unless explicitly set.\n        disableAssetsAnalyze: false,\n      },\n    }),\n  ],\n  server: {\n    origin: \"http://localhost:{Your port}\"\n  },\n  [...]\n});\n```\n\nThe host app configuration specifies its name, the filename of its exposed remote entry remoteEntry.js, and importantly, the configuration of the remote application to load.\nYou can specify the place the host initialization file is injected with the **hostInitInjectLocation** option, which is described in the example code above.\nThe **moduleParseTimeout** option allows you to configure the maximum time to wait for module parsing during the build process.\nThe **moduleParseIdleTimeout** option is an alternative that resets the timer on every parsed module. It only fires when there has been no module activity for the configured duration, making it suitable for large codebases where the total build time exceeds the fixed timeout.\n\n## Load the Remote App\n\nIn your host app, you can now import and use the remote app with **defineAsyncComponent**\n\nfile **host/src/App.vue**\n\n```ts\n\u003cscript setup lang=\"ts\"\u003e\nimport { defineAsyncComponent } from \"vue\";\nconst RemoteMFE = defineAsyncComponent( 👈\n  () =\u003e import(\"remote/remote-app\")\n);\n\u003c/script\u003e\n\n\u003ctemplate\u003e\n  \u003cRemoteMFE v-if=\"!!RemoteMFE\" /\u003e 👈\n\u003c/template\u003e\n```\n\n## ⚠️ `codeSplitting` settings are controlled by the plugin\n\nDo not set either `build.rollupOptions.output.codeSplitting` or\n`build.rolldownOptions.output.codeSplitting` to `false` with this plugin — it will be **automatically ignored**.\n\n`codeSplitting.groups` is also ignored because grouping shared-runtime chunks can break MF init order.\nModule Federation needs `loadShare` and `runtimeInitStatus` isolated into separate chunks for correct bootstrap behavior.\n\n## ⚠️ `manualChunks` is not supported\n\nDo not use `build.rollupOptions.output.manualChunks` or\n`build.rolldownOptions.output.manualChunks` with this plugin — it will be **automatically ignored**.\nThe plugin manages the runtime chunk graph itself, and forcing custom chunk grouping can break Module Federation bootstrap order.\nThe plugin injects the splits it needs so `runtimeInitStatus` and `loadShare` stay isolated.\n\n### So far so good 🎉\n\nNow you are ready to use Module Federation in Vite!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodule-federation%2Fvite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmodule-federation%2Fvite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodule-federation%2Fvite/lists"}