Skip to content

feat: add MF Rspack standalone examples for basehref #100

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fiorin
Copy link
Contributor

@fiorin fiorin commented Apr 22, 2025

What's added in this PR?

Provide an implementation summary. What did you add beyond the described task? What are the additional details you'd like people to pay attention to? To help people review this PR understand what's changed.

This PR provides a example for basehref usage with Module Federation + Rspack + Zephyr.

The ones with examples are way ahead on testing.

There is another example using Rspack, but with no MF:

What's the issues or discussion related to this PR ?

Provide some background information related to this PR, including issues or task. Prior to this PR what's the behavior that wasn't expected.

If there wasn't discussion related to this PR, you can include the reasoning behind this PR of why you did it.

The Rspack allows bashref as a custom path using the publicPath parameter in the plugin config. Works fine along Zephyr. Adding Module Federation to the formula forces to use "auto" parameter in the publicPath default in order to resolve dinamically remote built urls for the host. If the basehref parameter is added to the Rspack config, MF changes the URL handling to absolute or relative instead auto resolving.
That is the main issue we have found: if bashref is added to the remote, then the host needs the remote declaration as an absolute path, for each remote; or if is passed relative, then will not load the remote because relative evaluate on its own domain, instead remote domains.

  • Using absolute solves the loading issues but cause some usage chaos because for each remote building you need to care about passing to the host config that URL generated. That for each remote, for each build. So the host build flow need real often intervention.
  • Using relative causes 404 on loading script or assets for remotes outside the host domain.

Screenshot from 2025-04-24 10-20-57
Model Host - 2 Remotes - using "auto" URL evaluation

Screenshot from 2025-04-24 10-21-01
Model Host - 2 Remotes - absolute path pointing

Screenshot from 2025-04-24 10-21-04
Model Host - 2 Remotes - relative path pointing

What are the steps to test this PR?

To help reviewer and tester to understand what's needed

Implement an example for basehref usage with MF + Rspack + Zephyr

Documentation update for this PR (if applicable)?

Add documentation if how the application will behave differently than previous state. Copy paste your PR in zephyr-documentation PR link here.

(Optional) What's left to be done for this PR?

The Basehref + MF + Rspack with Zephyr implementation was moved to backlog until further implementation for dynamic domain handling.
It is supposed to have some MF implementation to handle the dynamic remote URLs on Zephyr build

(Optional) What's the potential risk and how to mitigate it?

(Required) Pre-PR/Merge checklist

  • [] I have added/updated/opened a PR to documentation to cover this new behavior
  • I have added an explanation of my changes
  • [] I have written new tests (if applicable)
  • [] I have tested this locally (standing from a first time user point of view, never touch this app before)
  • [] I have/will run tests, or ask for help to add test

@fiorin fiorin marked this pull request as draft April 22, 2025 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant