Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RRFC] Optional install #156

Open
gotbahn opened this issue May 30, 2020 · 4 comments
Open

[RRFC] Optional install #156

gotbahn opened this issue May 30, 2020 · 4 comments

Comments

@gotbahn
Copy link

gotbahn commented May 30, 2020

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

@maapteh
Copy link

maapteh commented Dec 28, 2020

Just think about having stuff into a mono-repo. I do the same for example our e2e setup is in its own package with its own deps and only runs on the stage it needs to be runned. So not installing any e2e related when not needed. The job depends on the build stage obviously but i guess its clear what a mono repo can do for you :)

Another way is making dependencies yourself for example all linters in one package. Then during the job you can install them while not being part of your package lib.

Having cypress for example as package is a total waste of energy, you can think about creating an image for it. Why download it, is has a huge post install phase and thats really a waste of energy :) Create the container and be done with it.

Hope it helps.

@aladdin-add
Copy link

same issue: we want to skip installing e2e related devDependencies (e.g. puppeteer) - it's very time-costing!

but I suggest something like optionalDevDependencies - it's just the same as optionalDependencies

related discussion: npm/npm#3870

@darcyclarke darcyclarke added the Agenda will be discussed at the Open RFC call label Mar 23, 2021
@darcyclarke
Copy link
Contributor

darcyclarke commented Mar 23, 2021

@gotbahn apologies for the delay in bubbling this up - I've added the "Agenda" label to this issue & it should get discussed at our next Open RFC call on Wednesday.

As a side note, you might actually be able to get this type of behaivour by utilizing workspaces when we ship the next round of improvements which include filtered/scoped installs (ex. npm i --workspace=static / npm i -w=static or npm i -w=static -w=staticDependencies...)

@gotbahn
Copy link
Author

gotbahn commented Mar 23, 2021

As a side note, you might actually be able to get this type of behaivour by utilizing workspaces when we ship the next round of improvements which include filtered/scoped installs

Oh, nice! Scoped installs sounds exciting. Looking forward to try it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants