module-federation / vite

Vite Plugin for Module Federation
MIT License
324 stars 24 forks source link

v1.0.0: Error when trying to load vite remote from webpack host. #65

Open husayt opened 2 months ago

husayt commented 2 months ago

Have tried loading our vite remote with host using module federation runtime but built with webpack. Get this error when calling loadRemote():

logger.ts:14 Error loading remoteEntry.js Error: @vitejs/plugin-react can't detect preamble. Something is wrong. See https://github.com/vitejs/vite-plugin-react/pull/11#discussion_r430879201

Remote should be able to be loaded by webpack host, especially if using MF2 runtime.

zhangHongEn commented 2 months ago

Need to turn off the hmr of the react plugin

Webpack host cooperates with rust remote. I guess HMR will also have problems, which requires customized special processing

zhangHongEn commented 2 months ago

When both the host and the remote are in dev mode, you need to ensure that react-refresh is a singleton and initialized earlier than react-dom. This may require modifying @vitejs/plugin-react I am currently giving priority to completing mf’s capabilities, and will look at react issues later.

ScriptedAlchemy commented 1 month ago

Hmr typically requires us hooking into reacts devtools global to access hmr, if that helps we have a refresh runtime plugin in one of our libraries. Hmr only works when remotes use the json protocol not the js entry

Eliwang4264 commented 3 weeks ago

I encountered the same problem when host ->webpack+react, remote vite+react Runtiem loading, So will we solve this problem from the perspective of the lib, or can we only close Vite's HMR

ScriptedAlchemy commented 2 weeks ago

I'm not sure if it will be possible to apply cross bundler HMR. Let me think about it.

zhangHongEn commented 2 weeks ago

Vue React React-Refresh maintains singleton and is a dev version

---- Replied Message ---- | From | Zack @.> | | Date | 10/17/2024 00:25 | | To | module-federation/vite @.> | | Cc | zhn @.>, Comment @.> | | Subject | Re: [module-federation/vite] v1.0.0: Error when trying to load vite remote from webpack host. (Issue #65) |

I'm not sure if it will be possible to apply cross bundler HMR. Let me think about it.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>