danger-js icon indicating copy to clipboard operation
danger-js copied to clipboard

[BUG] npm package contains extra files

Open rubiesonthesky opened this issue 3 months ago • 2 comments

Describe the bug

When looking at the code in npmjs.org (https://www.npmjs.com/package/danger?activeTab=code), you can see that there are a lot extra files that do not need to be included to the package. The size of danger is already big, so it would be nice to reduce the install size even a little bit.

Paths that could be added to .npmignore

  • .github
  • .eslintignore
  • .eslintrc.json
  • .gitattributes
  • .pre-commit-config.yaml
  • .prettierignore
  • .release-it.json
  • CHANGELOG.md
  • CONTRIBUTING.md
  • Dockerfile
  • VISION.md
  • tsconfig.spec.json

Total would be around 90 kB saved. It's not that much of the total size of 1.43 MB, but at least something.

rubiesonthesky avatar Oct 06 '25 08:10 rubiesonthesky

Seems reasonable to me

orta avatar Oct 07 '25 18:10 orta

instead of npmignore I suggest files in package.json instead. npmignore is known for causing issues

v1rtl avatar Oct 09 '25 08:10 v1rtl

I suggest creating .npmignore with whitelisting mode:

*
!/dist/**/*
!/package.json
!/CHANGELOG.md
!/README.md

The logic is:

  1. Exclude everything
  2. Use ! to specify what files to include.

But worth testing it over, I know it works with yarn 1.x, npm different versions may differ.

glensc avatar Dec 12 '25 21:12 glensc

But for now, I just took the list and inserted it (easier)

  • https://github.com/danger/danger-js/pull/1499

glensc avatar Dec 12 '25 21:12 glensc

Merged: https://github.com/danger/danger-js/pull/1499

glensc avatar Dec 14 '25 22:12 glensc