Skip to content

feat: add createModuleFederationConfig helper#720

Merged
gioboa merged 2 commits into
module-federation:mainfrom
tonoizer:feat/add-create-module-federation-config-helper
May 18, 2026
Merged

feat: add createModuleFederationConfig helper#720
gioboa merged 2 commits into
module-federation:mainfrom
tonoizer:feat/add-create-module-federation-config-helper

Conversation

@tonoizer
Copy link
Copy Markdown
Contributor

This PR adds createModuleFederationConfig helper for Vite config DX to further follow more the module federation recommendations to use the module-federation.config.tsfile structure (https://module-federation.io/guide/build-plugins/plugins-rspack.html#create)

createModuleFederationConfig(options) => options

The goal is DX consistency with the official Module Federation integrations for Rspack, Rsbuild, and Rspress, where users are encouraged to define their federation config in a dedicated module-federation.config.ts file and pass that object into the bundler plugin.

Why

  • Aligns Vite with the existing Module Federation config-file convention.
  • Gives users a simple, typed entry point for module-federation.config.ts.
  • Improves discoverability and keeps docs/examples consistent across bundlers.
  • Keeps Vite-specific typing by using @module-federation/vite's own ModuleFederationOptions type instead of the generic SDK plugin type.

Example

// module-federation.config.ts
import { createModuleFederationConfig } from '@module-federation/vite';

export default createModuleFederationConfig({
  name: 'remote_a',
  exposes: {
    './Feature': './src/Feature.tsx',
  },
});
// vite.config.ts
import { defineConfig } from 'vite';
import { federation } from '@module-federation/vite';
import moduleFederationConfig from './module-federation.config';

export default defineConfig({
  plugins: [federation(moduleFederationConfig)],
});

Expose a typed identity helper so authors can mirror the shared
module-federation.config.ts pattern used by other MF integrations,
while keeping @module-federation/vite-specific ModuleFederationOptions.

Co-authored-by: Cursor <cursoragent@cursor.com>
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 18, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@module-federation/vite@720

commit: 7720a75

Copy link
Copy Markdown
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your help @tonoizer

Comment thread src/index.ts
@gioboa gioboa changed the title feat: add createModuleFederationConfig helper for Vite MF DX feat: add createModuleFederationConfig helper May 18, 2026
@gioboa gioboa merged commit f7dcd2f into module-federation:main May 18, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants