feat(bridge-react): support React Router 8 package layout#4837
feat(bridge-react): support React Router 8 package layout#4837BleedingDev wants to merge 6 commits into
Conversation
🦋 Changeset detectedLatest commit: 1d9bb03 The changes in this PR will be included in the next version bump. This PR includes changesets to release 46 packages
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 |
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b33c04f893
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
b33c04f to
9f6924a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f6924a185
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
9f6924a to
8be9ecf
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8be9ecf6e7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
8be9ecf to
1fa6d1b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1fa6d1bffd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
1fa6d1b to
02aad5c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 02aad5c432
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
02aad5c to
25c516c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25c516c7da
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
25c516c to
461ec05
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 461ec055c3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
3684bd5 to
803b0fc
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 803b0fc34d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
803b0fc to
c8781ec
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c8781ecabe
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
c8781ec to
bcbbe88
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bcbbe88d74
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6dc6833ff2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dc7a54f2ce
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| routerPackagePath: string, | ||
| ): Record<string, string> => { | ||
| return { | ||
| 'react-router$': reactRouterV8AliasPath, |
There was a problem hiding this comment.
Guard shared react-router for v8 aliases
When a React Router 8 remote also configures shared: ['react-router'] or the object equivalent, the Module Federation shared consume path can take the real router package before this new react-router$ proxy is used, so BrowserRouter/RouterProvider are not wrapped and the host basename/memoryRoute context is ignored. The plugin constructor still only rejects shared react-router-dom, which covered the old package name; please apply the same guard to react-router for the v8 path.
Useful? React with 👍 / 👎.
Description
Fixes #4836.
React Router 8 removes
react-router-domand moves DOM-specific router APIs behindreact-router/dom. This updates the React bridge to support that package layout without keeping a v8react-router-dombridge path.What changed:
router-v8androuter-v8-dombridge entries soreact-routerandreact-router/domare proxied independently.react-router/dom, and map bridge-internal dist imports back to the user's installedreact-routerpackage to avoid alias loops.react-router-domso importing@module-federation/bridge-reactdoes not requirereact-router-domduring module initialization.react-routerpeers for@module-federation/bridge-reactand@module-federation/modern-js-v3while keepingreact-router-domcapped at v7.Related Issue
Impact
Apps preparing for React Router 8 can migrate imports to
react-routerandreact-router/dom, then let the bridge plugin select the v8 proxy entries. Existing v5/v6/v7 router aliases are kept on their current paths, including the v7react-router-domcompatibility alias.Validation
pnpm install --frozen-lockfilepnpm --filter @module-federation/bridge-react-webpack-plugin run testpnpm --filter @module-federation/bridge-react exec jest --config jest.config.ts __tests__/default-import.spec.ts __tests__/router.spec.tsx --runInBandpnpm exec prettier --check packages/bridge/bridge-react/src/router/v8.tsx packages/bridge/bridge-react/src/router/v8-dom.tsx packages/bridge/bridge-react/vite.config.ts packages/bridge/bridge-react/package.json packages/bridge/bridge-react/README.md packages/bridge/bridge-react/jest.config.ts packages/bridge/bridge-react/__tests__/default-import.spec.ts packages/bridge/bridge-react/__tests__/router.spec.tsx packages/bridge/bridge-react-webpack-plugin/src/router-alias.ts packages/bridge/bridge-react-webpack-plugin/src/utils.ts packages/bridge/bridge-react-webpack-plugin/src/index.ts packages/bridge/bridge-react-webpack-plugin/__tests__/utils.spec.ts packages/bridge/bridge-react-webpack-plugin/README.md packages/modernjs-v3/package.json .changeset/react-router-eight-bridge.mdgit diff --checkpnpm exec turbo run build --filter=@module-federation/bridge-react --filter=@module-federation/bridge-react-webpack-plugin --filter=@module-federation/modern-js-v3Notes:
package.jsoncurrently asks for Node^20.rsbuild-plugin/modern-js-v3.Types of changes
Checklist