Comments (20)
These questions show just how wanting we are for a proper spec here. I don't have answers today. The way it works now is not working. That's the only answer I have today.
from cli.
I'm in the position of upgrading the company wide npm version, this is one of the few changes that's causing wide spread differences. It's mainly a matter of documenting the change and explaining how to write equivalent npm 10 patterns.
I thin npm 8's ["dist-*"]
needs to become ["dist-*", "dist-*/**"]
from cli.
build
should absolutely match both build
and build/**/*
, just like it does for git.
from cli.
It seems like npm 10 will only treat exactly *
as a directory wildcard, so *
or lib/*
will match directories, but dist-*
or *.ts
will only match files.
from cli.
Okay, there's a closed npm/cli issue saying it's fixed #6164, and a npm-packlist issue tracking other packlist changes npm/npm-packlist#152
The fix they reference npm/npm-packlist#147 suggests that packlist should treat *
the same as **
, however dist-**/
doesn't match dist-es/index.js
either.
from cli.
interestingly dist-*/*
does match and has the same packlist between 8 and 10.
from cli.
Yes it's not very well documented, but the way "globstar" is treated got aligned more with standard glob implementations quite some time ago. Not sure what the long term solution will be here, obviously trying to "patch" back the old behavior has been buggy. Your best bet is to fix your globs.
from cli.
Added a note to our v11 roadmap to unwind all of these hacks.
from cli.
What does 'unwind all of these hacks' mean? Make it more like npm 8, or make it ' aligned more with standard glob implementations'?
IMO npm 8's behavior is not unaligned with standard globs.
dist-*
should include dist-cjs/index.js
for the same reason that dist-cjs
includes dist-cjs/index.js
in npm 10 - it matched dist-cjs
folder and recursively included everything in it.
An analogy, echo shows that dist-* only matches direct children
$ echo dist-*
dist-cjs dist-es dist-other.js
But when you give those arguments to find
it recurses and finds the descendants.
$ find dist-*
dist-cjs
dist-cjs/index.js
dist-cjs/lib
dist-cjs/lib/index.js
dist-es
dist-es/index.js
dist-other.js
Here's another example comparing npm 8 and 10, this time without using *
patterns. The directory pattern dist-es
matches the files in the dir in both versions. But passing the brace pattern dist-{es,cjs}
which expands to "dist-es", "dist-cjs"
only matches files in the directories in npm 8.
8 (["dist-es"]) | 10 (["dist-es"]) | both
| | dist-es/index.js
| | package.json
8 (["dist-{es,cjs}"]) | 10 (["dist-{es,cjs}"]) | both
dist-cjs/index.js | |
dist-cjs/lib/index.js | |
dist-es/index.js | |
| | package.json
from cli.
What does 'unwind all of these hacks' mean?
It means no longer work around the default node-glob
behavior. The decision was made at the time to try to work around them because the changes weren't well documented at the time. In hindsight this was probably less ideal than adding notes to the changelog to let folks know about the new behavior.
from cli.
For what it's worth find
does not use "glob".
ls
does. Compare the difference between ls *
and ls */*
from cli.
That is my point, dist-*
expands to dist-es
and dist-cjs
, then npm checks those directories recursively, like find does. The expansion is flat and doesn't rely on globstar behavior.
files: ["dist-es", "dist-cjs"]
will include dist-es/index.js
, but files: ["dist-{es,cjs}"]
won't, even tho it expands to the same thing.
I think npm 8's pattern matching was good. Requiring explicit recursive patterns would be okay. dist-cjs
being recursive while dist-*
is not, is bad.
dist-*
anddist-es
both matchingdist-es/index.js
is good (npm 8)dist-es
matchingdist-es/index.js
whiledist-*
does is bad (npm 10)dist-*
anddist-es
not matchingdist-es/index.js
is ok (maybe what you're proposing for npm 11?)dist-*/**
anddist-es/**
both matchingdist-es/index.js
is ok (maybe what you're proposing for npm 11?)
from cli.
Yes those last two would be what npm 11 does.
from cli.
Will those changes apply to .gitignore and .npmignore?
So .npmignore
build
won't exclude every file under build
in npm 11?
File patterns follow a similar syntax to .gitignore
docs.npmjs.com
from cli.
So will there be different pattern rules for .npmignore and files
? dist-*
in .gitignore or .npmignore will exclude everything under dist-cjs/
, while dist-*
in package.json files would only include a literal file like dist-other.js
while not including dist-cjs/
directories contents?
I much prefer npm 8's and .gitignore's "if a pattern matches a directory, it's files are matched" behavior to the proposed "a files
pattern must exactly match the path to a file".
from cli.
If you look through the history of especially map-workspaces
and npm-packlist
you'll see just how buggy the changes from glob
have made npm. We have to work around the new behavior in every instance now, and doing it like that is almost guaranteed to produce bugs.
from cli.
I'm happy to help out with spec/doc/test writing or discussion.
Not sure if this falls under the same umbrella, but I found that symlinks are treated differently between 8 and 10. LMK if I should create a different issue.
├── link -> /tmp/target
│ ├── dist
│ │ └── index.js
│ └── index.js
~/test-npm-pack '["link"]' '["link/dist"]' '["link/*"]' | column -t -s ' ' -o ' | '
8 (["link"]) | 10 (["link"]) | both
| | package.json
Neither 8 or 10 will recursively include files from a symlink that matches the pattern.
8 (["link/dist"]) | 10 (["link/dist"]) | both
link/dist/index.js | |
| | package.json
npm 8 will match files inside a link, as long as the pattern reaches past the link, but npm 10 won't.
8 (["link/*"]) | 10 (["link/*"]) | both
link/dist/index.js | |
link/index.js | |
| | package.json
npm 8 will also work with patterns, I think this is the same behavior as before.
8 (["link/dist/index.js"]) | 10 (["link/dist/index.js"]) | both
link/dist/index.js | |
| | package.json
npm 10 won't match a file under a symlink even when the exact path is given.
The behavior is the same with an internal link, like link -> ./dist-es
. I'm less sure about what the right behavior is here.
from cli.
A co worker found an odd behavior with directories named cvs. In this case I can't explain how either npm 8 or 10 is behaving. I understand the CVS is ignored by default, but it's not on the list of files that can't be included (docs)
- npm 10 will include the cvs directory with
"cvs"
patterns, but 8 won't. - Neither version will include dist/cvs directory with the
dist/cvs
pattern. - npm 8 will include dist/cvs/index.js with
dist/cvs/index.js
pattern but npm 10 won't. - Everything seems case insensitive and CVS will match cvs and vice versa.
.
├── cvs
│ └── index.js
├── CVS
│ └── index.js
├── dist
│ ├── cvs
│ │ └── index.js
│ └── CVS
│ └── index.js
└── package.json
8 (["cvs"]) | 10 (["cvs"]) | both
| cvs/index.js |
| CVS/index.js |
| | package.json
8 (["CVS"]) | 10 (["CVS"]) | both
| cvs/index.js |
| CVS/index.js |
| | package.json
8 (["dist/cvs"]) | 10 (["dist/cvs"]) | both
| | package.json
8 (["dist/CVS"]) | 10 (["dist/CVS"]) | both
| | package.json
8 (["cvs/index.js"]) | 10 (["cvs/index.js"]) | both
| | cvs/index.js
| | CVS/index.js
| | package.json
8 (["CVS/index.js"]) | 10 (["CVS/index.js"]) | both
| | cvs/index.js
| | CVS/index.js
| | package.json
8 (["dist/cvs/index.js"]) | 10 (["dist/cvs/index.js"]) | both
dist/cvs/index.js | |
dist/CVS/index.js | |
| | package.json
8 (["dist/CVS/index.js"]) | 10 (["dist/CVS/index.js"]) | both
dist/cvs/index.js | |
dist/CVS/index.js | |
| | package.json
npm-debug.log is also inconsistent, and differently than cvs.
.
├── dist
│ └── npm-debug.log
│ └── index.js
├── npm-debug.log
│ ├── index.js
│ └── npm-debug.log
└── package.json
8 (["npm-debug.log"]) | 10 (["npm-debug.log"]) | both
| | npm-debug.log/index.js
npm-debug.log/npm-debug.log | |
| | package.json
8 (["dist/npm-debug.log"]) | 10 (["dist/npm-debug.log"]) | both
dist/npm-debug.log/index.js | |
| | package.json
8 (["**/npm-debug.log"]) | 10 (["**/npm-debug.log"]) | both
dist/npm-debug.log/index.js | |
npm-debug.log/index.js | |
npm-debug.log/npm-debug.log | |
| | package.json
from cli.
https://github.com/npm/npm-packlist/blob/cb4a823cd42d50475a8e1e7582b95b15766f5ca2/lib/index.js#L25
from cli.
It's on the default ignore list, but it's not on the "can't include" list.
Why doesn't **/CVS/**
include dist/CVS/index.js
in npm 10?
Why doesn't dist/CVS
include dist/CVS/index.js
in npm 10?
.
├── CVS
│ └── index.js
├── dist
│ └── CVS
│ └── index.js
└── package.json
8 (["**/CVS/**"]) | 10 (["**/CVS/**"]) | both
| | CVS/index.js
dist/CVS/index.js | |
| | package.json
8 (["CVS"]) | 10 (["CVS"]) | both
| CVS/index.js |
| | package.json
8 (["dist/CVS"]) | 10 (["dist/CVS"]) | both
| | package.json
from cli.
Related Issues (20)
- [BUG] Failed index access on utils/tar.js while trying to publish a package with node_modules HOT 3
- [BUG] npm pack in 10.5.0 introduces breaking change due to changed output HOT 4
- [BUG] dist-tag in package.json not re-evaluated HOT 1
- [BUG] #7495 Partially fixes #7413, but running scripts for workspaces in the / directoy is still broken. HOT 1
- [BUG] can't install HOT 4
- [BUG] Fsevents hanging HOT 3
- [BUG] <EACCES permissions errors when installing packages, npm is trying to use /.npm as its cache directory, which typically requires root permission > HOT 4
- [BUG] `npm outdated` no longer respects semver range for `npm:` style indirect versions
- [BUG] How do I know that which version of nodeJS and npm are using a mern stack project HOT 2
- [BUG] `npm ci` doesn't properly compare `package.json` with `package-lock.json` HOT 1
- [BUG] If the project name is node_modules, this error will be reported HOT 1
- [BUG] npm shows spinner while waiting for password
- [BUG] "There appears to be trouble with your network connection. Retrying..."
- [BUG] "There appears to be trouble with your network connection. Retrying..." HOT 2
- [Feature request] Support overriding `main`, `exports` and other package.json fields with `publishConfig`
- [BUG] Installing an aliased package with an empty name will install the 'undefined' package HOT 2
- * OS: linux
- [BUG] Unable to install packages w/ brew linked node | macOS | NODE_EXTRA_CA_CERTS defined, behind ZScaler firewall HOT 1
- ### File `EIPS/(milehigh.world)eip-7708.md`
- Should npm init emit type=module? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cli.