Inside package.json, we can specify a list of dependencies that must be packaged during packaging.
....
"bundledDependencies": [
"dependency_1",
"dependency_2"
]
....
More about bundledDependency can be found here.
It may be more manual work of maintaining this list. There is a library called bundle-deps for this .
Using
$ bundle-deps [path/to/project]
bundled 48 dependencies.
$ npm pack
source
share