Patterns icon indicating copy to clipboard operation
Patterns copied to clipboard

Module federation remote loader

Open ScriptedAlchemy opened this issue 3 years ago • 5 comments

Hi, I've recently developed a better solution to loading remote scripts.

Consider require.loadChunk or webpack_require.l(url,event,id)

This will leverage webpacks own chunk loader for loading remote containers the same way import(remote/module) does within webpack module factories.

It's by far the most reliable solution.

ScriptedAlchemy avatar Aug 27 '22 05:08 ScriptedAlchemy

@ScriptedAlchemy thanks for the heads-up! I've grepped the webpack and module-federation-examples repos for any examples but didn't find any occurrences or examples. Can you point me to something?

thet avatar Sep 21 '22 16:09 thet

The https://github.com/module-federation/module-federation-examples/tree/master/advanced-api/automatic-vendor-sharing are quite the use case which we're tackling here. Except that I do not even want to expose/load individual modules from my separate bundles, but everything which is defined in them and which they depend on :)

thet avatar Sep 21 '22 16:09 thet

This is on npm as module-federation/utilities

Might need some adjustments to the file since it's got a loop for runtime remotes on there. (Send a pr if you want me to maintain script injection)

https://github.com/module-federation/nextjs-mf/blob/main/packages/utilities/src/utils/common.ts

ScriptedAlchemy avatar Sep 28 '22 05:09 ScriptedAlchemy

Ive published it to npm, so you can use it via module-federation/utilities.

ScriptedAlchemy avatar Sep 29 '22 00:09 ScriptedAlchemy

Just a heads up - I‌ still have this on my radar, but I'm short on time diving into that right now. Have to prepare next week's Plone conference training and my talk about module federation in Plone (resp. Patternslib) where I will revisit this proposal for sure :)

thet avatar Oct 07 '22 07:10 thet