Skip to content

Conversation

@lelemm
Copy link
Contributor

@lelemm lelemm commented Apr 21, 2025

I have a use case that I need to run the remote in dev mode but keep attaching it to the host.
This original line
const origin = window ? window.origin : "//${host}:${viteConfig.server?.port}"
prevents me from using the remote this way, because it tries to load the remote from the host url.

Adding this new parameter makes it possible to do this use case and keep the original behavior.

Copy link
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lelemm for your help
Is it similar to #281 ?

@lelemm
Copy link
Contributor Author

lelemm commented Apr 22, 2025

Thanks @lelemm for your help Is it similar to #281 ?

Yes. it's similar. they both achieve the same goal.

@lelemm lelemm changed the title Option to Ignore window.origin feat: Option to Ignore window.origin Apr 22, 2025
@lelemm
Copy link
Contributor Author

lelemm commented Apr 22, 2025

I created a basic example for this:

lelemm/example

npm run dev on both apps (host and remote)

Press the button:
image

Check your network tab:
image

It shows the remote with the URL of the host, not the remote as expected

@lelemm
Copy link
Contributor Author

lelemm commented Apr 22, 2025

The way I'm using module-federation is to dynamic load remotes to use as a plugin system for the react host app. This plugin system gets the default of the remote and call it passing some parameter to the plugin initialize.

This change is important to give a nice developer experience when developing plugins to the app (allowing it to hot reload with this PR: vitejs/vite-plugin-react#420 )

@lelemm
Copy link
Contributor Author

lelemm commented Apr 23, 2025

Fixed unit test for this

@lelemm
Copy link
Contributor Author

lelemm commented May 13, 2025

@gioboa , do you think this is a mergeable change? I'm waiting on this to be able to release the Actual Budget plugin system so it starts with a nice developer experience (I'm a maintainer of AB)

Copy link
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lelemm it looks good to me

@gioboa gioboa changed the title feat: Option to Ignore window.origin feat: add ignoreOrigin option May 14, 2025
@gioboa gioboa merged commit dc73717 into module-federation:main May 14, 2025
4 checks passed
@gioboa
Copy link
Collaborator

gioboa commented May 14, 2025

@lelemm A new release with this feat is out now. 👏

@lelemm lelemm deleted the enhance/ignore_origin_option branch May 14, 2025 19:19
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.

2 participants