npm / npm-expansions

Send us a pull request by editing expansions.txt

Home Page:http://npm.im/npm-expansions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

> 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 for npm install and arborist reify.

The new linked install mode, dedupes and installs packages in a flat structure in node_modules/.store, and then links the directories in node_modules. Unlike hoisted (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)