Skip to content

Conversation

@ScriptedAlchemy
Copy link
Member

@ScriptedAlchemy ScriptedAlchemy commented Jan 8, 2026

Summary\n- Stabilizes remote component rerendering in bridge-react and preserves instance state.\n- Defers destroy via queueMicrotask to avoid unmounting during React render phase.\n\nKey Changes\n- createBaseBridgeComponent: adds optional rerender hook, tracks root/component/props per DOM, builds stable element tree, avoids double render when custom render handles it.\n- RemoteAppWrapper: serializes props to a stable dependency (propsStr) for predictable updates.\n- Destroy lifecycle: moves destroy into microtask to prevent render-phase teardown issues and emits before/after hooks in order.\n\nTests\n- Adds packages/bridge/bridge-react/tests/rerender-issue.spec.tsx covering:\n - custom rerender hook being called on prop updates,\n - backward compatibility without rerender option,\n - state/instance preservation across updates,\n - fallback path invokes custom render again on updates.\n\nFiles Touched\n- packages/bridge/bridge-react/src/provider/versions/bridge-base.tsx\n- packages/bridge/bridge-react/src/remote/component.tsx\n- packages/bridge/bridge-react/tests/rerender-issue.spec.tsx\n\nNotes\n- Addresses behavior observed in Issue #4171 (rerender).\n- Maintains existing lifecycle hook ordering and logging.

philip-lempke and others added 23 commits October 27, 2025 12:49
path.join is not meant for URLs. Code does not work in Node > 22.11 and produces an Invalid URL. Fixing by setting the origin as the URL base.
Fixes CI format check failure by adding required trailing comma.
- Add rerender option to ProviderFnParams interface for custom rerender handling
- Update bridge-base implementation to support custom rerender logic
- Add component state tracking to detect rerenders vs initial renders
- Preserve component state when shouldRecreate is false
- Maintain backward compatibility for existing code
- Add comprehensive test suite for rerender functionality

Fixes #4171
- Fix shouldRecreate: true to actually unmount and recreate the root
- Implement proper root recreation with fresh React root instance
- Add comprehensive test to verify recreation behavior
- Ensure state is truly reset when shouldRecreate is true
- Maintain proper cleanup of old roots before creating new ones
- Add changeset for version bumping
- Remove test-implementation.js file (tests are in proper package location)

This addresses the issue where shouldRecreate: true was not actually
recreating the component and resetting state as promised in the API.
- Fix shouldRecreate: true to actually unmount and recreate the root
- Implement proper root recreation with fresh React root instance
- Add comprehensive test to verify recreation behavior
- Ensure state is truly reset when shouldRecreate is true
- Maintain proper cleanup of old roots before creating new ones

This addresses the issue where shouldRecreate: true was not actually
recreating the component and resetting state as promised in the API.
- Revert packages/typescript/src/plugins/FederatedTypesPlugin.ts to main branch version
- This file was not intended to be part of the bridge-react rerender functionality PR
- Keep PR focused only on bridge-react changes for issue #4171
- use stable element types (no nested component defs)

- create root only on first render; reuse for updates

- emit before/after destroy hooks when recreating

- honor custom render: skip re-creating root on updates
… root has no render()

Add tests to cover fallback behavior and ensure UI updates + custom render is invoked again.
@changeset-bot
Copy link

changeset-bot bot commented Jan 8, 2026

🦋 Changeset detected

Latest commit: e9feea6

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

This PR includes changesets to release 37 packages
Name Type
@module-federation/bridge-react Patch
@module-federation/modern-js Patch
remote5 Patch
remote6 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-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
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 Jan 8, 2026

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit e9feea6
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/695f2fb1ad5b8f0008b9cc6c
😎 Deploy Preview https://deploy-preview-4285--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.

@ScriptedAlchemy ScriptedAlchemy changed the title chore: commit current work bridge-react: stabilize rerender and defer destroy to post-render Jan 8, 2026
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