Building a library component
As it is intended to be shared with other solutions, a library component should always have its own solution folder. We start by reorganizing our solution folders a little bit by moving the web parts already developed in Part 2, Build Web Parts with the SharePoint Framework, in a dedicated Packt.Solutions.ProductManagement.Parts folder. The desired folder structure now looks like this.
Figure 16.3 – SPFx library component project structure
Library components and consuming projects must use the same SPFx version to get it to work (otherwise, you could face compilation/bundling issues due to a type mismatch between two different versions). Prior to creating the library project, you must ensure you use the correct version of the SPFx Yeoman generator. In this example, web parts are using SPFx 1.19.0, so the version of the generator must be the same. You can install it using this command:
npm i -g @microsoft/generator...