Skip to content
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

Adopt the new federation runtime #518

Open
ScriptedAlchemy opened this issue Mar 8, 2024 · 4 comments
Open

Adopt the new federation runtime #518

ScriptedAlchemy opened this issue Mar 8, 2024 · 4 comments

Comments

@ScriptedAlchemy
Copy link
Contributor

Describe the feature

I have recently redesigned module federation and introduced the concept of runtime plugins, while they have many uses - i think the new runtime could be a prime candidate for repack as i recall we had to do some special things for ChunkManager, this could likely be moved into a runtime plugin and not require a full webpack plugin for federation to work (i do the same for node.js now too)

Motivation

More flexability to end user and most likely a cleaner implementation of federation for RN apps

Related Issues

@jbroma
Copy link
Member

jbroma commented Mar 8, 2024

hey @ScriptedAlchemy,

you are talking about MF 1.5 correct? I'm all up for it, love the idea. Perhaps runtime plugins would actually help us solve the issue where host app can't define remotes (I think it was related to converting some part of initialisation logic to promise so RN wasn't initialising correctly). I wasn't involved in Re.Pack development at the time where MF was introduced so my knowledge is limited on why things are as they are. In the future, we're also looking forward to migrating to rspack and I know MF 1.5 is already implemented there as a plugin, but I haven't explored it much as of yet, since it's all very fresh.

Could you point me to some resources on what features MF 1.5 offers?

@ScriptedAlchemy
Copy link
Contributor Author

yeah so for RN this is what i was thinking which may help the chunk manager thing.

module-federation/core#2013

Then for defining remotes etc, we can do things like this:
https://github.com/module-federation/module-federation-examples/blob/master/runtime-plugins/remote-control/app1/pick-remote.ts

Resources:
https://github.com/module-federation/universe/tree/main/packages/runtime
https://github.com/module-federation/universe/tree/main/packages/enhanced

We are also finalizing a new api for adding remotes on the fly:
module-federation/core#2171

Heres a post i wrote about it:
https://medium.com/@scriptedalchemy/emodule-federation-gets-upgraded-and-rspack-supports-it-5ddb0d1e9546

Basically youd just swap over to module-federation/enhacend, then any runtime plugins you want to make you can just add as array like i do in examples.

If you want pure at runtime you can do that too with the module-federation/runtime

If you use enhanced, then all it does is init the runtime package under the hood and pass options.
https://github.com/module-federation/module-federation-examples/blob/master/advanced-api/dynamic-remotes/app1/src/App.js

If its something youd want to adopt, im down to help. I dont know a ton of RN but the main thing i had in mind where i could be helpful is with a runtime plugin for chunk handlers that RN needs.

Like node plugin, you make a custom chunk handler plugin. However i discovered i can do same with runtime plugin and since runtime plugins and federation runtime are embedded into the runtime chunks, they boot before any app code does, it boots along with webpacks runtime etc.

We also just rolled out data manifest plugin and preload hooks so if chunkManager needs that upfront in totality, we have a hook in runtime for preloadAssets etc. (was just merged)

Copy link

github-actions bot commented Apr 8, 2024

This issue has been marked as stale because it has been inactive for 30 days. Please update this issue or it will be automatically closed in 14 days.

@github-actions github-actions bot added the Stale label Apr 8, 2024
@jbroma jbroma removed the Stale label Apr 8, 2024
Copy link

github-actions bot commented May 9, 2024

This issue has been marked as stale because it has been inactive for 30 days. Please update this issue or it will be automatically closed in 14 days.

@github-actions github-actions bot added the Stale label May 9, 2024
@jbroma jbroma removed the Stale label May 17, 2024
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

No branches or pull requests

2 participants