web-infra-dev / rsbuild

The Rspack-based build tool. It's fast, out-of-the-box and extensible.
https://rsbuild.dev/
MIT License
959 stars 76 forks source link

[MF]: plugin for module federation #1234

Closed douglaszaltron closed 4 months ago

douglaszaltron commented 5 months ago

What problem does this feature solve?

The feature addresses the need for a streamlined and efficient way to manage module federation configurations in ReactJS-based or other development environments. Specifically, the plugin for module federation would allow developers to:

This feature solves the problem of manually configuring module federation settings, which can be time-consuming and prone to errors. By automating these processes and offering customization options, the plugin aims to improve the development workflow, maintainability, and scalability of applications using module federation in the rsbuild environment.

What does the proposed API look like?

It would be interesting to have a plugin for module federation.

import { pluginModuleFederation } from '@rsbuild/plugin-module-federation'; It already sets up the configurations and is able to read a file as the default modulefederation.config.js, and we can change this name.

@chenjiahan Is it feasible and does it make sense for rsbuild?"

chenjiahan commented 5 months ago

Thanks for your suggestion! We do plan to provide better support for module federation in Rsbuild, maybe even in Rsbuild core.

The design of the relevant API has not yet been determined. @ScriptedAlchemy and @2heal1 may be able to provide more input for this ❤️

ScriptedAlchemy commented 5 months ago

Yes. I also wanted to add http endpoint support to allow for APIs to configure the plugin. We need to have a larger discussion about what and how it should look.

File based was another possibility. Also reading exports field and mirroring it in MFP like a package would

douglaszaltron commented 5 months ago

@chenjiahan I'm testing with module federation, but with the new version (v0.3.8), it has stopped working. It halts at 70% sealing plugins. Do you know what could be the issue? Here's an example of my configuration.

image

It's related to the shared configurations in the module federation setup because when I remove that part, it can compile successfully.

image

chenjiahan commented 5 months ago

@douglaszaltron Can you provide a repro that can help us troubleshoot? ❤️

chenjiahan commented 5 months ago

@ahabhgk It seems rspack 0.5.2 broke Rsbuild + module federation example, can you help check it. ❤️

Steps:

chenjiahan commented 5 months ago

I wrote an RFC for MF, see: https://github.com/web-infra-dev/rsbuild/discussions/1461