core icon indicating copy to clipboard operation
core copied to clipboard

feat(module-federation/bridge): Enhance Bridge capabilities and fix some issues

Open danpeen opened this issue 1 year ago • 2 comments

Description

In this pr i have supported:

  • support provider.render can be provided by user, so that user can customize their render login. the usage is like this:
import { createBridgeComponent } from '@module-federation/bridge-react';

export const provider = createBridgeComponent({
  rootComponent: App,
  render: () => { user render logic}
});

  • support pass ref and other props, thus user can get the render root dom . The usage is like this:
const Remote1App = createRemoteComponent({
  loader: () => loadRemote('remote1/export-app'),
  fallback: FallbackErrorComp,
  loading: FallbackComp,
});

const App = () => { 
    const ref = useRef<HTMLElement>(null);
    useEffect(() => {
      const refTimeout = setTimeout(() => {
        if (ref && ref.current) {
          ref.current.style.backgroundColor = 'salmon';
        }
      }, 2000)
      return () => {
          clearTimeout(refTimeout);
      }
    }, [])
    return (<Remote1App msg={'hello remote1'} ref={ref} />)
}
  • some fixing about types hit and react-router-dom proxy

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.

danpeen avatar Jul 24 '24 08:07 danpeen

🦋 Changeset detected

Latest commit: 87b0110dfd6f0de84ea449ababac52b685e53b25

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

This PR includes changesets to release 36 packages
Name Type
@module-federation/bridge-react-webpack-plugin Patch
@module-federation/bridge-shared Patch
@module-federation/bridge-react Patch
@module-federation/bridge-vue3 Patch
@module-federation/enhanced Patch
@module-federation/rspack Patch
host Patch
host-v5 Patch
remote1 Patch
remote2 Patch
remote4 Patch
host-vue3 Patch
remote3 Patch
@module-federation/modern-js Patch
@module-federation/nextjs-mf Patch
@module-federation/node Patch
3008-runtime-remote Patch
@module-federation/modernjs Patch
modernjs-ssr-dynamic-nested-remote Patch
modernjs-ssr-dynamic-remote-new-version Patch
modernjs-ssr-dynamic-remote Patch
modernjs-ssr-host Patch
modernjs-ssr-nested-remote Patch
modernjs-ssr-remote-new-version Patch
modernjs-ssr-remote Patch
@module-federation/runtime 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/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

changeset-bot[bot] avatar Jul 24 '24 08:07 changeset-bot[bot]

Deploy Preview for module-federation-docs ready!

Name Link
Latest commit 87b0110dfd6f0de84ea449ababac52b685e53b25
Latest deploy log https://app.netlify.com/sites/module-federation-docs/deploys/66be168d1476e40008cefa45
Deploy Preview https://deploy-preview-2792--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.

netlify[bot] avatar Jul 24 '24 08:07 netlify[bot]