Giter VIP home page Giter VIP logo

Comments (2)

isaacs avatar isaacs commented on August 16, 2024

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.

isaacs avatar isaacs commented on August 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.