Multi Container with MFE

Tech

Workflow -(commented out for now)

Current workflow(without docker and nginx)

Now navigate to - http://localhost:3000

Routing MFE

Example

Dynamically loading the Remote at runtime

Statically loading remote in Container

new ModuleFederationPlugin({ name: 'container', // The default is remoteType: "script" which requires global@URL library: { type: "var", name: "container" }, filename: 'remoteEntry.js', remotes: { 'home': 'home', }, exposes: {}, shared: packageJson.dependencies // optional way to list all dependencies as shared }), // index.html <script src="http://localhost:3001/remoteEntry.js" />
new ModuleFederationPlugin({ name: 'container', // The default is remoteType: "script" which requires global@URL filename: 'remoteEntry.js', remotes: { 'home': 'home@http://localhost:3001/remoteEntry.js' }, exposes: {}, shared: packageJson.dependencies // optional way to list all dependencies as shared }),

Dynamically loading remotes in Container

new ModuleFederationPlugin({ name: 'container', filename: 'remoteEntry.js', remotes: { home: 'home@[window.homeurl]/remoteEntry.js' }, exposes: { }, shared: packageJson.dependencies // optional way to list all dependencies as shared }), new ExternalTemplateRemotesPlugin(),
fetch('http://localhost:5000/getURL') .then(res => { console.log( res, 'res'); return res.json(); }) .then(data => { console.log(data, 'data'); window.homeurl = data.url; import('./bootstrap'); }) .catch(err => { console.log('failed loading') })```