Skip to content

[RRFC] Optional install #156

@gotbahn

Description

@gotbahn

Motivation ("The Why")

As a Continuous Integration maintainer, I'm highly interested in fast build jobs. Installing dependencies one of the key parts here.

Caching helps significantly speed up, but:

  1. it's not stale, dependencies can be updated pretty often, so cache invalidation as well
  2. not all dependencies are cachable

I highly appreciate that npm has --production flag feature, that allows us to avoid devDependcies installation, this technique significantly reduces install time for delivery jobs.

It would be so nice if such behavior could be more eloquent and we can define or exclude certain packages from being installed. Lemme give some example

Example

Let's say we running some test jobs in parallel, based on type:

  • static, uses eslint, stylelint, typescript, etc.
  • units, uses jest, redux-mock-store, etc.
  • end-to-end, that uses some dev-server, cypress, cypress plugin, etc.
{
  "devDependencies": {
    "cypress": "*",
    "eslint": "*",
    "express": "*",
    "jest": "*",
    "stylelint": "*",
    "redux-mock-store": "*",
    "typescript": "*",
  },
  "dependencies": {
    "react": "*",
    "redux": "*",
    "webpack": "*",
  }
}

How

Current Behaviour

Each of the jobs installs all dependencies. Hower "static" and "unit" don't need packages from end-to-end, but have to install it together with all "devDependencies".

Desired Behaviour

I have no strong vision of how API should look like in the end, but can give a couple of ideas:

Exclude packages

As an additional argument, that accepts list of package to be ignored upon install

npm i --exclude=express,cypress

Unique listing

Assemble own unique lists

{
  "staticDependencies": {
    "eslint": "*",
    "stylelint": "*",
    "typescript": "*",
  },
  "unitDependencies": {
    "jest": "*",
    "redux-mock-store": "*"
  },
  "e2eDependencies": {
    "cypress": "*",
    "express": "*",
  },
  "dependencies": {
    "react": "*",
    "redux": "*",
    "webpack": "*",
  }
}

Can follow the same rule as --production, and install packages from "dependencies" & unique list. For example

npm i --dependencies=static

or

npm i --staticDependencies

References

Sorry, I haven't found anything useful to ref

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions