Comments (2)
Interesting question as to how far we want to go with this.
One simple approach would be:
- Get the list of nodes grouped by name.
- For every name with more than 1 instance, get the set of edges in
- Starting from the deepest in the tree, re-attempt to placeDep, with
preferDedupe: true
enabled. - If it ends up in the same place again, re-attempt with the other nodes in the set.
- Repeat until every node in the set is unchanged.
I think it might be surprising if npm dedupe
fetched new packages from the registry, so it should strictly be placing, not fetching.
A more dramatic and powerful approach would be to implement a variant of pubgrub, falling back to nesting when a conflict can be solved that way. It still won't be able to resolve all peer dep conflicts (eg, root module depends on X and Y which peer depend on incompatible versions of Z), but it would result in much more flattening in any non-pathological use case. Of course, doing that implies:
- Lots more fetching of packuments, (as opposed to just fetching the manifest which is the best match for a given spec)
- A dedupe that must reach out to the network.
- Figuring out how pubgrub would interact with git deps, remote deps, etc. In those cases, I think we'd have to fetch and unpack potentially a lot of stuff. (Imagine a package X where each version depends on a git dep Y with a different hash, or a remote dep Z with a different target url -- we'd have to fetch them all.)
I think as a separate command (or something like npm dedupe --extra-flat
or something), it could work, but it would not be network efficient enough for the default install.
from arborist.
Better expressed in #66 and #67. If we wanna do something fancier, we can explore that in a future version.
from arborist.
Related Issues (20)
- [BUG] peerOptionals can cause ERESOLVE in peerSet, but aren't included in tree HOT 1
- [BUG] case where ERESOLVE persists when `--force` is used
- [BUG] should not write package.json file if nothing is being changed
- [BUG] another peerOptional ERESOLVE case HOT 1
- [BUG] loadVirtual errors do not get forwarded to the promise correctly HOT 1
- [BUG] dont use package.json underscore-prefixed values HOT 1
- [QUESTION] How to access information about the package what was added/installed HOT 1
- [BUG] Cannot read property 'version' of undefined HOT 1
- [BUG] npm install recursively changes the owner of all files in my project, crashing mysql in docker HOT 1
- [BUG] (CLI-related) npm install ignores explicit prefix HOT 1
- [QUESTION] Isn't this deduplication happening too late in audit? HOT 2
- [BUG] Diff skips deps of non-global link root HOT 1
- [BUG] arborist does not create bin links for packages with `directories.bin`. HOT 4
- [BUG] TypeError: Cannot read property 'name' of undefined HOT 2
- [BUG] Issue of new version 2.7.1 HOT 1
- [BUG] The name property changes depending on project folder name in package-lock.json HOT 4
- [QUESTION] How is the install algorithm supposed to work ? HOT 1
- [BUG] Error when installing packages from local folder: "TypeError: Invalid comparator: file:../some-local/path"
- infinite loop in conflicting transitive peer dependencies HOT 1
- [BUG] npm update not scoped to workspace when no package targeted HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arborist.