-
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
[WIP] Skip already installed modules #2176
Conversation
@@ -137,6 +138,15 @@ export default class PackageLinker { | |||
phantomFiles.push(path.join(dest, file)); | |||
} | |||
|
|||
try { | |||
let obj = await fs.readJson(dest + "\\package.json"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path shouldn't contain \\
as that is only valid for Windows. This should use path.join(dest, 'package.json')
instead to work for all OSes.
@@ -147,6 +157,7 @@ export default class PackageLinker { | |||
}, | |||
}); | |||
} | |||
this.reporter.info('skipped ' + skipped.length + ' modules because they are already installed'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be a string here, it should use this.reporter.lang
like everywhere else.
Fixed comments from @wyze and some lint warnings/errors. Will still need to check the tests ( |
The good thing about yarn is that I can play around with node_modules - add console.log, edit code - and then clear everything up with |
@bestander I think most of the times when someone runs yarn add / yarn install, node_modules folder can be assumed unchanged, so it makes sense that the default behaviour is just to skip the installed folders. What's a good point though is that when calling |
Since 0.17 we fixed integrity checking that runs during install, so it won't do installation if integrity file is in place and dependencies did not change. |
Why I am a bit opposed to this is that this is another point of state in the system. |
@bestander Yarn is terribly slow in Windows, even without windows defender activated and having a single dependency updated, at the point where it is totally impractical and unusable in a daily basis. We should either merge this PR or find another solution otherwise no Windows user will ever use this application |
There are some changes that are coming or landed in the latest version of Yarn:
Besides that, read #990 with tests regarding Windows IO operations compared to Linux on the same machine. I'll close this PR for the reasons in a previous comment |
yarn install
was very slow on Windows because it takes very long to copy files from the cache folder tonode_modules
folder, specially if it's not whitelisted in Windows Defender. See #990 for further details.This made yarn very slow vs npm when adding new packages, specially if it had installed huge packages such as Webpack or React (or both), as all previous packages were re-coppied.
This PR solves this problem by skipping those packages that are already installed and have the exact same version that the ones that are about to be copied.
I'm not too sure about the correctness of this because I didn't go too deep into yarn's src architecture, so I can't be sure if I'm missing something... But for a normal use case it seems to work: Only the new packages or those that are needed to update are copied, while the previous ones are just ignored.