Skip to content

Conversation

danpeen
Copy link
Contributor

@danpeen danpeen commented Oct 13, 2025

Description

This PR introduces a new enableBridgeRouter configuration option to provide more explicit and granular control over the React bridge router functionality in Module Federation, while also optimizing bridge component basename passing and plugin application logic.

What Changed

  1. New Configuration Option
  • Added enableBridgeRouter boolean option to ModuleFederationPluginOptions.bridge
  • Provides explicit control over bridge router functionality
  • Deprecates disableAlias in favor of the more descriptive enableBridgeRouter
  1. Enhanced Plugin Priority Logic
    Implemented a three-tier priority system for ReactBridgePlugin activation:
  • Priority 1: Explicit enableBridgeRouter: true

When user explicitly enables bridge router

  • Priority 2: Explicit disable via enableBridgeRouter: false OR disableAlias: true

Provides backward compatibility with existing disableAlias option
Clear override mechanism for disabling functionality

  • Priority 3: Automatic detection based on @module-federation/bridge-react installation

Falls back to auto-detection when no explicit configuration is provided
Maintains existing behavior for users who haven't configured the option

  1. Optimized Bridge Component Implementation
  • Enhanced basename passing: Introduced BridgeWrapper component to reliably pass basename through both Context API and component props

  • Dual-channel approach: Ensures basename reaches target components via multiple paths for maximum compatibility

  • Better error handling: Maintains existing ErrorBoundary functionality while improving prop flow

Migration Guide

For users wanting to adopt the new explicit configuration:

// Old approach (still works)
module.exports = {
  plugins: [
    new ModuleFederationPlugin({
      bridge: {
        disableAlias: true, // ❌ Deprecated but still functional
      }
    })
  ]
};

// New recommended approach
module.exports = {
  plugins: [
    new ModuleFederationPlugin({
      bridge: {
        enableBridgeRouter: true, // ✅ Explicit enable bridge router
      }
    })
  ]
};

Related Issue

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation.

@changeset-bot
Copy link

changeset-bot bot commented Oct 13, 2025

🦋 Changeset detected

Latest commit: 29e6991

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 36 packages
Name Type
@module-federation/modern-js Patch
@module-federation/runtime Patch
@module-federation/enhanced Patch
@module-federation/rspack Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/sdk Patch
@module-federation/runtime-tools Patch
@module-federation/managers Patch
@module-federation/manifest Patch
@module-federation/dts-plugin Patch
@module-federation/third-party-dts-extractor Patch
@module-federation/devtools Patch
@module-federation/bridge-react Patch
@module-federation/bridge-vue3 Patch
@module-federation/bridge-shared Patch
@module-federation/bridge-react-webpack-plugin Patch
@module-federation/retry-plugin Patch
@module-federation/data-prefetch Patch
@module-federation/rsbuild-plugin Patch
@module-federation/error-codes Patch
@module-federation/inject-external-runtime-core-plugin Patch
@module-federation/runtime-core Patch
create-module-federation Patch
@module-federation/cli Patch
@module-federation/rspress-plugin Patch
@module-federation/metro Patch
@module-federation/metro-plugin-rnef Patch
@module-federation/metro-plugin-rnc-cli Patch
@module-federation/nextjs-mf Patch
@module-federation/node Patch
@module-federation/storybook-addon Patch
@module-federation/modernjsapp Patch
@module-federation/esbuild Patch
@module-federation/utilities Patch
remote5 Patch
website-new Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify
Copy link

netlify bot commented Oct 13, 2025

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit 29e6991
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/68ef1f14ca2c69000855e90d
😎 Deploy Preview https://deploy-preview-4129--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@danpeen danpeen changed the title feat(react-bridge): Introduce enableBridgeRouter Configuration for Enhanced Bridge Router Control WIP(react-bridge): Introduce enableBridgeRouter Configuration for Enhanced Bridge Router Control Oct 13, 2025
@danpeen danpeen changed the title WIP(react-bridge): Introduce enableBridgeRouter Configuration for Enhanced Bridge Router Control feat(react-bridge): Introduce enableBridgeRouter Configuration for Enhanced Bridge Router Control Oct 13, 2025
options?.bridge?.disableAlias === true
) {
if (options?.bridge?.disableAlias === true) {
console.warn(
Copy link
Member

Choose a reason for hiding this comment

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

need to replace with logger.warn :D

@danpeen danpeen merged commit aa7daae into main Oct 15, 2025
18 checks passed
@danpeen danpeen deleted the fix/bridge-router-proxy branch October 15, 2025 06:42
@danpeen danpeen mentioned this pull request Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants