d3 / d3-dsv

A parser and formatter for delimiter-separated values, such as CSV and TSV.

Home Page:https://d3js.org/d3-dsv

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Global d3 object is overwritten

vprus opened this issue · comments

As of release 1.0.6, d3-dsv has this at the top:

(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
    typeof define === 'function' && define.amd ? define(['exports'], factory) :
    (factory((global.d3 = {})));
}(this, (function (exports) { 'use strict';`

The effect is that global.d3 is reset, removing anything that previously loaded modules put there. All the other modules have global.d3 = global.d3 || {}

The problem is present both in d3-dsv.zip for version 1.0.6 on github, and in https://d3js.org/d3-dsv.v1.js

Perhaps it's to do with the Rollup upgrade in this commit ad89faa, which changed it from 0.41 to 0.49.

Looking through the Rollup CHANGELOG, I think the culprit is this change from 0.44:

[BREAKING] Don't extend existing globals, unless options.extend is true.

Discussion of this feature is in rollup/rollup#827

It looks like this can be fixed by setting Rollup's options.extend to true.

Sorry about this! I forgot about this change when upgrading Rollup.

Thanks for the fix!