-
-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: mount bridge api to host instance #3234
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 153b377 The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 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 site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
This pull request introduces a new feature to mount the bridge API to the module instance in the bridge-react package. The key changes include:
- Adding a new function
createLazyRemoteComponent
that allows for the creation of a lazy-loaded React component that can render a remote module. - Updating the
createRemoteComponent
function to use the newLazyRemoteComponentInfo
type, which includes aninstance
property. - Introducing a new plugin,
BridgeReactPlugin
, that enhances the functionality of thecreateRemoteComponent
andcreateBridgeComponent
functions by adding the current module instance to the function arguments. - Modifying the
createBridgeComponent
function to use theinstance
property from thebridgeInfo
parameter, and logging it to theLoggerInstance
. - Updating the
destroy
function to emit thebeforeBridgeDestroy
andafterBridgeDestroy
events on theinstance.bridgeHook.lifecycle
. - Adding a new
instance
prop to theRemoteAppWrapper
component, which is used to access the bridge hook lifecycle methods for before and after bridge rendering and destruction.
These changes aim to improve the integration of the bridge API with the module federation runtime, allowing for better control and management of the bridge's lifecycle within the application.
File Summaries
File | Summary |
---|---|
packages/bridge/bridge-react/src/create.tsx | The code changes introduce a new function createLazyRemoteComponent that takes in an object with properties such as loader , loading , fallback , export , and instance . This function is used to create a lazy-loaded React component that can be used to render a remote module. The changes also update the createRemoteComponent function to use the new LazyRemoteComponentInfo type, which includes the instance property. |
packages/bridge/bridge-react/src/index.ts | The code changes introduce a new export, BridgeReactPlugin , which is likely a plugin for the bridge API to be used in a React-based application. Additionally, the existing exports createRemoteComponent and createBridgeComponent remain unchanged, suggesting the primary purpose of this change is to add the new plugin functionality. |
packages/bridge/bridge-react/src/plugin.ts | The code changes introduce a new plugin for the bridge-react module that enhances the functionality of the createRemoteComponent and createBridgeComponent functions. The plugin wraps the original functions and adds the current module instance to the function arguments, allowing for better integration with the module federation runtime. |
packages/bridge/bridge-react/src/provider.tsx | The code changes introduce a new feature to mount a bridge API to a module instance. The key modifications include: |
- Importing the
FederationHost
type from the@module-federation/enhanced/runtime
module. - Updating the
ProviderFnParams
type to include an optionalinstance
property of typeFederationHost
. - Modifying the
createBridgeComponent
function to use theinstance
property from thebridgeInfo
parameter, and logging it to theLoggerInstance
. - Updating the
destroy
function to emit thebeforeBridgeDestroy
andafterBridgeDestroy
events on theinstance.bridgeHook.lifecycle
. |
| packages/bridge/bridge-react/src/remote/index.tsx | The code changes introduce a new feature to mount the bridge API to the module instance. The key modifications include adding a newinstance
prop to theRemoteAppWrapper
component, which is used to access the bridge hook lifecycle methods for before and after bridge rendering and destruction. Additionally, thegetInstance
function has been replaced with atype
import forFederationHost
, which is likely a more appropriate type for the instance being used. |
Description
feat: mount bridge api to module instance
Related Issue
Types of changes
Checklist