Skip to content

Conversation

@ScriptedAlchemy
Copy link
Member

Fix for Issue #4159: bridge-react (0.21.1): Created types are not correct

Problem

The TypeScript types generated for @module-federation/bridge-react v0.21.1 were incomplete compared to v0.8.10, missing crucial properties like rawComponent, __BRIDGE_FN__, and proper component props inference.

Root Cause

  • Changes in package structure with version-specific entry points
  • Type generation configuration affecting type bundling
  • Missing type exports in version-specific entry points

Solution

  1. Enhanced Type Exports - Added missing type exports (RenderFnParams, RemoteComponentParams, etc.) to all entry points
  2. Updated Bridge Component Interface - Added new BridgeComponent<T> interface with all required properties
  3. Improved Type Generation - Enhanced vite-plugin-dts configuration for better type bundling
  4. Type Safety Verification - Added comprehensive type tests

Changes Made

  • src/v18.ts & src/v19.ts: Added missing type exports
  • src/types.ts: Added BridgeComponent<T> interface
  • src/provider/versions/bridge-base.tsx: Enhanced return type with rawComponent and __BRIDGE_FN__
  • src/index.ts: Updated main exports for backward compatibility
  • vite.config.ts: Improved DTS plugin configuration
  • src/__tests__/types.test.ts: Added type verification tests

Expected Results

After these changes, generated types will include:

  • ✅ Complete bridge interface with render, destroy, rawComponent, and __BRIDGE_FN__
  • ✅ Proper component props type inference (e.g., WidgetProps)
  • ✅ Backward compatibility with legacy import patterns
  • ✅ Full type safety for both /v18 and /v19 imports

Testing

  • Type compilation tests pass
  • Component props inference works correctly
  • All entry points export complete type definitions

Fixes #4159

…ents

- Add missing type exports (RenderFnParams, RemoteComponentParams, etc.) to v18.ts and v19.ts
- Add new BridgeComponent<T> interface with rawComponent and __BRIDGE_FN__ properties
- Update bridge-base.tsx to properly expose rawComponent and __BRIDGE_FN__
- Enhance main index.ts exports for backward compatibility
- Improve vite.config.ts DTS plugin configuration for better type bundling
- Add comprehensive type tests to verify generated types

Fixes #4159
@changeset-bot
Copy link

changeset-bot bot commented Oct 30, 2025

⚠️ No Changeset found

Latest commit: 9e61ccb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link

netlify bot commented Oct 30, 2025

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit 9e61ccb
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/6903f6921daccf000884a97f
😎 Deploy Preview https://deploy-preview-4174--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.

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.

bridge-react (0.21.1): Created types are not correct

2 participants