rollup-federation icon indicating copy to clipboard operation
rollup-federation copied to clipboard

How much work is needed to allow rollup to be a remote?

Open 98mux opened this issue 5 years ago • 8 comments
trafficstars

Having rollup be a remote is really useful for my project. I would love to see it be realized. I could potentially sponsor this project.

Btw, amazing work so far with module federation!

@jacob-ebey

98mux avatar Oct 22 '20 12:10 98mux

Going to consider switching to webpack first

98mux avatar Oct 22 '20 13:10 98mux

@filipot I would consider Webpack. I do not have the time or drive to re-visit this at the moment. I'm keeping this open to potentially re-visit in the future.

jacob-ebey avatar Oct 22 '20 15:10 jacob-ebey

@jacob-ebey Is this something you'd be open to a contribution? This would be super helpful in our use case. We're using rollup in our plugin system. Enabling plugins to become remotes instead of switching to webpack would be great then! I'd be happy to try to invest some effort in contributing to this.

LukasHirt avatar Jan 26 '21 13:01 LukasHirt

@LukasHirt Always open for contributions, no one's stopping you ;)

jacob-ebey avatar Jan 26 '21 17:01 jacob-ebey

@LukasHirt You may also consider using snowpack, i think that is the direction where im heading. https://github.com/snowpackjs/snowpack/discussions/1098

98mux avatar Jan 27 '21 14:01 98mux

@jacob-ebey is there a design doc somewhere that specs module federation and how different bundlers need to interop?

I'm interested in this, and may even contribute, but webpack MF features seem to rely on _webpack* variables, whereas this projects seems to use federation. Is it that the two simply diverged?

emilio-martinez avatar Feb 17 '21 05:02 emilio-martinez

@emlio-martinez message me on twitter @ebey_jacob and we can setup a call to talk about things. I don't know of any official design docs, but you can mainly think of __webpack variables as it's module resolution stuff as it doesn't use esm imports. The main api is the get and init where sharing context is provided.

jacob-ebey avatar Feb 17 '21 05:02 jacob-ebey

This effective thing with module federation is that its a webpack specific problem really, from what I can tell. All its doing is calling a custom wrapped runtime on a remote. You can do this with es modules today as far as I can tell, having looked at the code on both sides of the coin here. This is what dynamic import handles.

Unless there is something critical I misunderstand about module federation (this could be the case, I'm not going to lie, the documentation around this is not great), there's no magic here. Its the equivalent of just dynamically importing your application at runtime as needed. Adding a global "module cache" would allow you to do this in a way where you can import the module after bootstrap and it "mount" it when needed.

ScottAwesome avatar Jun 04 '21 02:06 ScottAwesome