Role of the src and dist folders in NPM packages
src/
and dist/
is a common naming convention for most packages. In most instances a developer has the code that they are working on src/
and the distribution version of the code they want others to use dist/
. Most developers, my self included will either compile, minify or concatenate their code in to production facing version of the code. They usually include the src/
file in their public repositories so that people can see the source code and modify it as they see fit.
tdlr;
src/
is the code the developer is working in.
dist/
is the distribution version that has been modified to perform better for users not looking to modify how the code works.
Typically src
contains source code and dist
code after minification and other changes (anyway, derived code - what would be target
in Java world).
Sometimes when main repo is written in EcmaScript6 or newer, then dist
folder contains code transpiled down to EcmaScript5 to support older versions of nodejs / older browsers.
You can use code from src
if it works for you - however typically code in dist
is minified and hence faster.
But sometimes authors forget to update dist
folder and then you might have discrepancies. You might ping the author to rebuild the dist
folder.