Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

danpeen
Copy link
Contributor

@danpeen danpeen commented Nov 15, 2024

Description

feat: mount bridge api to module instance

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 Nov 15, 2024

🦋 Changeset detected

Latest commit: 153b377

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

This PR includes changesets to release 27 packages
Name Type
@module-federation/bridge-react 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/modern-js Patch
@module-federation/retry-plugin Patch
@module-federation/data-prefetch Patch
@module-federation/rsbuild-plugin Patch
@module-federation/error-codes 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

Copy link

netlify bot commented Nov 15, 2024

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit 153b377
🔍 Latest deploy log https://app.netlify.com/sites/module-federation-docs/deploys/6737e41e95a0860008f14e77
😎 Deploy Preview https://deploy-preview-3234--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.

Copy link
Contributor

@squadronai squadronai bot left a 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 new LazyRemoteComponentInfo type, which includes an instance property.
  • Introducing a new plugin, BridgeReactPlugin, that enhances the functionality of the createRemoteComponent and createBridgeComponent functions by adding the current module instance to the function arguments.
  • Modifying the createBridgeComponent function to use the instance property from the bridgeInfo parameter, and logging it to the LoggerInstance.
  • Updating the destroy function to emit the beforeBridgeDestroy and afterBridgeDestroy events on the instance.bridgeHook.lifecycle.
  • Adding a new instance prop to the RemoteAppWrapper 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:
  1. Importing the FederationHost type from the @module-federation/enhanced/runtime module.
  2. Updating the ProviderFnParams type to include an optional instance property of type FederationHost.
  3. Modifying the createBridgeComponent function to use the instance property from the bridgeInfo parameter, and logging it to the LoggerInstance.
  4. Updating the destroy function to emit the beforeBridgeDestroy and afterBridgeDestroy events on the instance.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 new instance prop to the RemoteAppWrapper component, which is used to access the bridge hook lifecycle methods for before and after bridge rendering and destruction. Additionally, the getInstance function has been replaced with a type import for FederationHost, which is likely a more appropriate type for the instance being used. |

@danpeen danpeen changed the title feat: mount bridge api to module instance feat: mount bridge api to host instance Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants