Skip to content

Transitive wildcard dependencies should use existing versions if possible #4136

Closed
@glentakahashi

Description

@glentakahashi

Basically an extension of #2763

When packages declare dependencies using wildcards, existing version should be re-used if possible for consistency's sake. For example:

My package.json:

"@types/react": "^15.0.3",
"@types/react-redux": "^4.4.34"

@types/react-redux depends on "@types/react": "*"

In my yarn.lock:

"@types/react@*":
  version "16.0.2"
  resolved "https://registry.yarnpkg.com/@types/react/-/react-16.0.2.tgz#0b31a73cdde6272b719e5b05a7df6d1e2654a804"

"@types/react@^15.0.3":
  version "15.6.1"
  resolved "https://registry.yarnpkg.com/@types/react/-/react-15.6.1.tgz#497f7228762da4432e335957cb34fe9b40f150ae"

In this case, I think @types/react-redux should use 15.6.1 because it's specified by the package.json. For other example, such as dependencies using ^15.6, and package.json using ~15, they should both use 15.6.1.

EDIT: I now realize I can use --flat to force this with the resolutions block, but it seems strange to me that this isn't the default. If packages properly declare their dependencies, it shouldn't matter which version the have installed, so it seems ideal to always use package.json version if possible.

Also, --flat requires you to resolve /all/ dependencies which is just impossible for most repos.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions