Does the main D3 module namespace not get updated with bleeding edge submodule additions?

Viewed 159

I'm trying to use d3.group, a very new addition to the d3-array submodule that got released a few days ago. I am using a yarn/webpack workflow and import statements to pull in D3 like so:

import * as d3 from 'd3';

However, when I tried to use d3.group, it didn't work.

console.log(d3.group)

Returns undefined.

I to solve this, I had to install the newest version of d3-array and assign that to a new namespace.

import * as d3Array from 'd3-array';
console.log(d3Array.group)

This successfully returned the function.

So my question is, when Bostock or the other D3 developers update the submodules, do the updates not get added to the main D3 namespace until a major update? Is it necessary to pull from the submodules every time I want to use a really new feature?

1 Answers

Considering that the newest d3-array is not it on the latest d3 bundle, and you're using webpack/yarn

You can easily loads the modules on the d3.*, install the latest modules and wrap then together,

example: // select all your d3 modules and save it on d3.js // then load it on your script -> import d3 from './d3'; import { select, selectAll } from 'd3-selection' import { group } from 'd3-array'

    const d3 = Object.assign(
      {},
      {
        select,
        selectAll,
        group,
      }
    )
    export default d3;

ref: https://www.giacomodebidda.com/how-to-import-d3-plugins-with-webpack/

Related