-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Install transitive dependencies even if listed as devDependencies in the project #2895
Conversation
…ger discarded on --production installs
I think this bug originates in the package hoister. In production mode, devDepencies are ignored, but when a subdependency of the normal dependencies is deduped with a root devDependency, that root devdep isn't marked as non-ignored. I'm afraid your solution only works when the two references are exactly the same, but if the versions differ, the requests won't be merged. |
@blexrob The hoister bug you are describing seems to have been fixed here: #2537 I've tried installing this
|
@DanReyLop I should have done a test before commenting, sorry for that noise. This PR fixes indeed that when the same version of a (not yet installed) package is referenced multiple times, different references are created for that package, fixing this bug. However, it does trigger another one with the following package.json:
(citronjs chosen as the first package in gulp's npm page that has gulp as dependency). When running yarn install, there are now two references to the newly installed gulp - one from the package.json and one from citronjs. This PR merges those into one request with two references. The The fix for that would be to let I'll see if I can modify #2921 to include that last fix. |
I have added a commit to #2921 which removes the reference count check in |
@blexrob Wow, ok, that went way over my head. The hoister is a beast that I'm not ready to wrestle with (yet). Great find with that counter-example! Looks like your fix makes this PR obsolete, I'm closing this :) I have just one small suggestion, please add a test like the one on this PR. Your testing approach with
And probably should add too the example you just described:
There's no such thing as "too many tests" when you're testing the absolute core of the program :) |
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.