Skip to content

feat: Option to Ignore window.origin #290

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

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

Conversation

lelemm
Copy link

@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
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
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
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
Author

lelemm commented Apr 23, 2025

Fixed unit test for this

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