chore: measure impact of the Graph mixins on tree-shaking [poc] by tbouffard · Pull Request #639 · maxGraph/maxGraph

DISCLAIMER

  • this PR is for exploration and information only
  • it is not intended to be merged

Context

The Graph class is very large and it has been partially splitted into mixins, to organize the code per feature. However, at runtime, this is the same as having the whole code in the Graph class definition, so some unused elements are sometimes included in an application.
This increase the size of the application. We have a plugin mechanism, that could replace this in the future.

Prior providing ways to improve the tree-shaking in this situation, here are some figures about the impact of the mixins in 2 very simple applications included in this repository.

Disclaimer

The sole purpose of this PR is to measure the impact of removing mixins on the tree-shaking.
The TypeScript compilation pass here but some features are lost or may not work in the 2 examples used to measure the impact of the removals.

Results

Note: initial commit = few commits after tag v0.14.0

ts-example no default

  • start: 441.20 kB
  • only CellsMixin: 388.82 kB (not working, some methods about listeners are missing)
  • mixins required to make the example work: 430.35 kB
  • no mixin: 365.83 kB

js-example no default

  • start: 454.22 kB
  • only CellsMixin: 401.37 kB
  • mixins required to make the example work:443.29 kB
  • no mixin: 379.39 kB