SharedLibraryWebpackPlugin
Last updated
Last updated
SharedLibraryWebpackPlugin
is a webpack plugin for sharing libraries between applications.
When the host application loads many micro apps bundled with a webpack, many JavaScript is loaded on a client page. In a perfect world, each app can share its libraries with other apps and meet the requirements:
Each app stays self-hosted.
Fallbacks for non-loaded packages.
Codesharing in runtime.
Different library versions work individually.
SharedLibraryWebpackPlugin came to us from a perfect world!
There is a host application with two micro-apps. All apps are built with Angular. The client page loads 282.8kB of JavaScript (gzip) when it opens all pages.
We add SharedLibraryWebpackPlugin in each app build for sharing all Angular packages and zone.js.
After that, the client page loads 174.6kB of JavaScript! It is 38% less!