module-federation-examples
module-federation-examples copied to clipboard
feat(): add error handling when remote is down
When app2 is down the entire app crashes. Since the route definition is synchronous and happens before the app renders, we can't do a dynamic import like const routes = await import('app2/routes') in order to catch the error so it has to be caught before the module federation promise rejects.
shpuld use webpack require. but ill send you the snippit tommorrow
shpuld use webpack require. but ill send you the snippit tommorrow
I found another alternative where you can create a promise chain and resolve before the app i.e.
import('app2/routes').then(async (module) => {
ReactDOM.render(<App routes={module.default} />, document.querySelector('#root'));
}).catch(e => {
// handle error or render App with fallback routes
}
But it would be great to have an example on how to use the low level API above to handle this on the script.onerror()
@infoxicator is attempting to deploy a commit to the Module Federation Team on Vercel.
A member of the Team first needs to authorize it.