Skip to content

Installing d3 pulls in multiple versions of the same d3-* packages #3256

@edmorley

Description

@edmorley

STR

  1. mkdir d3-test && cd d3-test
  2. yarn add [email protected]
  3. Inspect yarn.lock to see if any packages installed more than once due to different versions. eg using: grep '^[^ ]' yarn.lock | sed 's/@.*//' | sort | uniq -d

Expected

No duplicate d3 packages of differing versions.

Actual

  • d3-format is installed twice, once at version 1.2.1 and once at 1.2.2. The older version is due to the parent d3 package pinning to an exact version, whereas d3-scale pins to a version range (1).
  • d3-selection is installed twice, once at version 1.2.0 and once at 1.3.0. Similar to above, the older version is due to the d3 package pinning to an exact version, whereas d3-drag, d3-brush, d3-zoom pin to 1 and d3-transition pins to ^1.1.0.

This means potentially two copies of both packages can end up in the webpack build output, bloating the size of the browser bundle.

I was going to suggest changing the d3 package's exact version pinning to use version ranges - however it appears that the status quo is intentional (#3088). It seems that if this design decision is to be kept, then either:

  • the d3 repo needs to be updated regularly for new d3 sub-package releases - perhaps using something like Renovate to simplify the process?
  • the sub packages need to use exact versions as well, rather than ranges (although this will presumably create even more chances of dependencies drifting and not being in sync)

Many thanks :-)

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