chore: measure impact of the default configuration on tree-shaking [POC] #432
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
maxGraph provides style defaults which is great for users, especially when evaluating the library.
It is also possible to override the defaults.
However, currently (v0.10.3), if my application doesn't use part of these defaults, the related code is imported.
For example, if my application doesn't need the
PanningHandlerplugin, it will be imported as the Graph class directly uses it (as part of the default plugins array which is always initialized whether it is used).This increase the size of my application.
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 default style registration 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: 6144386 (v0.10.3 + few changes)
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: