You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 17, 2019. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 17, 2019. It is now read-only.
I believe Babel doesn’t correctly handle re-exporting d3.event because it assumes that exported values never change, so this might be a Babel issue. ES2015 modules export bindings, or “live connections to values”, so it’s valid for the value of an exported symbol to change. (And only the module that exports the symbol is allowed to set its value.)
(Rollup also doesn’t re-export it correctly in the CommonJS format, which is why there’s a script to patch the Node bundle, d3.node.js.)
If you want a transpile a custom D3 build down to ES5, I recommend editing the index.js file and re-building with Rollup. You can also simply concatenate the provided ES5 UMD bundles of the individual modules to create a custom bundle; for example:
Yes, you need this to apply side-effects to selection.prototype:
import"d3-selection-multi";
The simplest thing to do would be to just add that line to the existing index.js. Then, if you don’t want some of the other functionality in the default build, delete the corresponding exports.
Activity
mbostock commentedon May 18, 2016
I believe Babel doesn’t correctly handle re-exporting d3.event because it assumes that exported values never change, so this might be a Babel issue. ES2015 modules export bindings, or “live connections to values”, so it’s valid for the value of an exported symbol to change. (And only the module that exports the symbol is allowed to set its value.)
(Rollup also doesn’t re-export it correctly in the CommonJS format, which is why there’s a script to patch the Node bundle, d3.node.js.)
If you want a transpile a custom D3 build down to ES5, I recommend editing the index.js file and re-building with Rollup. You can also simply concatenate the provided ES5 UMD bundles of the individual modules to create a custom bundle; for example:
plmrry commentedon May 18, 2016
Thanks for your response @mbostock
Just to make sure I understand this correctly: What would the edit to
index.jslook like?Something like this?
What confuses me is that
d3-selection-multi'sindex.jsdoesn't export anything, it just performs side effects onselection.mbostock commentedon May 18, 2016
Yes, you need this to apply side-effects to selection.prototype:
The simplest thing to do would be to just add that line to the existing index.js. Then, if you don’t want some of the other functionality in the default build, delete the corresponding exports.
I’ve updated my custom bundle example here:
http://bl.ocks.org/mbostock/bb09af4c39c79cffcde4
plmrry commentedon May 18, 2016
@mbostock Awesome, thank you!