Understanding what a library component is
The library component, introduced in SPFx v1.9.1, is an additional component type available when creating a new SPFx solution using the Yeoman generator. The main goal of this customization is to share and reuse JavaScript code across multiple SPFx customizations deployed on the tenant (web part, extensions, and so on). It answers a common need in software development in general: avoiding code duplication.
To give you a clear example, let’s take the following use case.
A company creates and deploys a web part, Web Part A, to display information contained in a SharePoint list as a dashboard. For that purpose, they implement a dedicated TypeScript class called ListService.ts to fetch data from a SharePoint list called List A.
A few months later, they decide to create another web part, Web Part B, but this time displaying information for another list, List B, with another view. Again, they implement another ListService.ts class...