Sharing dependencies between micro frontends
One of the most important considerations when dealing with micro frontends is where they are composed. We’ve seen in many of the previous chapters that the composition can happen on the server (Chapter 7) or the client (Chapter 9). Generally, however, no matter where we decide to actually stitch the different fragments together, we’ll bring these parts to the browser.
In many cases, we don’t only deliver HTML and CSS to the browser but we also bring over some JavaScript. This is where things start to get interesting. While there are certain scenarios wherein micro frontends are either restricted to bringing JavaScript or what JavaScript they can deliver, we will generally have to deal with pretty much anything in there. This includes some third-party libraries such as React or jQuery.
Like CSS, the major problem with JavaScript is that it is globally shared by default. Unlike CSS, with shadow DOM there is no good...