sindresorhus / np

A better `npm publish`
MIT License
7.56k stars 299 forks source link

Doesn't include `dist` folder #719

Open mahyarmirrashed opened 1 year ago

mahyarmirrashed commented 1 year ago

Description

It is not including the dist/ folder when it is specified to be ignored in .gitignore but not in .npmignore.

Steps to reproduce

  1. Ignore dist in your .gitignore file.
  2. Only ignore node_modules in .npmignore
  3. Run something like npx np@latest --preview even with --contents=dist doesn't mention that the dist folder will be included.

Expected behavior

It should follow the conventions

Environment

np - 8.0.4 Node.js - 16.20.2 pnpm - 8.10.0 Git - 2.42.0 OS - macOS Ventura 13.6.1

jerone commented 8 months ago

I'm having a very similar issue with the dist folder. Via npm there is no issue.

np --preview:

The following new files will be published for the first time:
- LICENSE
- package.json
- README.md

npm publish --dry-run:

npm notice === Tarball Contents ===
npm notice 35.1kB LICENSE
npm notice 1.3kB  README.md
npm notice 767B   dist/main.js
npm notice 919B   dist/main.js.map
npm notice 611B   dist/module.js
npm notice 915B   dist/module.js.map
npm notice 1.7kB  package.json

.npmignore:

*
!dist/**
!package.json
!LICENSE
!README.md
tommy-mitchell commented 8 months ago

What version of np are you on? Since #682 (np v8.0.0), we just use npm itself to figure out what files are included.

What's the output if you run npm pack --dry-run?

jerone commented 8 months ago

@tommy-mitchell commented on Feb 29, 2024, 11:40 PM GMT+1:

What version of np are you on? Since #682 (np v8.0.0), we just use npm itself to figure out what files are included.

The latest version 10.

What's the output if you run npm pack --dry-run?

Exactly the same result as seen above with npm publish --dry-run.

npm notice === Tarball Contents ===
npm notice 35.1kB LICENSE
npm notice 1.3kB  README.md
npm notice 767B   dist/main.js
npm notice 919B   dist/main.js.map
npm notice 611B   dist/module.js
npm notice 915B   dist/module.js.map
npm notice 1.7kB  package.json

np - 10.0.0 node - 21.6.1 npm - 10.5.0 git - 2.44.0.windows.1 OS - Windows 10

jerone commented 8 months ago

Yarn gives the same result as npm.

I tried running np with yarn via np --preview --package-manager=yarn and I got the same missing results.

What I do find surprising is that the files in the dist/ folder are also not mentioned in the ? The following new files will not be part of your published package: section.

jerone commented 8 months ago

Finally had time to do a real publish to NPM and confirmed that the dist/ files are included in the package, while the message didn't mention them.

Maybe I do not understand the message correctly. It says The following new files will be published for the first time:. Keyword new, but the mentioned new files are definitely not new.