I recently developed a JavaScript package and here is the configuration in my package.json
:
{
"name": "packageName",
"version": "1.0.0",
"description": "Description of the package",
"main": "dist/main.js",
"types": "dist/src/index.d.ts",
"files": [
"dist"
],
"license": "MIT",
"devDependencies": {
},
"peerDependencies": {
"react": ">=16.12.0",
"react-dom": ">=16.12.0",
},
"dependencies": {
}
}
After running npm pack
, I receive a compressed tar.gz
file containing only these files:
dist package.json readme.md
In another project, where this package is included through a file dependency, the structure seems to include all files despite it's listing in the files
key of its package.json
. Here's part of the package.json
for that project:
"mylib": "file:../../mylib",
However, after executing npm install
, checking the directory with ls node_modules/mylib
displays an excessive amount of files not specified in the initial package setup.
This behavior suggests that using a file path dependency is bringing in unnecessary files, whereas I desire only those listed under the files
property within the original package configuration.