-
-
Notifications
You must be signed in to change notification settings - Fork 272
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
@module-federation/runtime init method not executing as expected #2584
Comments
please provide a repo to debug |
Hello @xiaoYuanDun. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with |
here is the repo, thank you https://stackblitz.com/~/github.com/xiaoYuanDun/module-federation-demo?file=README.md |
@xiaoYuanDun according to the source code, this is correct. builder id is the ID of the host. |
yeah, it work, but i wonder why the buildId is the highest priority in this case, can I only use the i dont know if The purpose of providing name to the Developer is to resolve this case here. if so, when i defined the name = app2, actually i want init the app2, but it stopped by buildId, Is it more reasonable to first judge by the name passed in from the outside? |
If this is a meaningful question, Could you please take a look at this when you have a moment ?I will continue to follow it. THX |
So you are trying to init the same app as two different names? |
no, not the same app, different app has their own mf_instance in in my case ,the app1 is the main app, it provides a global function, like init, loadRemote, so that the subApp do not need i want manage all the instances in Dose the |
and , according to the source code, if the app is not built via new MF plugin, they will not has i can fix my case by this way, it need move my config in MF_Plugin to fully dynamic runtime, but I feel like this is not a good solution. if the I haven’t seen any special logic related to FEDERATION_BUILD_IDENTIFIER yet. wonder what is the meaning of distinguishing whether it contains buildId? |
are you trying to recycle the runtime code from the host? By setting a global instance, you are communicating with the host instance only, not the remote instances. there should be 1 instance of federation per remote, you should have 3 instances created. By using the global host instance, you are just communicating as the host, dispatching commands in the host who is encoded as app1 |
I wrote a new repo here to see if it can be clearer, the steps is in the readme.md |
You would need to expose a global function that executes init and returns a instance. You cannot execute init and make the return global |
Please excuse me, I don't think I fully grasped what you said. Just let's focus back here repo , is there any way to make the execution of And yes, I'm able to get my project working for now by switching between app1-via-build and app1 like this, but will you consider unifying the behavior of the two in the future? |
As the issue was labelled with 由于该 issue 被标记为 "需要重现",但在 5 天内没有回应,因此该 issue 将被关闭。如果你有任何进一步的问题,请随时发表评论并重新打开该 issue。背景请参考 为什么需要最小重现。 |
the repo is here, @ScriptedAlchemy but it closed automatically, Is anyone still working on this? |
As the issue was labelled with 由于该 issue 被标记为 "需要重现",但在 5 天内没有回应,因此该 issue 将被关闭。如果你有任何进一步的问题,请随时发表评论并重新打开该 issue。背景请参考 为什么需要最小重现。 |
get same issue, any solutions? |
Clear and concise description of the problem
there are 2 app: "app1", "app2", and now i want change some config for "app2", and i call
init
under the scope of app1, like thisinit({ name: 'app2', remotes: { ... } })
but is not working,when i debug code,i find there is a
buildId
ingetGlobalFederationInstance
, and the value of buildId is always "app1". theFEDERATION_BUILD_IDENTIFIER
stop me, because app1 build with MF_Plugin.so i want to know, if i want to change init option between different scope, how should i do ?
// ----------------------------------------------------------------
大概描述一下:
目前有两个 app:app1 和 app2,需要在 app1 中对 app2 的配置做一些更新,这时在 app1 的 scope 下调用 init
init({ name: 'app2', remotes: { ... } })
但是此时 app2 的 MF 实例中并没有更新,debug 发现是因为
![image](https://private-user-images.githubusercontent.com/22720420/337139168-5f50777b-3b7c-41a4-b46f-d51097a82d4d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNjA5NjMsIm5iZiI6MTczOTA2MDY2MywicGF0aCI6Ii8yMjcyMDQyMC8zMzcxMzkxNjgtNWY1MDc3N2ItM2I3Yy00MWE0LWI0NmYtZDUxMDk3YTgyZDRkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDAwMjQyM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI4NjY0MDllZmZkMmE1ODdkNWRkNWVlMTkyYjQ3MmQwMGQzNmIyMjg0OGMxNGFhZDkxOWVjMmUwYWQ0M2E3NzImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.QVK0R7ypQZBKBZ_os2bHF77X8KUcB7B3KCZU6sBMtTI)
getGlobalFederationInstance
方法中会判断一个buildId
,如果 app1 是通过构建时引用 MF 插件,则会生产一个FEDERATION_BUILD_IDENTIFIER
,导致这里的buildId
永远都是 "app1"。想要了解一下,这里为什么要对构建时的 MF 实例做这个限制,现在
init
方式已经提供了name
属性,应该就是为了可以跨实例进行配置修改吧,所以在getGlobalFederationInstance
寻找 MF 实例时,是不是以 name 作为最高优先级的查找条件比较合适。Suggested solution
getGlobalFederationInstance
方式可以优先通过入参的 name 来查找 MF 实例Alternative
No response
Additional context
No response
Validations
Tasks
The text was updated successfully, but these errors were encountered: