Best way to import D3 V5 library options. ( Optimize imports and dependencies )

Viewed 107

I have the following imports from D3 library in my Vue app for a d3 diagram.

import {select, zoom, event, path, html, Selection} from 'd3';

My package.json has the following dependecies :-

  "dependencies": {
     "d3": "^5.16.0",
   }

  "devDependencies": {
    "@types/d3": "^5.7.2",
  }

My builds are timing out and my slug sizes are increasing. So, I am trying to optimize the imports and I am looking for a better way to import or add dependencies in package.json

I've modified some imports as below :-

import {
  hierarchy,
  HierarchyNode,
  HierarchyPointNode,
  HierarchyLink,
  HierarchyPointLink,
  TreeLayout,
  tree,
} from 'd3-hierarchy';

But my package.json still has the entire d3 v5 library. I am using web pack as bundler.

I am looking to optimize both installing dependencies and importing specific functionalities from each dependency.

Please let me know if you have any questions.

0 Answers
Related