Basics of SPA composition
SPA composition builds on top of client-side composition. However, instead of explicitly mentioning HTML tags, we just bring in other scripts. These scripts will automatically integrate themselves and run individual applications when active. The trick is that these independent SPAs will not always be active – and if they are active, they may coexist within one another.
As with all the other patterns, we start our journey into SPA composition with a look at its architecture. Then we follow the essential steps to come up with a sample implementation. Finally, we look at potential enhancements for the derived sample.
The architecture
We've already seen how mini-applications can be hosted in Web Components. SPA composition takes this idea a step further. Instead of relying on Web Components to handle the lifecycle of mini-applications, a custom loader script is used.
As shown in Figure 10.1, the pattern is quite similar to client-side composition...