Skip to content

Conversation

@tbouffard
Copy link
Member

@tbouffard tbouffard commented Jun 9, 2024

DISCLAIMER

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

Context

maxGraph let's perform actions on Cells when they are selected.
This is orchestrated by the SelectionCellsHandler plugin, and it relies on some Graph methods to create dedicated handlers for edges and vertices. This indirection is coming from mxGraph and is currently still in place to simplify the migration from mxGraph.

If my application doesn't need actions on selection (for example, if it is a viewer only), I could remove the plugin (see also #432) but the EdgeHandler (several implementations are provided) and VertexHandler classes are still imported.

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

Disclaimer

The sole purpose of this PR is to measure the impact of removing Edge and Vertex Handlers implementation 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

IMPORTANT: This PR is based on a commit older than https://github.com/maxGraph/maxGraph/releases/tag/v0.12.0, so prior than maxGraph has been marked a side-effects free. Results could now be different.

base commit: 8ae6bc6 (almost like v0.11.0 - missing a refactoring)
A dedicated commit in the branch of this PR is available for each test.
The TS compilation is OK, but this may change the behavior of the application (we don't care, this is not what we test here).

ts-example

Build with vite/esbuild, maxGraph chunk

  • base: 444.95kB
  • without vertexhandler:  416.80kB
  • without edgeHandler: 407.16kB
  • removing all: 378.89 kB --> decrease: 66.06kB

js-example

Build with webpack, main.js:

  • base 512.67kB
  • without vertexhandler: 485.34kB
  • without edgeHandler: 476.24kB
  • removing all: 448.91kB --> decrease: 63.76kB

@tbouffard tbouffard added the chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...) label Jun 9, 2024
@tbouffard
Copy link
Member Author

POC completed, so closing the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant