> Co-authored-by: Vincent Bailly [vibailly@microsoft.com](mailto:vibailly@microsoft.com)
Syndrom-Fnale opened this issue · comments
> Co-authored-by: Vincent Bailly [vibailly@microsoft.com](mailto:vibailly@microsoft.com)
Added an
--install-strategy=(hoisted | linked)
config option fornpm install
andarborist reify
.The new
linked
install mode, dedupes and installs packages in a flat structure innode_modules/.store
, and then links the directories innode_modules
. Unlikehoisted
(the previous and current default behavior), linked installs are not hoisted, and while the.store
directories are deduped, the tree is not. Links are not hoisted.One added benefit is that dependencies and workspaces will no longer work by coincidence when a shared package is required but the dependency was accidentally omitted from one or more parents.
This new install mode may break packages that depend on hoisted behavior. The package-lock.json will not change when switching modes.
This is a draft PR with the following known TODOS:
- solve resolved URL linking in reify (currently breaking 1 line of coverage)
- remove dependency on
hash-graph-nodes
- properly handle when a workspace is also bundled
- readability
- potential for performance improvements
Longer term (outside the scope of this PR):
- remove need for emulated tree by converting Node class into proper Proxy and isolating logic
Originally posted by @Syndrom-Fnale in npm/cli#5492 (comment)