docs(bridge): document the router-free /base entry for non-webpack hosts - #4972
Open
Gmendesfonseca wants to merge 1 commit into
Open
docs(bridge): document the router-free /base entry for non-webpack hosts#4972Gmendesfonseca wants to merge 1 commit into
/base entry for non-webpack hosts#4972Gmendesfonseca wants to merge 1 commit into
Conversation
…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`.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The "Bundle Size Optimization" section of the React Bridge load-app guide presents
bridge.enableBridgeRouteras the way to dropreact-router-domfrom a host bundle. That option is implemented inpackages/enhanced(webpack) andpackages/rspackonly, so two common setups have no plugin that can honour it:@module-federation/vite— itsModuleFederationOptionstype has nobridgekey at all.init()from@module-federation/runtimeandregisterRemotes()directly, with no Module Federation build plugin in the pipeline.For both, the only way to avoid
react-router-domis to import@module-federation/bridge-react/basedirectly. Today that entry is mentioned exactly once in the whole documentation set, inside an:::info How It Worksaside 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 packageexportsmap or inspecting the built bundle.What this changes
The section is split into the two paths:
enableBridgeRouter: falsecontent, unchanged, now labelled with the toolchains that actually implement it./basedirectly, 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:
basenamefrom the surrounding React Router context;/basedoes not, so it must be passed explicitly. (src/remote/base-component/contains nobasenamehandling;src/remote/router-component/component.tsxderives it.)react-router-domis declared inpeerDependencies, but only the router-enabled entry needs it. A host importing exclusively from/basecan leave it uninstalled and ignore the unmet-peer warning.Why it is worth documenting
/baseshipped 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 asnot_plannedfor 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 styleRelated Issue
Documents the entry point requested in #4191 (
@module-federation/bridge-react - react-router optionality), which was closed asnot_plannedafter the capability had already shipped in #4227.Types of changes
Checklist