feat: add a global npmignore file#9351
Open
ljharb wants to merge 1 commit into
Open
Conversation
e559d3e to
41a0eef
Compare
Contributor
|
@ljharb I like the idea, not sure I want to merge it without the accompanying/supporting code as it will silently do nothing but still be a config option |
41a0eef to
b19803e
Compare
Contributor
Author
|
whoops, sorry! i meant to push 4 commits (which is all the supporting code). pushed. |
Contributor
Ha, no worries - but the pacote and packlist changes will have to be in their respective repositories |
Contributor
Author
|
ha, also my bad :-) i'll make those PRs and then update this one. |
This was referenced May 13, 2026
Defines a new path typed config, `global-ignore-file`, with a default of `${prefix}/etc/npmignore`.
The default is computed via a getter on the defaults object so it follows `--prefix` overrides, mirroring the existing `globalconfig` setup.
The default flatten function camelCases the key to `globalIgnoreFile`, which is the option name that `pacote` and `npm-packlist` will read off the flat options bag once their matching support is released.
The motivation is letting a user keep a single ignore list (for editor metadata, scratch directories, and similar artifacts that should never ship) instead of copying the same patterns into every package's `.npmignore`.
This is the cli side of a multi repo feature.
The matching changes live on branches in the corresponding repos and need releases before the option has any effect:
- ljharb/npm-packlist branch feat/global-ignore-file
- ljharb/pacote branch feat/global-ignore-file
After both ship, a follow up commit in cli will bump the `npm-packlist` and `pacote` dependency versions; no other cli source changes are required since the value already flows through `flatOptions` via `lib/commands/pack.js`, `lib/commands/publish.js`, and `libnpmpack`.
Includes definitions tests (type, default, description, flattening) and index tests (computed default from `--prefix`, explicit cli override), plus regenerated snapshots for the type description, the `npm config list` output, and the docs generator.
b19803e to
2b8da71
Compare
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The purpose of this is to allow users to specify files that should never be published that are not project-specific, and should remain on their local machine and NOT committed to every project they happen to work with. This could include IDE files (nobody else should know or care which IDE i'm using), LLM output (.claude directories, things like that), anything that is unique to me, my environment, or my machine, that i never want published.
The intention is for this global file to be configured in a user's npmrc, and then that separate file (
~/.npmignore, for example, like how most people's global gitignore is set to~/.gitignore) is respected.Whether a package is using
files, or.npmignore(or neither), the global npmignore is respected: withfiles, anything listed is published as normal; with.npmignoreor neither, anything listed (except things npm always publishes like package.json and the readme etc) will be removed from the packed file list.