Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] npm pack ignores files with * by npm@9 #6330

Closed
2 tasks done
riywo opened this issue Apr 6, 2023 · 2 comments
Closed
2 tasks done

[BUG] npm pack ignores files with * by npm@9 #6330

riywo opened this issue Apr 6, 2023 · 2 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release

Comments

@riywo
Copy link

riywo commented Apr 6, 2023

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

There is a pattern with * to list files dynamically and worked with npm@8:

❯ tree dist-es
dist-es
└── file

0 directories, 1 file

❯ cat package.json
{
  "name": "foo",
  "version": "1.0.0",
  "license": "ISC",
  "files": [
    "dist-*"
  ],
  "dependencies": {
    "npm": "^8.19.4"
  }
}

❯ npx npm -v
8.19.4

❯ npx npm pack
npm notice
npm notice 📦  [email protected]
npm notice === Tarball Contents ===
npm notice 0B   dist-es/file
npm notice 139B package.json
npm notice === Tarball Details ===
npm notice name:          foo
npm notice version:       1.0.0
npm notice filename:      foo-1.0.0.tgz
npm notice package size:  222 B
npm notice unpacked size: 139 B
npm notice shasum:        28dbb81702cbfb6cc33dfab16124b64198cb52b0
npm notice integrity:     sha512-RuxBJkELLcpI3[...]5d9K5MHNiTJ4w==
npm notice total files:   2
npm notice
foo-1.0.0.tgz

However, npm@9 won't list them:

❯ npm -v
9.5.0

❯ npm pack
npm notice
npm notice 📦  [email protected]
npm notice === Tarball Contents ===
npm notice 139B package.json
npm notice === Tarball Details ===
npm notice name:          foo
npm notice version:       1.0.0
npm notice filename:      foo-1.0.0.tgz
npm notice package size:  199 B
npm notice unpacked size: 139 B
npm notice shasum:        60bba941acfae804697b3c1658a7f29f75e18338
npm notice integrity:     sha512-W1w8uMjdKoRRd[...]010nGnTR4HMrg==
npm notice total files:   1
npm notice
foo-1.0.0.tgz

Expected Behavior

List dist-* with npm pack.

Or, confirm this is the expected breaking change so that we can change our package.json.

Steps To Reproduce

  1. Setup a package like above (create dist-es/file and add dist-* to files in package.json)
  2. Run npm pack with npm@9
  3. It misses dist-es/file in the tgz file

Environment

  • npm: 9.5.0
  • Node.js: v18.15.0
  • OS Name: Ubuntu 22.04.2 LTS
  • System Model Name: WSL2
  • npm config:
; node bin location = /usr/bin/node
; node version = v18.15.0
; npm local prefix = /tmp/foo
; npm version = 9.5.0
; cwd = /tmp/foo
; HOME = /home/riywo
; Run `npm config ls -l` to show all defaults.
@riywo riywo added Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release labels Apr 6, 2023
@riywo riywo changed the title [BUG] npm pack ignores files with * with npm@9 [BUG] npm pack ignores files with * by npm@9 Apr 6, 2023
@wraithgar
Copy link
Member

The glob rules in npm 9 underwent quite a few bugfixes, and one of the results of that is that it requires you to use proper glob paths.

The glob pattern you want is dist-*/**. See this primer for more info on glob patterns.

~/D/n/s/pack $ npm pkg get files
"dist-*/**"
~/D/n/s/pack $ find .
.
./dist-asdf
./dist-asdf/index.js
./dist-asdf/sub
./dist-asdf/sub/index.js
./package.json
./other-dir
./other-dir/index.js
~/D/n/s/pack $ npm pack --dry-run
npm notice 
npm notice 📦  [email protected]
npm notice === Tarball Contents === 
npm notice 0B   dist-asdf/index.js    
npm notice 0B   dist-asdf/sub/index.js
npm notice 281B package.json          
npm notice === Tarball Details === 
npm notice name:          pack                                    
npm notice version:       1.0.0                                   
npm notice filename:      pack-1.0.0.tgz                          
npm notice package size:  334 B                                   
npm notice unpacked size: 281 B                                   
npm notice shasum:        f47827dcb5942699d9f0d5dd23c92939a82623ea
npm notice integrity:     sha512-6R56rnlUklKbf[...]8koqhJ89csuvg==
npm notice total files:   3                                       
npm notice 
pack-1.0.0.tgz

@riywo
Copy link
Author

riywo commented Apr 10, 2023

Totally makes sense. Thank you for confirming!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release
Projects
None yet
Development

No branches or pull requests

2 participants