Thanks, Brian!
Yes, re-downloaded content is a drawback of micro frontends.
Tree shaking is a popular way to reduce the bundle size. It relies on the import and export statements in ES2015 to detect if code modules are exported and imported for use between JavaScript files. Hence, it can remove unreachable code. In modern JavaScript applications, module bundlers, such as, webpack or Rollup, can automatically remove unreachable code when bundling multiple JavaScript files into single files.
Unfortunately, tree shaking doesn’t work for Moment.js at this point. But there are still ways to reduce Moment.js bundling sizes. A simple way is using import moment from ‘moment/src/moment’
.
Micro frontend approach has pros and cons. It provides decoupling by extra footprint. My other article, 10 Decision Points for a Micro-Frontend Approach, discussed this. You do have one more point, which is that it requires a server, or multiple servers.
You have asked a lot of interesting questions. It is part of the fun journey!
Thank you for your interest in my article.