Skip to content

Conversation

danpeen
Copy link
Contributor

@danpeen danpeen commented Apr 10, 2025

Description

refactor(bridge-react): Refactor the bridge-react to better support multiple React versions from React 16 to React 19, in the meantime maintaining backward compatibility and providing clearer version-specific entry points.

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.

Copy link

changeset-bot bot commented Apr 10, 2025

🦋 Changeset detected

Latest commit: 1ecdeba

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

This PR includes changesets to release 32 packages
Name Type
@module-federation/bridge-react Major
remote5 Minor
website-new Minor
@module-federation/runtime Major
@module-federation/enhanced Major
@module-federation/rspack Major
@module-federation/webpack-bundler-runtime Major
@module-federation/sdk Major
@module-federation/runtime-tools Major
@module-federation/managers Major
@module-federation/manifest Major
@module-federation/dts-plugin Major
@module-federation/third-party-dts-extractor Major
@module-federation/devtools Major
@module-federation/bridge-vue3 Major
@module-federation/bridge-shared Major
@module-federation/bridge-react-webpack-plugin Major
@module-federation/modern-js Major
@module-federation/retry-plugin Major
@module-federation/data-prefetch Major
@module-federation/rsbuild-plugin Major
@module-federation/error-codes Major
@module-federation/inject-external-runtime-core-plugin Major
@module-federation/runtime-core Major
create-module-federation Major
@module-federation/cli Major
@module-federation/nextjs-mf Patch
@module-federation/node Patch
@module-federation/storybook-addon Major
@module-federation/modernjsapp Patch
@module-federation/esbuild Patch
@module-federation/utilities 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

Copy link

netlify bot commented Apr 10, 2025

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit 2bab3ad
🔍 Latest deploy log https://app.netlify.com/sites/module-federation-docs/deploys/67ff663dc13ed40008c0646a
😎 Deploy Preview https://deploy-preview-3690--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 site configuration.

You can choose specific import paths based on the React version used in your project:

```jsx
// Auto-detect React version (recommended for most scenarios)
Copy link
Member

Choose a reason for hiding this comment

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

How to detect, I'm not found the logic.(maybe just not in this diff)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

* - import { createBridgeComponent } from '@module-federation/bridge-react/v18'
* - import { createBridgeComponent } from '@module-federation/bridge-react/v19'
*/
function defaultCreateRoot(
Copy link
Member

Choose a reason for hiding this comment

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

Why no react 19 here 🤔

:::danger
请注意:使用 `@module-federation/bridge-react` 后不能将 `react-router-dom` 设置成 shared,否则构建工具将会提示异常。这是因为 `@module-federation/bridge-react` 通过代理 `react-router-dom` 实现了对路由的控制,以保证应用间路由能够正常协同工作。
:::danger 注意
使用 `@module-federation/bridge-react` 后不能将 `react-router-dom` 设置成 shared,否则构建工具将会提示异常。这是因为 `@module-federation/bridge-react` 通过代理 `react-router-dom` 实现了对路由的控制,以保证应用间路由能够正常协同工作。
Copy link
Member

Choose a reason for hiding this comment

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

Can we auto detect it on build plugin ?

}

// For React 16/17, use legacy API
return {
Copy link
Member

Choose a reason for hiding this comment

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

Throw error if the react is 19

@danpeen danpeen merged commit 88a018d into main Apr 16, 2025
24 of 25 checks passed
@danpeen danpeen deleted the feat/react-bridge-compat-reactv19 branch April 16, 2025 09:39
@2heal1 2heal1 mentioned this pull request Apr 22, 2025
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.

3 participants