[RRFC] Query Installs

Open
#638 5 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, node.js
Domain
cli, tooling

Research direction

Start by comparing the existing npm query and npm install behavior described in the issue. Define how a query selects dependencies, how the minimal dependency tree is built, and how existing install behavior is preserved. Done means npm install --query supports the listed examples and continues to support aliases such as --production.

Written by the indexing model from the issue text.

Description

Agenda

Motivation ("The Why")

1. Extending the usefulness of npm query

With the new npm query command it's now possible to select subtrees of your dependencies for many different purposes, auditing, inspecting, upgrading dependencies, funding, etc.

For all of these purposes, you sometimes also want the contents of these dependencies as well, even a full install. You can run a full install today, but that tends to take awhile and if you're auditing or want to do something sensitive

2. Allow users to install just the packages they need for a task

For users with sizable installs, npm install is one of the longest steps in their CI process. And oftentimes its not worthwhile to parallelize running separate npm scripts across CI nodes, simply because npm install takes much longer than the script itself.

If you could run:

npm install --query "eslint, [name^=eslint-plugin-], [name^=@typescript-eslint/], typescript"

And get the subtree of your dependencies queried, it would be much faster than trying to run a full npm install/ci and splitting tasks across ci nodes would be much more impactful.

Other tools could be written around npm install --query to make this more powerful by generating queries for you.

3. "Explain" existing features like --production

Features like --production could be implemented via queries, it could be called an alias.

4. Avoid building one-off features in installs

By giving users a powerful querying syntax in installs, many feature requests related to installs could point to this instead.

Example

npm install --query <query>
npm install --query "*:attr(contributors, :attr([name~=Jordan]))"
npm install --query "eslint, [name^=eslint-plugin-], [name^=@typescript-eslint/], typescript"
npm install --query ".prod" # same as `npm install --production`

How

Current Behaviour

N/A, only options are npm install [--production]

Desired Behaviour
  • npm install --query <query>
  • Build the minimal tree that includes all of the dependencies matched by <query>
  • Preserve npm install's other behaviors otherwise

References

Related to #360, #592

Dominant language
JavaScript
Stars
777
Forks
267
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from npm/rfcs

All issues in npm/rfcs

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.