Comparing npm packages with SPFx library components
Library components are not the only way to mutualize software code for SPFx solutions. You can also use traditional npm packages and consume them as dependencies in your code through the package.json file, using the same linking mechanism (using npm link). However, in such cases, you will be responsible for the package publishing process (for instance, as part of your DevOps process) and need to use a dedicated platform to host and distribute these packages to your consuming solution. Also – and because in an enterprise scenario, you likely won’t publish your packages publicly – the chosen hosting platform needs to support private packages. Among them, we can mention the most popular ones:
npmjs.comthrough private packages- Azure Artifacts on Azure DevOps
- GitHub Packages on GitHub Enterprise
- JFrog Artifactory
The following table summarizes the npm package and SPFx library component options...