This is perhaps a request for documentation. Are there reasons why it would be a bad idea for yarn to populate the node_modules directory of a project with symbolic links to package directories under ~/.yarn.cache rather than copying those directories? Obviously that would save a lot of disk space.
I believe that yarn link could be one of these reasons... although it seems to be workable anyways. And if implementation would be explicitly optional, I think I it makes sense. Something like yarn install --symlinked or something...
Big danger here, what if dev modified one of the linked module, that would effectively blew up any other project that is using this module. Integrity checks might help, that's seems that yarn doing it already?
The main issue with symlinks is that if you delete the cache, your app will no longer work (as the symlink points to the cache). Hardlinks would solve this while still retaining the disk space advantages. Symlinks are essentially a pointer to another file path (so reading the symlink requires reading the file path it points to), while hardlinks result in multiple files pointing to the exact same data in the filesystem (so the file can be read directly). There's an existing issue about using hardlinks here: #499
The other main issue is that if someone modifies a file in node_modules, they may not realise that it actually modifies the file everywhere, not just in the local copy.
I agree that it would be a great optional feature though. I'd use it!
I'm going to close this out and we can follow up in #499. Thanks for using Yarn! 馃槃
Most helpful comment
The main issue with symlinks is that if you delete the cache, your app will no longer work (as the symlink points to the cache). Hardlinks would solve this while still retaining the disk space advantages. Symlinks are essentially a pointer to another file path (so reading the symlink requires reading the file path it points to), while hardlinks result in multiple files pointing to the exact same data in the filesystem (so the file can be read directly). There's an existing issue about using hardlinks here: #499
The other main issue is that if someone modifies a file in
node_modules, they may not realise that it actually modifies the file everywhere, not just in the local copy.I agree that it would be a great optional feature though. I'd use it!
I'm going to close this out and we can follow up in #499. Thanks for using Yarn! 馃槃