Skip to content

docs(bridge): document the router-free /base entry for non-webpack hosts - #4972

Open
Gmendesfonseca wants to merge 1 commit into
module-federation:mainfrom
Gmendesfonseca:docs/bridge-without-react-router
Open

docs(bridge): document the router-free /base entry for non-webpack hosts#4972
Gmendesfonseca wants to merge 1 commit into
module-federation:mainfrom
Gmendesfonseca:docs/bridge-without-react-router

Conversation

@Gmendesfonseca

@Gmendesfonseca Gmendesfonseca commented Aug 7, 2026

Copy link
Copy Markdown

Description

The "Bundle Size Optimization" section of the React Bridge load-app guide presents bridge.enableBridgeRouter as the way to drop react-router-dom from a host bundle. That option is implemented in packages/enhanced (webpack) and packages/rspack only, so two common setups have no plugin that can honour it:

  • @module-federation/vite — its ModuleFederationOptions type has no bridge key at all.
  • Pure runtime hosts — hosts that call init() from @module-federation/runtime and registerRemotes() directly, with no Module Federation build plugin in the pipeline.

For both, the only way to avoid react-router-dom is to import @module-federation/bridge-react/base directly. Today that entry is mentioned exactly once in the whole documentation set, inside an :::info How It Works aside that describes it as a plugin implementation detail requiring "no code changes" — which is the opposite of what these users must do. In practice the router-free path is discoverable only by reading the package exports map or inspecting the built bundle.

What this changes

The section is split into the two paths:

  • With webpack or Rspack — the existing enableBridgeRouter: false content, unchanged, now labelled with the toolchains that actually implement it.
  • Everywhere else — import from /base directly, listing the cases that need it (Vite, pure runtime hosts, and non-React-Router routers such as @tanstack/react-router).

It also documents two behaviours that are not evident from the type signatures:

  • Basename handling differs. The default entry derives a remote's basename from the surrounding React Router context; /base does not, so it must be passed explicitly. (src/remote/base-component/ contains no basename handling; src/remote/router-component/component.tsx derives it.)
  • The peer dependency is conditional. react-router-dom is declared in peerDependencies, but only the router-enabled entry needs it. A host importing exclusively from /base can leave it uninstalled and ignore the unmet-peer warning.

Why it is worth documenting

/base shipped in #4227 (2025-11-24) and does exactly what #4191 asked for, down to the import line in that issue's "Suggested solution". But #4191 was auto-closed as not_planned for inactivity on 2026-01-30, and the entry was never surfaced in the docs as a user-facing option — only as something a plugin does on your behalf. This PR closes that gap so the capability is discoverable by the users who need it most: the ones with no plugin to do it for them.

English only, to keep the diff reviewable. Happy to mirror to zh and pt-BR in this PR or a follow-up, whichever the maintainers prefer.

This is a documentation-only change. It does not change runtime behavior or the public API.

Validation

  • prettier --check apps/website-new/docs/en/guide/bridge/react/load-app.mdx — all matched files use Prettier code style

Related Issue

Documents the entry point requested in #4191 (@module-federation/bridge-react - react-router optionality), which was closed as not_planned after the capability had already shipped in #4227.

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.

…hosts

The "Bundle Size Optimization" section presents `bridge.enableBridgeRouter`
as the way to drop `react-router-dom`, but that option is implemented only in
`packages/enhanced` (webpack) and `packages/rspack`. Two common setups have no
plugin to honour it:

- `@module-federation/vite`, whose `ModuleFederationOptions` has no `bridge`
  key at all
- pure runtime hosts that call `init()` and `registerRemotes()` directly, with
  no Module Federation build plugin in the pipeline

For both, the only route is importing `@module-federation/bridge-react/base`
directly. Today that entry is mentioned once, inside an "How It Works" aside
that describes it as a plugin implementation detail requiring "no code
changes" — which is the opposite of what these users need to do.

Splits the section into the plugin-based path and the manual path, and notes
the two things that are not obvious from the type signatures: `/base` does not
derive `basename` from React Router context, and the `react-router-dom` peer
dependency is unnecessary when importing exclusively from `/base`.
@changeset-bot

changeset-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 6106a0b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

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.

1 participant