Skip to content

Reconciling npm aliases and shared dependencies. #4311

Open
@WattyRev

Description

@WattyRev

Here's a proposed scenario:

Parent module has the following dependency:

"dependencies": {
  "myDep": "^2.0.0"
}

and it defines myDep as a shared dependency like so:

shared: {
  myDep: {
    requiredVersion: "^2.0.0"
  }
}

Child module that is rendered inside Parent has the following dependencies:

"dependencies": {
  "myDep-2": "npm:myDep@^2.0.0",
  "myDep": "^1.0.0"
}

and it defines shared dependencies like so:

shared: {
  myDep-2: {
    requiredVersion: "^2.0.0"
  },
  myDep: {
    requiredVersion: "^1.0.0"
  }
}

In my testing, a scenario like this will result in [email protected] being downloaded the browser once, and [email protected] being downloaded to the browser twice.
Parent is loaded and brings [email protected] with it, creating the first v2 download.
Child loads and does not find a provided dependency named "myDep-2" in order to satisfy its requiredVersion, so v2 gets downloaded again.
Child also looks for the provided "myDep" dependency, finds one that doesn't satisfy the required version, and downloads v1.

Is there any way to take a scenario like this and get Child to recognize that the parent's [email protected] satisfies its needs for myDep-2 and use it accordingly, preventing a duplicate dependency download?

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