palerdot / react-d3-speedometer

React Speedometer component using d3.js ⚛️

Home Page:https://palerdot.in/react-d3-speedometer/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reducing bundle size

ZipBrandon opened this issue · comments

Adding react-d3-speedometer to an application that makes extensive use of d3 via nivo results in importing the entire d3 package. This can be circumvented with redeclaring imports so they don't import from the index of d3; or declaring sideEffects in the package.json.

image

With a bit of further investigation, this seems like this improvement would be yielded from usage of the alternate d3 libraries and not d3.

This can be circumvented with redeclaring imports so they don't import from the index of d3; or declaring sideEffects in the package.json

Can you please elaborate more on what you mean by this? An example code snippet to explain your ideas might be helpful.

Also, this could also be solved by moving d3 to peerDependencies and offload d3 import mechanism to the build system used by the project. But, most of the consumers of this library may not use d3 in their project and they might just need this component.