chore: measure impact of the Edge and Vertex Handlers on tree-shaking [POC] #449
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DISCLAIMER
Context
maxGraphlet's perform actions on Cells when they are selected.This is orchestrated by the
SelectionCellsHandlerplugin, and it relies on someGraphmethods to create dedicated handlers for edges and vertices. This indirection is coming frommxGraphand is currently still in place to simplify the migration frommxGraph.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
js-example
Build with webpack, main.js: