[RRFC] `.npmignore` pragma to include `.gitignore`
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 777
- Forks
- 267
- PR merge metrics
- No merged PRs in 30d
Description
Motivation ("The Why")
While opinions differ, I consider "files" to be dangerous, since I have zero concern for accidental publishing but I have infinite concern for accidental breakage. (Let's avoid debating this)
When using .npmignore, one has to remember to start by cp .gitignore .npmignore, and then later, to keep those in sync, since unfortunately npm ignores .gitignore when .npmignore is present. This is a maintenance burden and is error-prone over time.
Example/How/Desired Behavior
These examples show a hypothetical where "coverage data" is ignored by both git and npm, but the "dist" folder (build output) is ignored by git but included in npm.
Current:
.gitignore
coverage/ # coverage data
dist/ # build output
.npmignore
coverage/ # coverage data
Potential:
.gitignore
coverage/ # coverage data
dist/ # build output
.npmignore
<include gitignore> # ideally something that would make the npm CLI crash prior to supporting this feature
!dist/ # unignore build output
The advantage would be that additions to .gitignore no longer need to be propagated to .npmignore. The disadvantage would be that removals from .gitignore now do need to be propagated, but the explicit opt-in would mean that's expected.
Thoughts?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing how the npm CLI currently interprets .npmignore and .gitignore, using the examples in this RFC as the behavioral reference. Define the opt-in pragma, its interaction with negation such as !dist/, and the expected handling before implementation; done means the proposed behavior is specified and validated in the CLI.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- cli, release
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100