Install transitive dependencies even if listed as devDependencies in the project #2895
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.
Fixes #2819
Go to #2819 for a minimal way to reproduce it. Basically, if you have these kind of dependency tree:
package.json
:a/package.json
:If you install your package using the
--production
flag, thenb
won't be installed (and it should, since it's a transitive dependency ofa
). This PR fixes this.The issue was that, if the exact same version of a dependency pattern is found multiple times during the
resolve
phase, only the first time it will actually be resolved. In order to prunedevDependencies
, all packages that have exactly 1 "resolve request" after theresolve
phase will be discarded. I've removed the optimisation that checks if a given pattern has already been resolved, and changed an array to aSet
to not impact performance.This has probably not been a good explanation but I'm not very familiar with this codebase. I've tried to see what was the motivation for that optimisation, but it's there since the creation of this repo.
Test plan
sequelize-cli
as a dependency andgulp
as a devDependency.yarn install --production
master
,gulp
won't be present innode_modules
. With this PR, it will be.master
,yarn check verify-tree
will fail. With this PR it will pass.